Error using createMeshShape on scene containing terrainQuad

So i used terramonkey to make a basic scene containing nothing but a flat terrainQuad.

When I try to make a mesh exact control for it to add to the PhysicsSpace it crashes. Here is the stack trace:

Jul 22, 2011 9:00:02 PM handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]


at java.nio.Buffer.checkIndex(

at java.nio.DirectIntBufferU.get(

at com.jme3.scene.mesh.IndexIntBuffer.get(

at com.jme3.bullet.util.Converter.convert(

at com.jme3.bullet.collision.shapes.MeshCollisionShape.createCollisionMesh(

at com.jme3.bullet.collision.shapes.MeshCollisionShape.(

at com.jme3.bullet.util.CollisionShapeFactory.createSingleMeshShape(

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(

at com.jme3.bullet.util.CollisionShapeFactory.createMeshCompoundShape(

at com.jme3.bullet.util.CollisionShapeFactory.createMeshShape(

at mygame.BattleField.(

at mygame.Main.initMap(

at mygame.Main.simpleInitApp(


at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(



Any idea why this is happening? Am I supposed to treat terrainQuads differently with respect to physics?

look at TerrainTestCollision

First I was looking at the TestTerrainCollision that comes in JMP which used PhysicsNodes, and I knew that wasn’t right.

So I took a look at the svn and found the newer version.

It uses:


terrain = new TerrainQuad(“terrain”, 65, 513, heightmap.getHeightMap());

TerrainLodControl control = new TerrainLodControl(terrain, getCamera());



terrain.setLocalScale(new Vector3f(2, 2, 2));

terrain.setLocked(false); // unlock it so we can edit the height



  • Create PhysicsRigidBodyControl for collision


    terrain.addControl(new RigidBodyControl(0));



    The only way this differs from my code is that it is creating the TerrainQuad in code. I am trying to load it from a scene:


    Node terrainScene = (Node) assetManager.loadModel(“Scenes/BattleFields/TerrainTest.j3o”);

    TerrainQuad tQ = (TerrainQuad) terrainScene.getChild(0);

    tQ.addControl(new RigidBodyControl(0));



    This was not the only way I tried. I tried adding the control while leaving the scene as a Spatial and casting it to a Node. I tried it on the object itself and on its children. I’m at a loss. Am I misunderstanding something about how scenes are structured? I assumed I could import them and treat them like any other Node or Spatial.

    Thanks for the help!

Ok so I’ve found that this only happens when I change its location. I had dropped it down to (0,-20,0) in the scene editor and this was causing it. When I made it (0,0,0) it ran fine.

It also crashes if I try using setPhysicsLocation(0,-20,0) after everything has been added to the rootNodes and PhysicsSpace. So I guess the new question is, why does moving the terrain cause this error or how am I supposed to move it instead?

What error are you getting when you use setPhysicsLocation()?

TestCollisionGroups has examples of setPhysicsLocation.

I’m not on a machine with jme right now, and it might be a few days for me to get to one so I can look at this issue. Hang tight and bare with my absence :slight_smile:

This is very strange, but when I went to recreate the error it worked fine. With both setPhysicsLocation and the scene editor setLocalTranslation. Thanks for the response lol. If I run into it again I’ll post here.