Exception in a ms3d with bones

Hi… i done a mesh of a body in milkshape. Then added some bones and animate them to test controlling it with keyframes.

When the programs loads throws an exception:





java.lang.ArrayIndexOutOfBoundsException: -1

at com.jme.animation.JointController.updateData(JointController.java:233)

at com.jme.animation.JointController.update(JointController.java:220)

at com.jme.scene.Spatial.updateWorldData(Spatial.java:408)

at com.jme.scene.Node.updateWorldData(Node.java:213)

at com.jme.scene.Spatial.updateGeometricState(Spatial.java:388)

at com.jme.scene.Node.updateWorldData(Node.java:218)

at com.jme.scene.Spatial.updateGeometricState(Spatial.java:388)

at com.jme.scene.Node.updateWorldData(Node.java:218)

at com.jme.scene.Spatial.updateGeometricState(Spatial.java:388)

at com.jme.app.SimpleGame.update(SimpleGame.java:123)

at com.jme.app.BaseGame.start(BaseGame.java:68)

at com.vlad.game.main.GameStart.main(GameStart.java:57)





here´s the loading code:



public void loadMilk(String mesh, String gfxdir) {
      MilkToJme converter = new MilkToJme();
      ByteArrayOutputStream BO = new ByteArrayOutputStream();
      URL MSFile = null;
      
      try {
         MSFile = new File(mesh).toURL();
         converter.convert(MSFile.openStream(), BO);
      } catch (IOException e) {
         System.out.println("IO problem writting the file!!!");
         System.out.println(e.getMessage());
         System.exit(0);
      }
      JmeBinaryReader jbr = new JmeBinaryReader();
      Node i = null;
      try {
         URL TEXdir = new File(gfxdir).toURL();
         jbr.setProperty("texurl", TEXdir);
         jbr.setProperty("bound","box");
         i = jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
      } catch (IOException e) {
         System.out.println("darn exceptions:" + e.getMessage());
      }
      i.setLocalScale(.1f);
      rootNode.attachChild(i);

   }



What could it be?

There was a bug in the animator that made it assume all vertex had a joint assigned to them, which is the -1 you’re seeing. It’s fixed (or should be) in the current version. Update from the CVS and try again. Let me know how it goes.

"Cep21" wrote:
There was a bug in the animator that made it assume all vertex had a joint assigned to them, which is the -1 you're seeing. It's fixed (or should be) in the current version. Update from the CVS and try again. Let me know how it goes.

Downloaded again the latest version from the cvs and the problem persist. Want the model?

What classes changed?

If you’re getting the same error at the same line



at com.jme.animation.JointController.updateData(JointController.java:233)



I can guarantee you’re not using the CVS because line 233 is something like


int curIndex;



which can't get that kind of exception.


Do you have jme.jar in your classpath along with the .java files? If so that could be the problem
"Cep21" wrote:
If you're getting the same error at the same line

at com.jme.animation.JointController.updateData(JointController.java:233)

I can guarantee you're not using the CVS because line 233 is something like

int curIndex;



which can't get that kind of exception.


Do you have jme.jar in your classpath along with the .java files? If so that could be the problem

mmmmm... you are right. I have configured my proyect including the jme proyect (not using the jar file.. i opened a new proyect and put the jme source there and then in the my proyect properties, included the jme). If i not include it, the jme classes are not viewed from my proyect so i am sure that i am getting the classes from there but when a get the line 233 (int currentBoneIndex; different from the one you are saying) is where i get the exception!

I did a full clean from the .class but is the same. Obviously theres is a problem with my eclipse, not the code. What can i do? I updated all from the /src in the cvs. It´s ok?

What command is java executing when it compiles your program? What command is java executing when it runs the class file?

"Cep21" wrote:
What command is java executing when it compiles your program? What command is java executing when it runs the class file?

What do you mean about "command"? I tell you what i do: first i put a breakpoint here:


   private void updateData(){
        for (int currentGroup=0;currentGroup<movingMeshes.size();currentGroup++){
            JointMesh2 updatingGroup=(JointMesh2) movingMeshes.get(currentGroup);
            int currentBoneIndex; //<-- here the breakpoint
            Vector3f[] vertexes=updatingGroup.getVertices();
            Vector3f[] normals=updatingGroup.getNormals();
            int j;
            for (j=0;j<updatingGroup.jointIndex.length;j++){
                currentBoneIndex=updatingGroup.jointIndex[j];
                if (currentBoneIndex==-1) continue;
                unSyncbeginPos.set(updatingGroup.originalVertex[j]);
                vertexes[j].set(jointMovements[currentBoneIndex].multPoint(unSyncbeginPos));
                unSyncbeginPos.set(updatingGroup.originalNormal[j]);
                normals[j].set(jointMovements[currentBoneIndex].multNormal(unSyncbeginPos));
            }
            if (j!=0){
                updatingGroup.updateVertexBuffer();
                updatingGroup.updateNormalBuffer();
                if (updatePerFrame) updatingGroup.updateModelBound();
            }
        }
    }



