Jme crashes when I add DynamicPhysicsObject to PhysicsWorld

Hi

I have been trying to run a simple physics example involving a box and a floor, but I can't get it to work. The program refuses to run unless I have commented out

 PhysicsWorld.getInstance().addObject(boxPhysics);

where boxPhysics is a DynamicPhysicsObject. The StaticPhysicsObject works fine.

Any ideas about what causes this or how to fix it?



The error message:


INFO: Child (Box) attached to this node (rootNode)
Jan 7, 2006 2:57:16 PM com.jmex.physics.PhysicsWorld addObject
INFO: Physics Object (Floor) has been added to the PhysicsWorld
Jan 7, 2006 2:57:16 PM com.jmex.physics.PhysicsWorld addObject
INFO: Physics Object (Box) has been added to the PhysicsWorld
java.lang.NoSuchMethodError: com.jme.math.Quaternion.set(Lcom/jme/math/Quaternion;)V
   at com.jmex.physics.PhysicsSynchronizer.update(PhysicsSynchronizer.java:86)
   at com.jme.scene.Spatial.updateWorldData(Unknown Source)
   at com.jme.scene.Spatial.updateGeometricState(Unknown Source)
   at com.jme.scene.Node.updateWorldData(Unknown Source)
   at com.jme.scene.Spatial.updateGeometricState(Unknown Source)
   at com.jme.app.SimpleGame.initGame(Unknown Source)
   at com.jme.app.BaseGame.start(Unknown Source)
   at TestSphere.main(TestSphere.java:90)
Jan 7, 2006 2:57:16 PM com.jme.app.SimpleGame cleanup
INFO: Cleaning up resources.
Jan 7, 2006 2:57:16 PM com.jme.app.BaseGame start
INFO: Application ending.
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGSEGV (0xb) at pc=0xb1783198, pid=8364, tid=2978839472
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode, sharing)
# Problematic frame:
# C  0xb1783198



The code, "borrowed" from someone else on this forum


import org.odejava.Odejava;

import com.jme.app.SimpleGame;
import com.jme.math.Vector3f;
import com.jme.scene.shape.Box;
import com.jmex.physics.DynamicPhysicsObject;
import com.jmex.physics.PhysicsObject;
import com.jmex.physics.PhysicsWorld;
import com.jmex.physics.StaticPhysicsObject;


public class TestSphere extends SimpleGame {
   Box boxGraphics;
   DynamicPhysicsObject boxPhysics;
   protected void simpleInitGame() {
      display.setTitle("Simple Test");

      // Set up the PhysicsWorld. It's got a couple of default
      // values, e.g. Earths gravity.
      Odejava.init();
      PhysicsWorld.create();

      // Here we tell the PhysicsWorld how many times per second we would like
      // to update it. It'll make the PhysicsWorlds internal timer govern the
      // frequency of update calls, thus obtaining frame rate independance.
      // We set it to 100 updates per second - the default is no restriction.
     // PhysicsWorld.getInstance().setUpdateRate(100);

      // Here we tell the PhysicsWorld how much should change with each
      // update. A bigger value leads to a faster animation. A step size
      // of 2/UPS (updates/sec) seem to give a rather nice simulation/result.
//      PhysicsWorld.getInstance().setStepSize(2f/100f);

      // Creates the box that makes out the floor (graphics only).
      Box floorGraphics = new Box("Floor", new Vector3f(), 50, 1, 50);

      // We move it down 5 units, and away from the camera 10 units.
      floorGraphics.setLocalTranslation(new Vector3f(0, -5, 10));

      // Add the graphical representations to the rootNode. You could also get
      // references to them by calling PhysicsObject.getSpatial().
      rootNode.attachChild(floorGraphics);

      // In order to add it to the PhysicsWorld we need to create a
      // PhysicsObject from it. Note that we don't pass a mass in the constructor.
      // This is because it's static.
      PhysicsObject floorPhysics = new StaticPhysicsObject(floorGraphics);

      // Creates the box that falls down on the floor.
      boxGraphics = new Box("Box", new Vector3f(), 1f, 1f, 1f);

      // We move it 10 units up, and 10 units away from the camera.
      boxGraphics.setLocalTranslation(new Vector3f(-10, 10, 10));
     
      // Attach the graphical representation to the scene.
      rootNode.attachChild(boxGraphics);

      // Create a dynamic physics object from it. Because it is dynamic, we
      // need to provide it with a mass.
      boxPhysics = new DynamicPhysicsObject(boxGraphics, 1f);
     
     

      com.jme.math.Quaternion q = new com.jme.math.Quaternion();
      q.set(1,1,1,1);
      PhysicsWorld.getInstance().addObject(floorPhysics);
     // PhysicsWorld.getInstance().addObject(boxPhysics);
   }


   protected void cleanup() {
      super.cleanup();
      PhysicsWorld.getInstance().cleanup();
   }
  
   /**
    * Gets called every frame.
    */
   protected void simpleUpdate() {
      boxPhysics.resetForces();
      boxPhysics.setTorque(new Vector3f(0, 20f, 0));
      System.err.println(boxPhysics.getAngularVelocity());

      PhysicsWorld.getInstance().update(tpf);
   }

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



It looks as though there is a problem with the version of jME-Physics to jME you are running.  What version of each are you running?



Your problem will resolve itself if you update to the version of both in CVS.



darkfrog

I am running jme from cvs and jme-physics v0.4( I think) from http://www.logicalnetwork.com/jme-physics-src.zip . Still trying to check out jme-physics from cvs.sourceforge.net.

Is



cvs -d :pserver:[username]@cvs.sourceforge.net:/cvsroot/jme-physics:/cvs login



and



cvs -d :pserver:[username]@cvs.sourceforge.net:/cvsroot/jme-physics:/cvs checkout -P jme-physics





correct?

See this page for correct commands:

https://sourceforge.net/cvs/?group_id=132642

And, yes,

haakon said:

I am running jme from cvs and jme-physics v0.4( I think)

that'd be the problem!

I need to update that source code. :o



darkfrog

Thanks guys



After several hours of doing battle with the sourceforge cvs server I finally managed to get the sources, and now my box is falling towards the floor as it should.