Model Loading broken?

I've loaded models before in jME, but I have since deleted the code and am trying to do it again. I am following HelloModelLoading.java in the TutorialGuide packaged with the source code, but I'm getting a very strange error.



Here is my code:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package maploader;

import com.jme.app.SimpleGame;
import com.jme.scene.Node;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.converters.MilkToJme;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Student
 */
public class TestClass extends SimpleGame
{
    public static void main(String args[])
    {
        TestClass app = new TestClass();
        app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
        app.start();
    }

    @Override
    protected void simpleInitGame()
    {
        try {
            Node model;
            URL fileName = TestClass.class.getClassLoader().getResource("meshes/tree1.ms3d");
           
            MilkToJme converter = new MilkToJme();

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            converter.convert(fileName.openStream(), baos);

            model = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(baos.toByteArray()));
        } catch (IOException ex) {
            Logger.getLogger(TestClass.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}



And here is the error:

init:
deps-jar:
Compiling 1 source file to C:Documents and SettingsStudent.SCIDESK01-PCDesktopRTSProofOfConceptbuildclasses
compile-single:
run-single:
Feb 12, 2009 9:48:16 AM com.jme.app.BaseGame start
INFO: Application started.
Feb 12, 2009 9:48:16 AM com.jme.system.PropertiesIO <init>
INFO: PropertiesIO created
Feb 12, 2009 9:48:16 AM com.jme.system.PropertiesIO load
INFO: Read properties
Feb 12, 2009 9:48:19 AM com.jme.system.PropertiesIO save
INFO: Saved properties
Feb 12, 2009 9:48:19 AM com.jme.app.BaseSimpleGame initSystem
INFO: jME version 1.0
Feb 12, 2009 9:48:19 AM com.jme.input.joystick.DummyJoystickInput <init>
INFO: Joystick support is disabled
Feb 12, 2009 9:48:19 AM com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
Feb 12, 2009 9:48:19 AM com.jme.renderer.lwjgl.LWJGLRenderer <init>
INFO: LWJGLRenderer created. W:  1024H: 768
Feb 12, 2009 9:48:19 AM com.jme.app.BaseSimpleGame initSystem
INFO: Running on: ati2dvag
Driver version: 6.14.10.6444
ATI Technologies Inc. - RADEON X300 x86/SSE2 - 1.5.4334 WinXP Release
Feb 12, 2009 9:48:19 AM com.jme.renderer.AbstractCamera <init>
INFO: Camera created.
Feb 12, 2009 9:48:19 AM com.jme.util.lwjgl.LWJGLTimer <init>
INFO: Timer resolution: 1000 ticks per second
Feb 12, 2009 9:48:19 AM com.jme.scene.Node <init>
INFO: Node created.
Feb 12, 2009 9:48:20 AM com.jme.scene.Node <init>
INFO: Node created.
Feb 12, 2009 9:48:20 AM com.jme.scene.Node attachChild
INFO: Child (FPS label) attached to this node (FPS node)
Feb 12, 2009 9:48:20 AM com.jme.scene.Node <init>
INFO: Node created.
Feb 12, 2009 9:48:20 AM com.jme.scene.Node attachChild
INFO: Child (tree1.tga) attached to this node (ms3d file)
Feb 12, 2009 9:48:20 AM com.jme.util.resource.ResourceLocatorTool locateResource
WARNING: Unable to locate: tree1.tga
Feb 12, 2009 9:48:20 AM com.jme.scene.Node <init>
INFO: Node created.
Feb 12, 2009 9:48:20 AM class maploader.TestClass start()
SEVERE: Exception in game loop
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:546)
        at java.util.ArrayList.get(ArrayList.java:321)
        at com.jmex.model.animation.JointController.processController(Unknown Source)
        at com.jmex.model.animation.JointController.read(Unknown Source)
        at com.jme.util.export.binary.BinaryImporter.readObject(Unknown Source)
        at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(Unknown Source)
        at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(Unknown Source)
        at com.jme.util.export.binary.BinaryInputCapsule.readSavableArrayList(Unknown Source)
        at com.jme.scene.Spatial.read(Unknown Source)
        at com.jme.scene.Node.read(Unknown Source)
        at com.jme.util.export.binary.BinaryImporter.readObject(Unknown Source)
        at com.jme.util.export.binary.BinaryImporter.load(Unknown Source)
        at com.jme.util.export.binary.BinaryImporter.load(Unknown Source)
        at maploader.TestClass.simpleInitGame(TestClass.java:46)
        at com.jme.app.BaseSimpleGame.initGame(Unknown Source)
        at com.jme.app.BaseGame.start(Unknown Source)
        at maploader.TestClass.main(TestClass.java:30)
Feb 12, 2009 9:48:20 AM com.jme.app.BaseSimpleGame cleanup
INFO: Cleaning up resources.
Feb 12, 2009 9:48:20 AM com.jme.app.BaseGame start
INFO: Application ending.
BUILD SUCCESSFUL (total time: 6 seconds)



The model I'm trying to load is from the Loopix Project.

Most likely it's something wrong with the model converter, not necessarily model loading in general. I routinely get index out of bounds errors on loading .obj models from my modeler (DeleD…which is why I made my own importer for that tool). Has this specific model been able to load via the MilkToJme converter in the past? If so…then that would be odd…if you were able to load other models, then it may just be something weird in the model data that the converter didn't read in right.

I've never loaded this model in the past, no. I will attempt to convert the model, to see if it yields different results.

Hello. The model files import correctly into Freeworld3D, but not to Blender or jME. Any ideas?

Trussell said:

Hello. The model files import correctly into Freeworld3D, but not to Blender or jME. Any ideas?


Well if it won't import into Blender then I'm pretty sure it's the importers (or your tool's exporter) - to expand my previous example, I usually (DESPITE exporting normals) have DeleD exported .obj models get loaded into blender (and 3ds) with inverted normals. And then of course jME would throw the error you got with said .obj model. You'd think stuff like this wouldn't happen as model formats, is well a format, but exporters/importers written for specific models or scenarios definitely can deliver irregularities.

So it loads fine in Freeworld3D, is this still using the Milk format? Have you tried using another format? You know, it could also be something else (e.g. the error says when you're exporting a joint controller, boom it blows up...maybe its something wrong with that? maybe its something wrong in the milk importer in generating joints?)? If all else fails and you really want to use this format, perhaps make simple examples (that produce error) and try and pinpoint where things go wrong during conversion. Maybe you can find a fix for the  Milk importer if one exists? :)

It could very well be. Some of the models DO work, but for some reason the TGA textures that are supposed to load will not load showing transparency correctly. Any idea on a fix for that?

Trussell said:

It could very well be. Some of the models DO work, but for some reason the TGA textures that are supposed to load will not load showing transparency correctly. Any idea on a fix for that?


I'm looking through the MilkToJme source, the readMats() routine has a TODO comment to implement alpha maps (line 222)...so it looks like the importer doesn't support transparency at the moment.

But I've been using 3dsToJme and 3ds files, since none of the ms3d files seem to work. I suppose that this will be the case there as well.

Also TGA textures are only supported if uncompressed.

Actually JOC contributed a patch for compressed TGA images: http://code.google.com/p/jmonkeyengine/source/detail?r=4094

Cool!, I didn't know. I updated the wiki to reflect this fact.