and when the debugline passes over that line, in the variable inspector, magically appears currentboneindex = -1 !!! Seem like the eclipse is debugging something but is not "synchronized" with what is showing to me. Now if i comment that line, the debugger also passes!!

Eclipse bug??

The command line command that your IDE uses to run the java program. Like


java -cp ./build -Djava.library.path=./lib com.jme.TutoriolGuide.HelloWorld


or something similar.

I don't know eclipse, so I can't debug the IDE for you unfortunantly. If it was IntelliJ I could help you. Maybe someone else knows eclipse?

My bet is that you've got jme.jar in your classpath or some other refrence to an old version of the class file.

Yeah… probably is that. Or at last, eclipse seem to “working” :’( that way.

Let me fix that and later we can check out the other problem.



If anyone reading this knows how to fix it, please tell me.

Thanks!

another thing: please tellme the exact and complete route in the cvs where the latest javas are posted. Dont know why is bringing me an alder version.

I’m not sure what you mean by direct route, but the following command will download the most up to date .java source


cvs -d :pserver:guest@cvs.dev.java.net:/cvs checkout -P jme
"Cep21" wrote:
I'm not sure what you mean by direct route, but the following command will download the most up to date .java source

cvs -d :pserver:guest@cvs.dev.java.net:/cvs checkout -P jme

cep.. archived the full jme proyect in one jar and removed the references from my proyect properties and worked everything! Can see the model with the bones animation. Thanks..

Now other thing.. it is normal seeing the full animation until i set the keyframe controllers??

The animation plays by default. You have to turn it off, or set start/end times and such yourself if you want all that.



Glad it worked. I bet that fixes the repeating texture problem you had before too.

"Cep21" wrote:
The animation plays by default. You have to turn it off, or set start/end times and such yourself if you want all that.

Glad it worked. I bet that fixes the repeating texture problem you had before too.

Ha! i forgotted the texture problem! I was resignated with it! :D Will try and later tell you!

Thanks again!

Hi again… now this similar problem its happening with another model (also with bones and animation)



INFO: Child (ms3d file) attached to this node (XML loaded scene)

11-sep-2004 8:37:41 com.jme.scene.Node attachChild

INFO: Child (XML loaded scene) attached to this node (rootNode)

java.lang.IndexOutOfBoundsException: Index: 27, Size: 1

at java.util.ArrayList.RangeCheck(Unknown Source)

at java.util.ArrayList.get(Unknown Source)

at com.jme.scene.Node.getChild(Node.java:219)

at com.vlad.game.util.MeshLoader.nodeTest(MeshLoader.java:86)

at com.vlad.game.util.MeshLoader.loadMilk(MeshLoader.java:79)

at com.vlad.game.main.GameStart.simpleInitGame(GameStart.java:45)

at com.jme.app.SimpleGame.initGame(SimpleGame.java:329)

at com.jme.app.BaseGame.start(BaseGame.java:63)

at com.vlad.game.main.GameStart.main(GameStart.java:22)

11-sep-2004 8:37:41 com.jme.app.SimpleGame cleanup

INFO: Cleaning up resources.

11-sep-2004 8:37:41 com.jme.app.BaseGame start

INFO: Application ending.




Here is the ms3d i use:



http://nicolasl.sion.com/man2.ms3d

This code works for me. Notice the power of the loader, I load it directly from your webpage }:slight_smile: }:slight_smile:



While loading your model, I did notice a quirk about the ms3d format. If it looks funky, just update from CVS and try it.




public class TestMilkJmeWrite extends SimpleGame{
    public static void main(String[] args) {
        new TestMilkJmeWrite().start();
    }

    protected void simpleInitGame() {

        MilkToJme converter=new MilkToJme();
//        URL MSFile=TestMilkJmeWrite.class.getClassLoader().getResource(
//        "jmetest/data/model/msascii/run.ms3d");
        ByteArrayOutputStream BO=new ByteArrayOutputStream();

        try {
            URL MSFile=new URL("http://nicolasl.sion.com/man2.ms3d");
            converter.convert(MSFile.openStream(),BO);
        } catch (IOException e) {
            System.out.println("IO problem writting the file!!!");
            System.out.println(e.getMessage());
            System.exit(0);
        }
        JmeBinaryReader jbr=new JmeBinaryReader();
        URL TEXdir=TestMilkJmeWrite.class.getClassLoader().getResource(
                "jmetest/data/model/msascii/");
        jbr.setProperty("texurl",TEXdir);
        Node i=null;
        try {
            i=jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
        } catch (IOException e) {
            System.out.println("darn exceptions:" + e.getMessage());
        }
        i.setLocalScale(.1f);
        rootNode.attachChild(i);
    }

    private void drawAxis() {
        rootNode.attachChild(new Box("axisX",new Vector3f(5,0,0),5f,.1f,.1f));
        rootNode.attachChild(new Box("axisY",new Vector3f(0,5,0),.1f,5f,.1f));
        rootNode.attachChild(new Box("axisZ",new Vector3f(0,0,5),.1f,.1f,5f));
    }
}

sorry… was completly my fault :// … i was trying to get a node that doesnt exist in this model.



Thanks!