My investigation into whether JOODE was usable for game development through jME has brought some startling results.
My test:
package test;
import jmetest.*;
import jmetest.input.controls.*;
import com.jme.bounding.*;
import com.jme.image.*;
import com.jme.math.*;
import com.jme.scene.shape.*;
import com.jme.scene.state.*;
import com.jme.system.*;
import com.jme.util.*;
import com.jmex.game.*;
import com.jmex.game.state.*;
import com.jmex.physics.*;
public class StressPhysics {
public static void main(String[] args) throws Exception {
StandardGame game = new StandardGame("Stress Physics");
game.getSettings().setVerticalSync(false); // We want to see what FPS we're running at
game.start();
// Move the camera
game.getCamera().setLocation(new Vector3f(0.0f, 50.0f, -100.0f));
game.getCamera().lookAt(new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.0f, 1.0f, 0.0f));
// Create a DebugGameState to give us the toys we want
DebugGameState debug = new DebugGameState();
debug.setActive(true);
GameStateManager.getInstance().attachChild(debug);
// Create our GameState
PhysicsGameState physics = new PhysicsGameState("PhysicsState");
GameStateManager.getInstance().attachChild(physics);
// Create the floor
Box visualFloor = new Box("Floor", new Vector3f(), 100.0f, 0.5f, 100.0f);
visualFloor.getLocalTranslation().set(0.0f, -25.0f, 0.0f);
TextureState wallTextureState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
wallTextureState.setTexture(TextureManager.loadTexture(TestChooser.class.getResource("data/texture/wall.jpg"), Texture.MM_LINEAR, Texture.FM_LINEAR));
visualFloor.setRenderState(wallTextureState);
// Create the physics for the floor
StaticPhysicsNode floor = physics.getPhysicsSpace().createStaticNode();
floor.attachChild(visualFloor);
floor.generatePhysicsGeometry();
physics.getRootNode().attachChild(floor);
// Create falling boxes
TextureState ts = game.getDisplay().getRenderer().createTextureState();
Texture t = TextureManager.loadTexture(TestSwingControlEditor.class.getClassLoader().getResource("jmetest/data/images/Monkey.jpg"), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR);
t.setWrap(Texture.WM_WRAP_S_WRAP_T);
ts.setTexture(t);
int boxes = 100;
for (int i = 0; i < boxes; i++) {
Box box = new Box("Box" + i, new Vector3f(), 5.0f, 5.0f, 5.0f);
box.setModelBound(new BoundingBox());
box.updateModelBound();
box.setRenderState(ts);
DynamicPhysicsNode node = physics.getPhysicsSpace().createDynamicNode();
node.attachChild(box);
node.generatePhysicsGeometry();
node.setLocalTranslation((float)(Math.random() * 100.0f) - 50.0f, (float)(5.0f + (Math.random() * 50.0f)), (float)(Math.random() * 100.0f) - 50.0f);
physics.getRootNode().attachChild(node);
}
// Update the rootNode
physics.getRootNode().updateRenderState();
// Wait to activate the scene until we're all done
physics.setActive(true);
}
}
OdeJava ran that test pretty well staying consistently above 300fps. However, when I switched out for JOODE it tried to start, showed me the one frame or two frames and essentially gave me the middle finger and died:
java.lang.ArrayIndexOutOfBoundsException: 50
at net.java.dev.joode.collision.collider.BoxBoxCollider.collideBoxes(BoxBoxCollider.java:443)
at net.java.dev.joode.collision.collider.BoxBoxCollider.collide(BoxBoxCollider.java:38)
at net.java.dev.joode.collision.collider.Colliders.dCollide(Colliders.java:132)
at net.java.dev.joode.collision.collider.GeomTransformCollider.collide(GeomTransformCollider.java:56)
at net.java.dev.joode.collision.collider.Colliders.dCollide(Colliders.java:120)
at net.java.dev.joode.collision.collider.GeomTransformCollider.collide(GeomTransformCollider.java:56)
at net.java.dev.joode.collision.collider.Colliders.dCollide(Colliders.java:132)
at com.jmex.physics.impl.joode.JoodePhysicsSpace.call(JoodePhysicsSpace.java:590)
at net.java.dev.joode.space.Space.collideAABBs(Space.java:309)
at net.java.dev.joode.space.octtree.OctTreeNode.collide(OctTreeNode.java:241)
at net.java.dev.joode.space.OctTreeSpace.collide(OctTreeSpace.java:69)
at com.jmex.physics.impl.joode.JoodePhysicsSpace.computeTimeStep(JoodePhysicsSpace.java:598)
at com.jmex.physics.impl.joode.JoodePhysicsSpace.update(JoodePhysicsSpace.java:517)
at test.PhysicsGameState.update(PhysicsGameState.java:21)
at com.jmex.game.state.GameStateNode.update(GameStateNode.java:71)
at com.jmex.game.StandardGame.update(StandardGame.java:268)
at com.jmex.game.StandardGame.run(StandardGame.java:169)
at java.lang.Thread.run(Thread.java:619)
So, if JOODE can't handle a simple test like this I think it's pretty obvious it's not going to work for a game. However, if I bump it down to 10 boxes instead of 100 it goes ahead and runs just to let me know that it can still do the basics. ;)