Problem with the loading of a *-jme.xml file

Hi to all!



I'm new in this forum, and actually I'm new in 3d programming too…



for a university project I have to make a java game, so I decided to use jMonkey Engine



I followed both flagrush tutorials and jme physics tutorials and I had no problem



I use eclipse galileo IDE, jME 2.0.0 (I had problem with jME 2.0.1 and physics for final methods) and jME Physics 2.1



now I want to learn how to load 3d models in my game, and after the succesfully load of .3ds .md3 .ase .obj files, I'm trying to load a .xml file, because I have to load an animated model for the soldiers of my game



I followed the HottBJ basics tutorial, but I have problem with the loading of my *-jme.xml file (it's just the blender's plane)



I try with the XmlWorld class, but I always got this error (both in eclipse and netBeans):



java.lang.IllegalArgumentException: Failed to load URL: file:/home/sal/Scrivania/progetti/jME_proj/src/xmlLoader/default-jme.xml



the URL is correct, the file default-jme.xml is actually in the xmlLoader package but the loader failed to load it!

I searched in the forum for this problem and I found some topics, but I can't found the solution!

can anyone help me please??

ps: sorry for my english...I'm italian...

Post the compete Exception trace, which probably spells out the specific problem in the nested cause.

GRAVE: Exception in game loop
java.lang.IllegalArgumentException: Failed to load URL: file:/D:/Documenti/java3d/jme3d-prova1/bin/default-jme.xml
   at customGame.XmlWorld.loadModel(XmlWorld.java:42)
   at customGame.XmlWorld.simpleInitGame(XmlWorld.java:32)
   at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:544)
   at com.jme.app.BaseGame.start(BaseGame.java:74)
   at customGame.XmlWorld.main(XmlWorld.java:15)
Caused by: java.io.IOException
   at com.jme.util.export.xml.DOMInputCapsule.readSavable(DOMInputCapsule.java:786)
   at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:95)
   at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:108)
   at customGame.XmlWorld.loadModel(XmlWorld.java:40)
   ... 4 more
Caused by: java.io.IOException
   at com.jme.util.export.xml.DOMInputCapsule.readSavableArrayList(DOMInputCapsule.java:960)
   at com.jme.scene.Node.read(Node.java:679)
   at com.jme.util.export.xml.DOMInputCapsule.readSavableFromCurrentElem(DOMInputCapsule.java:819)
   at com.jme.util.export.xml.DOMInputCapsule.readSavable(DOMInputCapsule.java:779)
   ... 7 more
Caused by: java.lang.NumberFormatException: For input string: ""
   at java.lang.NumberFormatException.forInputString(Unknown Source)
   at java.lang.Integer.parseInt(Unknown Source)
   at java.lang.Integer.parseInt(Unknown Source)
   at com.jme.util.export.xml.DOMInputCapsule.readSavableArrayList(DOMInputCapsule.java:947)
   ... 10 more
17-ott-2009 0.51.58 com.jme.app.BaseSimpleGame cleanup
INFO: Cleaning up resources.
17-ott-2009 0.51.58 com.jme.app.BaseGame start
INFO: Application ending.



and this is the class:

public class XmlWorld extends SimpleGame {

    static public void main(String[] args) {
        XmlWorld xmlWorld = new XmlWorld();
        xmlWorld.start();
    }

    protected void simpleInitGame() {
        URL url = XmlWorld.class.getClassLoader().getResource("default-jme.xml");
        try {
            MouseInput.get().setCursorVisible(true);
            ((FirstPersonHandler) input).setButtonPressRequired(true);
        } catch (Exception e) {
            e.printStackTrace();
            finish();
        }
        loadModel( url );
    }

    protected void loadModel(URL modelUrl) {
        Node loadedSpatial = null;
        try {
            loadedSpatial = (Node) XMLImporter.getInstance().load(modelUrl);
        } catch (Exception e) {
            throw new IllegalArgumentException(
                    "Failed to load URL: " + modelUrl, e);
        }
        loadedSpatial.setModelBound(new BoundingBox());
        rootNode.attachChild(loadedSpatial);
        loadedSpatial.updateModelBound();
        rootNode.updateRenderState();
    }
}

HottBJ is not compatible with jME 2.0.0, as documented on the main online help page under "Usage Tips".

blaine said:

HottBJ is not compatible with jME 2.0.0, as documented on the main online help page under "Usage Tips".


sorry I haven't read that...

so I have to use jME 2.0.1??

I want to use physics in my game, and I had problems with jme 2.0.1 and jme physics due to the final method findCollision and hasCollision...how can I fix this problem?

no version of the HottBJ exporter works with jme 2.0.0 ??

thanks for the answer...

HottBJ and jME are under heavy development and blaine's exporter is very close to the jME-core where he is extending lot's of stuff.  So if you really intend to develop with jME there is in my oppinon no way round using the svn-version.  Use this tutorial to setup your eclipse to use svn:



Tutorial(3.4):

http://www.jmonkeyengine.com/wiki/doku.php?id=setting_up_eclipse_to_build_jme_2

