Problem with XMLExporter/XMLImporter and objects containing physics nodes

Hello



I’m trying to load a model exported from blender (HottBj), attach some physic to it (jME Physics 2) and export it, so i could use it in game without having to set up physic again (it will be some kind of modeler for my game), but im gettings some errors ( i wrote it already http://www.jmonkeyengine.com/forum/index.php?topic=11898.0 ). If i use some thing like in following piece of code (with some Box)

PhysicsSpace pSpace = PhysicsSpace.create();

      pSpace.setupBinaryClassLoader(BinaryImporter.getInstance());

      

      DynamicPhysicsNode pNode = pSpace.createDynamicNode();

      Box some_box = new Box( “some_box”, new Vector3f(), 5, 0.25f, 5 );

      pNode.attachChild(some_box);

      pNode.generatePhysicsGeometry();



      File phys_file = new File("/home/users/pablo/phys_model.xml");

      try {

         XMLExporter.getInstance().save(pNode, phys_file);

         //Node tmpNode = (Node)XMLImporter.getInstance().load(phys_file);

      } catch (IOException e) {

         e.printStackTrace();

      }

exports works without any exception, but in phys_file.xml i can see many things like (with NaN)

     <MapEntry>

                                 <Key class=‘com.jmex.physics.material.Material’ density=‘0.9’ name=‘ice’ reference_ID=‘com.jmex.physics.material.Material@14982605’>

                                        <contactHandlingDetails>

                                            <MapEntry>

                                                <Value bounce=‘0.2’ class=‘com.jmex.physics.contact.MutableContactInfo’ dampingCoefficient=‘NaN’ minimumBounceVelocity=‘1.0’ mu=‘0.0020’ muOrthogonal=‘NaN’ springConstant=‘NaN’>

                                                    <sufaceMotion class=‘com.jme.math.Vector2f’/>

                                                    <slip class=‘com.jme.math.Vector2f’ x=‘NaN’ y=‘NaN’/>

                                                    <frictionDirection class=‘com.jme.math.Vector3f’ x=‘NaN’ y=‘NaN’ z=‘NaN’/>

                                                </Value>

                                            </MapEntry>

And if i try to load this file with something like in this piece of code

PhysicsSpace pSpace = PhysicsSpace.create();

      pSpace.setupBinaryClassLoader(BinaryImporter.getInstance());

      File phys_file = new File("/home/users/pablo/phys_model.xml");

      try {

         Node tmpNode = (Node)XMLImporter.getInstance().load(phys_file);

      } catch (IOException e) {

         e.printStackTrace();

      }

I will get following exception

java.io.IOException: java.lang.InstantiationException: com.jmex.physics.impl.ode.DynamicPhysicsNodeImpl

   at com.jme.util.export.xml.DOMInputCapsule.readSavable(DOMInputCapsule.java:978)

   at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:75)

   at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:119)

   at gProject0.samples.PhysicExportTest.simpleInitGame(PhysicExportTest.java:36)

   at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)

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

   at gProject0.samples.PhysicExportTest.main(PhysicExportTest.java:21)

Caused by: java.lang.InstantiationException: com.jmex.physics.impl.ode.DynamicPhysicsNodeImpl

   at java.lang.Class.newInstance0(Class.java:340)

   at java.lang.Class.newInstance(Class.java:308)

   at com.jme.util.export.xml.DOMInputCapsule.readSavableFromCurrentElem(DOMInputCapsule.java:1005)

   at com.jme.util.export.xml.DOMInputCapsule.readSavable(DOMInputCapsule.java:969)

   … 6 more

Where PhysicExportTest.java is my class file. Tests for jME2 and jME Physics 2 works. How can i do it correctly?? I will be grateful for help :slight_smile:



PS:

Sorry for my English.

there are no active jmephysics developers.



I guess since DynamicPhysicsNodeImpl has no default constructor, it cannot be exprted/imported?

Core-Dump said:

there are no active jmephysics developers.

I guess since DynamicPhysicsNodeImpl has no default constructor, it cannot be exprted/imported?


I'm not looking at the class, so I don't know, but if it has no constructor at all then the implied default constructor will work.  If any non-default contructor is implemented, then the no-param constructor must be implemented too.

There could be other problems, but it's pretty obvious that there are bugs with some Savable.write() implementations in the Physics classes.  You need to get the attention of the Physics 2 developers.  Perhaps make a new Topic in the Physics forum here…  or maybe ask a moderator to move this Topic there.

If i use BinaryImporter/BinaryExporter all works fine.



Today i updated a jME2 and jME Physics 2 jar’s (build from source) and now i’m getting

INFO: PhysicsNode (null) has been added

java.io.IOException: java.lang.NullPointerException

   at com.jme.util.export.xml.DOMInputCapsule.readSavableArrayList(DOMInputCapsule.java:1143)

   at com.jme.scene.Node.read(Node.java:683)

   at com.jmex.physics.PhysicsNode.read(PhysicsNode.java:633)

   at com.jmex.physics.DynamicPhysicsNode.read(DynamicPhysicsNode.java:254)

   at com.jmex.physics.impl.ode.DynamicPhysicsNodeImpl.read(DynamicPhysicsNodeImpl.java:450)

   at com.jme.util.export.xml.DOMInputCapsule.readSavableFromCurrentElem(DOMInputCapsule.java:986)

   at com.jme.util.export.xml.DOMInputCapsule.readSavable(DOMInputCapsule.java:946)

   at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:75)

   at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:119)

   at gProject0.samples.PhysicExportTest.simpleInitGame(PhysicExportTest.java:41)

   at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)

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

   at gProject0.samples.PhysicExportTest.main(PhysicExportTest.java:50)

Caused by: java.lang.NullPointerException

   at com.jmex.physics.PhysicsCollisionGeometry.readPhysicsNodeFromInputCapsule(PhysicsCollisionGeometry.java:126)

   at com.jmex.physics.util.binarymodules.BinaryPhysicsBoxModule.load(BinaryPhysicsBoxModule.java:50)

   at com.jme.util.export.binary.BinaryClassLoader.fromName(BinaryClassLoader.java:125)

   at com.jme.util.export.xml.DOMInputCapsule.readSavableFromCurrentElem(DOMInputCapsule.java:981)

   at com.jme.util.export.xml.DOMInputCapsule.readSavableArrayList(DOMInputCapsule.java:1128)

   … 12 more

Where gProject0.samples.PhysicExportTest is my file. Here is a result of exporting using XMLExporter http://wklej.org/id/144354/ (i pasted a piece of it in first post). Thanks :slight_smile: