- add way to invoke blender
- add blender file template

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10143 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent 01873e6f80
commit e0edc1b44c
  1. 8
      sdk/jme3-blender/nbproject/genfiles.properties
  2. 8
      sdk/jme3-blender/nbproject/project.xml
  3. 11
      sdk/jme3-blender/src/com/jme3/gde/blender/BlenderDataObject.java
  4. 130
      sdk/jme3-blender/src/com/jme3/gde/blender/BlenderTool.java
  5. 2
      sdk/jme3-blender/src/com/jme3/gde/blender/Bundle.properties
  6. 43
      sdk/jme3-blender/src/com/jme3/gde/blender/OpenInBlender.java
  7. 60
      sdk/jme3-blender/src/com/jme3/gde/blender/OutputReader.java
  8. BIN
      sdk/jme3-blender/src/com/jme3/gde/blender/blender24.png
  9. BIN
      sdk/jme3-blender/src/com/jme3/gde/blender/blender48.png
  10. 84
      sdk/jme3-blender/src/com/jme3/gde/blender/layer.xml
  11. BIN
      sdk/jme3-blender/src/com/jme3/gde/blender/tpl_box.blend

@ -1,8 +1,8 @@
build.xml.data.CRC32=6f271b27
build.xml.data.CRC32=d6432352
build.xml.script.CRC32=0f77a514
build.xml.stylesheet.CRC32=a56c6a5b@2.49.1
build.xml.stylesheet.CRC32=a56c6a5b@2.50.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=6f271b27
nbproject/build-impl.xml.data.CRC32=d6432352
nbproject/build-impl.xml.script.CRC32=5c5042d6
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49.1
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1

@ -74,6 +74,14 @@
<specification-version>7.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.modules</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.32.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.nodes</code-name-base>
<build-prerequisite/>

@ -8,10 +8,21 @@ import com.jme3.asset.BlenderKey;
import com.jme3.asset.ModelKey;
import com.jme3.gde.core.assets.SpatialAssetDataObject;
import java.io.IOException;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject.Registration;
import org.openide.loaders.DataObjectExistsException;
import org.openide.loaders.MultiFileLoader;
//TODO: move this new way of registering to core
@Registration(displayName = "CTL_OpenInBlender", iconBase = "com/jme3/gde/blender/blender.png", mimeType = "application/blender")
@ActionReferences(value = {
@ActionReference(id =
@ActionID(category = "jMonkeyPlatform", id = "com.jme3.gde.core.assets.actions.ConvertModel"), path = "Loaders/application/blender/Actions", position = 10),
@ActionReference(id =
@ActionID(category = "jMonkeyPlatform", id = "com.jme3.gde.core.assets.actions.OpenModel"), path = "Loaders/application/blender/Actions", position = 20)})
public class BlenderDataObject extends SpatialAssetDataObject {
public BlenderDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {

@ -0,0 +1,130 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.jme3.gde.blender;
import com.jme3.math.Vector3f;
import java.io.File;
import java.io.IOException;
import java.util.logging.Logger;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.filesystems.FileObject;
import org.openide.modules.InstalledFileLocator;
import org.openide.util.Exceptions;
import org.openide.util.Utilities;
/**
*
* @author normenhansen
*/
public class BlenderTool {
private static final Logger logger = Logger.getLogger(BlenderTool.class.getName());
private static boolean running = false;
// private static AtomicBoolean running = new AtomicBoolean(false);
private static String getBlenderExeName() {
if (Utilities.isWindows()) {
return "blender.exe";
} else {
return "blender";
}
}
public static File getBlenderExecutable() {
File blender = InstalledFileLocator.getDefault().locate("../blender/" + getBlenderExeName(), null, false);
if (blender == null) {
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Error finding Blender!"));
}
return blender;
}
public static File getBlenderSettingsFolder() {
File blender = InstalledFileLocator.getDefault().locate("../blender/2.64", null, false);
if (blender == null) {
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Error finding Blender!"));
}
return blender;
}
public static File getBlenderRootFolder() {
// File appFolder = InstalledFileLocator.getDefault().locate("bin", null, false).getParentFile().getParentFile();
// if (appFolder != null) {
// DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(appFolder.toString()));
// }
File blender = InstalledFileLocator.getDefault().locate("../blender", null, false);
if (blender == null) {
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Error finding Blender!"));
}
return blender;
}
public static boolean openInBlender(FileObject file){
String path = file.getPath().replace("/", File.separator);
return runBlender(path, true);
}
public static boolean runBlender(final String options, boolean async) {
if (running) {
return false;
}
running = true;
//TODO: wtf, for some reason i cannot access AtomicBoolean..
final Vector3f v = new Vector3f(0, 0, 0);
final File exe = getBlenderExecutable();
if (exe == null) {
return false;
}
Runnable r = new Runnable() {
public void run() {
try {
String command = null;
if (options != null) {
command = exe.getAbsolutePath() + " " + options;
} else {
command = exe.getAbsolutePath();
}
Process proc = Runtime.getRuntime().exec(command);
OutputReader outReader = new OutputReader(proc.getInputStream());
// outReader.setProgress(handle);
OutputReader errReader = new OutputReader(proc.getErrorStream());
// errReader.setProgress(handle);
outReader.start();
errReader.start();
try {
proc.waitFor();
} catch (InterruptedException ex) {
Exceptions.printStackTrace(ex);
}
if (proc.exitValue() != 0) {
v.x = 1;
}
running = false;
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
v.x = 1;
running = false;
}
}
};
if (async) {
new Thread(r).start();
} else {
r.run();
}
if (v.x != 1) {
return true;
} else {
return false;
}
}
public static void runBlender() {
if(!runBlender(null, true)){
DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message("Error running Blender."));
}
}
}

@ -5,4 +5,4 @@ OpenIDE-Module-Long-Description=\
OpenIDE-Module-Name=Blender Support
OpenIDE-Module-Short-Description=Adds support for Blender .blend files
Services/MIMEResolver/BlenderResolver.xml=Blender Files
Templates/Other/BlenderTemplate.blend=Empty Blender file
Templates/Other/tpl_box.blend=Basic Box Blender file

@ -0,0 +1,43 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.jme3.gde.blender;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;
@ActionID(
category = "jMonkeyEngine",
id = "com.jme3.gde.blender.OpenBlender")
@ActionRegistration(
iconBase = "com/jme3/gde/blender/blender.png",
displayName = "#CTL_OpenInBlender")
@ActionReferences({
@ActionReference(path = "Menu/Tools", position = 3333),
@ActionReference(path = "Toolbars/File", position = 335),
@ActionReference(path = "Loaders/application/blender/Actions", position = 30)
})
@Messages("CTL_OpenInBlender=Open in Blender")
public final class OpenInBlender implements ActionListener {
private final BlenderDataObject context;
public OpenInBlender(BlenderDataObject context) {
this.context = context;
}
@Override
public void actionPerformed(ActionEvent ev) {
if (!BlenderTool.openInBlender(context.getPrimaryFile())) {
DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message("Error opening Blender with file " + context.getPrimaryFile().getNameExt()));
}
}
}

@ -0,0 +1,60 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.jme3.gde.blender;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.api.progress.ProgressHandle;
/**
*
* @author normenhansen
*/
public class OutputReader implements Runnable {
private Thread thread;
private BufferedReader in;
private ProgressHandle progress;
public OutputReader(InputStream in) {
this.in = new BufferedReader(new InputStreamReader(in));
}
public OutputReader(BufferedReader in) {
this.in = in;
}
public void start() {
thread = new Thread(this);
thread.start();
}
public void run() {
try {
String line;
while ((line = in.readLine()) != null) {
if (line.trim().length() > 0) {
if (progress != null) {
progress.progress(line);
} else {
Logger.getLogger(OutputReader.class.getName()).log(Level.INFO, "{0}",line);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param progress the progress to set
*/
public void setProgress(ProgressHandle progress) {
this.progress = progress;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

@ -1,82 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="Loaders">
<folder name="application">
<folder name="blender">
<folder name="Actions">
<file name="com-jme3-gde-core-assets-actions-ConvertModel.shadow">
<attr name="originalFile" stringvalue="Actions/jMonkeyPlatform/com-jme3-gde-core-assets-actions-ConvertModel.instance"/>
<attr name="position" intvalue="10"/>
</file>
<file name="com-jme3-gde-core-assets-actions-OpenModel.shadow">
<attr name="originalFile" stringvalue="Actions/jMonkeyPlatform/com-jme3-gde-core-assets-actions-OpenModel.instance"/>
<attr name="position" intvalue="20"/>
</file>
<file name="org-openide-actions-CopyAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CopyAction.instance"/>
<attr name="position" intvalue="300"/>
</file>
<file name="org-openide-actions-CutAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CutAction.instance"/>
<attr name="position" intvalue="200"/>
</file>
<file name="org-openide-actions-DeleteAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-DeleteAction.instance"/>
<attr name="position" intvalue="500"/>
</file>
<file name="org-openide-actions-FileSystemAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-FileSystemAction.instance"/>
<attr name="position" intvalue="1000"/>
</file>
<file name="org-openide-actions-PropertiesAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-PropertiesAction.instance"/>
<attr name="position" intvalue="1300"/>
</file>
<file name="org-openide-actions-RenameAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-RenameAction.instance"/>
<attr name="position" intvalue="600"/>
</file>
<file name="org-openide-actions-SaveAsTemplateAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-SaveAsTemplateAction.instance"/>
<attr name="position" intvalue="800"/>
</file>
<file name="org-openide-actions-ToolsAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-ToolsAction.instance"/>
<attr name="position" intvalue="1200"/>
</file>
<file name="sep-1.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="100"/>
</file>
<file name="sep-2.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="400"/>
</file>
<file name="sep-3.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="700"/>
</file>
<file name="sep-4.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="900"/>
</file>
<file name="sep-5.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="1100"/>
</file>
</folder>
<folder name="Factories">
<file name="BlenderDataLoader.instance">
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:/com/jme3/gde/blender/blender.png"/>
<attr name="dataObjectClass" stringvalue="com.jme3.gde.blender.BlenderDataObject"/>
<attr name="instanceCreate" methodvalue="org.openide.loaders.DataLoaderPool.factory"/>
<attr name="mimeType" stringvalue="application/blender"/>
</file>
</folder>
</folder>
</folder>
</folder>
<folder name="Services">
<folder name="MIMEResolver">
<file name="BlenderResolver.xml" url="BlenderResolver.xml">
@ -84,4 +8,12 @@
</file>
</folder>
</folder>
<folder name="Templates">
<folder name="Blender">
<file name="tpl_box.blend" url="tpl_box.blend">
<attr name="displayName" bundlevalue="com.jme3.gde.blender.Bundle#Templates/Other/tpl_box.blend"/>
<attr name="template" boolvalue="true"/>
</file>
</folder>
</folder>
</filesystem>

Loading…
Cancel
Save