Fix for empty nodes in blender not ranged in hierarchy

@Kaelthas Could this be added?

I used among others this file with empty parents to confirm it’s working.

http://depositfiles.com/files/7mjxebfyg



[patch]Index: src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java

===================================================================

— src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java (revision 8315)

+++ src/blender/com/jme3/scene/plugins/blender/objects/ObjectHelper.java (working copy)

@@ -152,6 +152,14 @@

LOGGER.log(Level.INFO, “Importing empty.”);

Node empty = new Node(name);

empty.setLocalTransform(t);

+

  •                //setting the parent<br />
    
  •   			if(parent instanceof Node) {<br />
    
  •   				((Node)parent).attachChild(empty);<br />
    
  •   			}<br />
    

+

  •                //I prefer do calculate bounding box here than read it from the file<br />
    
  •   			empty.updateModelBound();<br />
    

result = empty;

break;

case OBJECT_TYPE_MESH:



[/patch]

It looks fine.

Seems that I forgot to attach an empty to its parent. :wink:

@Kaelthas I’m sure you have enough work already but could you remember to add the fix above, please?



Btw. something different… when you have a incomplete mesh in your blend file by mistake, like a stand alone edge, you get following exception. Something more descriptive than a NullPointerException would be cool, that’s not so important, though.



[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at com.jme3.scene.plugins.blender.meshes.MeshHelper.toMesh(MeshHelper.java:157)

at com.jme3.scene.plugins.blender.objects.ObjectHelper.toObject(ObjectHelper.java:174)

at com.jme3.scene.plugins.blender.AbstractBlenderLoader.toObject(AbstractBlenderLoader.java:135)

at com.jme3.scene.plugins.blender.BlenderLoader.toObject(BlenderLoader.java:1)

at com.jme3.scene.plugins.blender.BlenderModelLoader.toObject(BlenderModelLoader.java:1)

at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:64)

at com.jme3.scene.plugins.blender.BlenderModelLoader.load(BlenderModelLoader.java:1)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:243)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:376)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:230)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

at java.lang.Thread.run(Thread.java:662)[/java]

Sorry I’ve completely forgot to add empty to its parent.

Already fixed and commited :wink:



As for the NPE here this is caused by the lack of faces.

I can add a fix but I’d rather discuss first what to do with such situation.



@normen wht do you think?

Shall I Import the mesh without faces as a point or line ?

Or shall I not import it at all and create an empty node.

In blender you can see the mesh without faces as one made of edges only.

But it cannot be seen in the rendered images.



Maybe I should add an option in the blender key about that ?

Hm, hard to say… Basically I would say if theres no faces the model is broken for a game ^^ I’d say leave them out and put out warnings… The guy who sees a use in these will probably explain it to us then if he exists :slight_smile: