I know there are alot of topic about models, but

I have a code for loading a model, but it compiler always says that can't locate the .3ds model!


private Node createObjects() {
        Node objects = new Node("objects");

        Spatial boat = null;
        FormatConverter CONVERTER_3DS = new MaxToJme();
   ByteArrayOutputStream outStream = new ByteArrayOutputStream();

        try {
            FileInputStream rawIn = new FileInputStream("jmedatamodelsBoat.3ds");
            CONVERTER_3DS.convert(rawIn, outStream);
            rawIn.close();

            ByteArrayInputStream convertedIn = new ByteArrayInputStream(outStream.toByteArray());

            boat = (Spatial) BinaryImporter.getInstance().load(convertedIn);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        if(boat != null) {
            boat.setModelBound(new BoundingBox());
            boat.updateModelBound();
            objects.attachChild(boat);
        }
        return objects;
    }



java.io.FileNotFoundException: jmedatamodelsBoat.3ds (The system could not locate the specified directory)
       at java.io.FileInputStream.open(Native Method)
       at java.io.FileInputStream.<init>(FileInputStream.java:106)
       at java.io.FileInputStream.<init>(FileInputStream.java:66)
       at jme.game.Main.createObjects(Main.java:214)
       at jme.game.Main.simpleInitGame(Main.java:98)
       at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)
       at com.jme.app.SimplePassGame.initGame(SimplePassGame.java:101)
       at com.jme.app.BaseGame.start(BaseGame.java:74)
       at jme.game.Main.main(Main.java:56)


But the model is there! I really don't know what's happening...

Regards, Gustavo Borba.

Where is the path "jmedatamodels" in the stacktrace from? It does not seem to fit to the code you posted, was it two different attempts?

Is your model in a folder jmedatamodels next to the src folder (in the root of the project) or is it in the src folder (visible in you project source)?

If its the latter, you will have to specify "srcjmedatamodelsBoat.3ds" as parameter to the FileInputStream constructor. Better yet, to be able to load the model from the jar classpath of your project even after distribution use Main.class.getClassLoader().getResource("jme/data/models/Boat.3ds").openStream(); (note that here you dont specify the src prefix, as it is the root of the classpath and its slashes, no backslashes).

Well,…I wonder if you know the jmetest-Package. First approach would be to find a resource where you

know loading is working and then compare it to your code and see the difference. It seems you don't know

this kind of workflow so I'm pleased to tell you that.



Ok, to your problem. Have a look here:



http://code.google.com/p/jmonkeyengine/source/browse/trunk/src/jmetest/renderer/loader/TestMaxJmeWrite.java



Try to use something like

Yourclass.class.getClassLoader().getResource("jmedatamodelsBoat.3ds")

to get the url and

new BufferedInputStream(modelToLoad.openStream())

to get the stream.




Okay, I did it like this:


private Node createObjects() {
        Node objects = new Node("objects");

        Spatial boat = null;
        FormatConverter CONVERTER_3DS = new MaxToJme();
   ByteArrayOutputStream outStream = new ByteArrayOutputStream();

        try {
            URL url = Main.class.getClassLoader().getResource("jme/data/models/Boat.3ds");
            BufferedInputStream BI = new BufferedInputStream(url.openStream());
            CONVERTER_3DS.convert(BI, outStream);
            ByteArrayInputStream convertedIn = new ByteArrayInputStream(outStream.toByteArray());

            boat = (Spatial) BinaryImporter.getInstance().load(convertedIn);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        if(boat != null) {
            boat.setModelBound(new BoundingBox());
            boat.updateModelBound();
            objects.attachChild(boat);
        } else System.exit(0);
        return objects;
    }



Now I don't get any stack trace and the model does not shows!

Do you attach the returned objects node to the rootNode and call updateRenderState() on the rootNode?

I'm just curious if you know the word: debugging?



With the speed you replied you cannot even tried to find the error on your own.

reflectedNode.attachChild(createObjects());

rootNode.attachChild(reflectedNode);
rootNode.updateRenderState();



Yes, I have updated the rootNode yes you saw in the code above.
Yes, I debugged, and I saw something strange in this debug:

INFO: Child "2:49:6" attached to this node "TDS Scene"
03/04/2010 18:24:09 com.jme.scene.Node attachChild

The compiler added many, many, many of them. also added many of:

03/04/2010 18:24:10 com.jme.scene.Node <init>
INFO: Node created.



If I don't call createObjects(); this Infos do not show.

Maybe your model is too small or too large to see it? Did you check if you can load other 3ds models? Maybe the importer has problems with some objects and leaves them out.

But I can open this model in Blender o_o

And I already tried setLocalScale to see if it is too big/small.

What is the size of your model in Blender units?  No conversion should be taking place so a 1x1x1 box in blender should show up sized as a Vector3f(1,1,1)



Is your model's 'root' node named "TDS Scene" in Blender?

Nothing is named TDS Scene, that's why i can't understand it! I Have downloaded this model:

http://www.turbosquid.com/3d-models/free-3ds-model-dingy/447339



:confused: Please I really need help!

I just opened the model and it looks like it's situated at:



X: -114

Y: -102

Z: 0



Try moving your camera to that location and see what you get, whoever created the model didn't create it at the origin of the scene.

"TDS Scene" is the name of the root node, which is given by the MaxToJme importer.



you could also try to use the http://code.google.com/p/scenemonitor/ to see what exactly has been imported.