Empty Normalbuffer?


Hi,

another day and another problem :) maybe some of you guys have an idea.

I try to load a collada scene (Maya->Collada->jME) and it works for some meshes (animated). However, sometimes i get the following exception:


Error optimizing geometry
java.lang.NullPointerException
   at com.jme.animation.SkinNode.regenInfluenceOffsets(SkinNode.java:405)
   at com.jme.animation.SkinNode.assignSkeletonBoneInfluences(SkinNode.java:382)
   at com.jme.animation.SkinNode.updateGeometricState(SkinNode.java:287)
   at com.jmex.model.collada.ColladaImporter.optimizeGeometry(ColladaImporter.java:749)
   at com.jmex.model.collada.ColladaImporter.processCollada(ColladaImporter.java:728)
   at com.jmex.model.collada.ColladaImporter.load(ColladaImporter.java:282)
   ...



the reason for the exception is that the normal buffer inside the regenInfluenceOffsets() method in the SkinNode class is null.


ublic void regenInfluenceOffsets() {
        if (cache == null)
            return;

        Vector3f vertex = new Vector3f();
        Vector3f normal = new Vector3f();

        FloatBuffer verts, norms;
        for (int batch = cache.length; --batch >= 0;) {
            GeomBatch tb = skin.getBatch(batch);
            verts = tb.getVertexBuffer();
            norms = tb.getNormalBuffer();
            verts.clear();
            norms.clear();  // <<---- null !
       ...



has anybody of you guys had this problem before ?

Looks like no vertex normals for that mesh.  Is there an option in maya to force exporting normals?  Or perhaps they were not generated for that specific model because it was not lit or some reason like that.  (just guesses)

renanse said:

Looks like no vertex normals for that mesh.  Is there an option in maya to force exporting normals?  Or perhaps they were not generated for that specific model because it was not lit or some reason like that.  (just guesses)


hi!

the vertex normals have been exported and are stored inside the .dae file. I noticed a realy strange thing:

When the ColladaImporter parses a .dae file, it stores all obtained data in the resourceLibrary. Ok, so far so good. Also the normal-array is stored in the hashmap (resourceLibrary) correctly. After some more processing the VisualScene node is created and attached to the scene-graph. A new child node is created and attached to the VisualScene node. This node is also stored in the resourceLibrary.

(ColladaImporter.java, around line 3839 - 3843)



if (child == null) {
        child = new Node(childName);
}
      
parent.attachChild(child);

put(childName, child);



The strange thing now is, as soon as


instance.resourceLibrary.put(key, value);


is called inside the


public static void put(String key, Object value)


method in the ColladaImporter, the normal array that has been stored inside the resourceLibrary is gone ! It is removed.. The other HashMap entries are still there, just the normal array is gone!

I have attached a collada file to reproduce this effect. I would realy appreciate it, if somebody of the developers, or any other developer with some knowledge about the engine could try to load this scene.

greets
koal

the test file

http://www.speedshare.org/download.php?id=B6226E093

i ran into the same problem before.



this only occurs when u try to import an animated model. so im guessing the collada animation is the problem here.



i tried importing the same model without the animation, and everything works fine.



if u really wanna use collada, then ur only option is to force the normals on the model to be face normal instead of vertex normal.

this will fix the problem and let u import the mesh.



however, i couldnt get the animation working even after i loaded in the animated mesh. the mesh was just not moving for some reason.