Video-Tutorial by core-dump(3.5):

http://www.jmonkeyengine.com/wiki/doku.php?id=video_tutorial_-_setting_up_eclipse_to_build_jme_2


ttrocha said:

HottBJ and jME are under heavy devlopment and blaine's exporter is very close to the jME-core and he is extending lot's of stuff.  So if you really intend to develop with jME there is in my oppinon no way round using the svn-version.  Use this tutorial to setup your eclipse to use svn:

Tutorial:
http://www.jmonkeyengine.com/wiki/doku.php?id=setting_up_eclipse_to_build_jme_2
Video-Tutorial by core-dump:
http://www.jmonkeyengine.com/wiki/doku.php?id=video_tutorial_-_setting_up_eclipse_to_build_jme_2




ok I'll try it, but what about the problems with jme physics??

I have just tried to export the -jme.xml model from the Modeler to jme binary (.jme)
and it's correctly loaded into my jme base game...

Don't know about your "final" problem. But if you want to extend Spatial you should overwrite the abstract method


    public abstract void findCollisions(
            Spatial scene, CollisionResults results, int requiredOnBits);



The one you want to change is a wrapper that is just for keeping compatibility with a former method-call. (This calls your implemented abstract class)

ttrocha said:

Don't know about your "final" problem. But if you want to extend Spatial you should overwrite the abstract method

    public abstract void findCollisions(
            Spatial scene, CollisionResults results, int requiredOnBits);



The one you want to change is a wrapper that is just for keeping compatibility with a former method-call. (This calls your implemented abstract class)




when I had problems, I used jme 2.0.1 and physics 2.1 not updated (the downloadable version in google code)
now it's all right with subclipse and svn!

I'm going to try the loading of an xml

ok, now all works!



thanks a lot for your patience



I think I'll ask you for help soon!  :smiley:

HottBJ (incll. v 0.4a and Subversion) works fine with jME 2.0.1.  Upcoming versions and Subversion (of HottBJ) will probably remain compatible with jME 2.0.1 for months.



When it becomes incompatible with 2.0.1, I'll note that on the main online help page and in the release announcement Topic.

I have another question…



I loaded the monkey xml model in my flagRush game, and located it to 50,50 x,z coordinates

but when I run the game, if I don’t go with my player very near the monkey, I just see an empty and trasparent space instead of it!







the model is correctly visualized (with texture too) only if my player is near the model







and this is the code:


Node model = null;

URL url = Game3.class.getClassLoader().getResource("models/default-jme.xml");

try {
   model = (Node)XMLImporter.getInstance().load( url );
   
} catch (IOException e) {
   e.printStackTrace();
}
model.setLocalScale(3f);
model.setLocalTranslation(50, terrain.getHeight(50,50) + 3, 50);
model.setModelBound( new BoundingBox() );
model.updateModelBound();

scene.attachChild( model );

// scene is my rootNode
scene.attachChild( model );

scene.updateGeometricState(0, true);
scene.updateRenderState();



I thought that was caused by the cullstate optimization, but it's not so...
slash17 said:

I have another question...

I loaded the monkey xml model in my flagRush game, and located it to 50,50 x,z coordinates
but when I run the game, if I don't go with my player very near the monkey, I just see an empty and trasparent space instead of it! ...


Interesting.  Do you have a ZBufferState for your scene?  Try replacing the imported model with a jME Box textured with the same image to distinguish whether the problem is with the model, or with your scene or game engine.
blaine said:

slash17 said:

I have another question...

I loaded the monkey xml model in my flagRush game, and located it to 50,50 x,z coordinates
but when I run the game, if I don't go with my player very near the monkey, I just see an empty and trasparent space instead of it! ...


Interesting.  Do you have a ZBufferState for your scene?  Try replacing the imported model with a jME Box textured with the same image to distinguish whether the problem is with the model, or with your scene or game engine.


it's a very strange problem!!
if I move the code in the initGame instead of the buildEnvironment function (called in the initGame) all works...

it's the same thing with a simple textured box!

I can't understand what is the problem....

the buildEnvironment function, just like the flagRush tutorial, create a fenze by calling it's constructor, scale and locate it, and attach it to the rootNode, and I add just the code for the loading of the monkey model...

If you want to pursue it, you should make a simpler test case using a Box or similar and start a new, more specific Topic, to address the issue without the complication of *-jme.xml etc.

I tried with the box and with a sphere too…



the problem come if I put the code for the creation of a box (or anything other) in some function:

buildEnvironment

buildTerrain

buildSkybox

etc



but there is no problem if I put the code in the buildPlayer function or in the buildChaseCamera function or in a new function!!!



it's very very strange…




one more thing…

I'm following the tutorial for animation and I create my basic robot and it works fine with the Modeler…but actually I'm not able to program something for automate movements for my robot



I saw "I wish I had the time to work up an example using a SpatialController to toggle walking animations for our robot. Email me if you want to see this. " in the tutorial…



can you send me your example or give me some guidelines?