[SOLVED]Terrain collision vs geometry dynamicmesh collision causes a… Black hole?

Hey forum, been having fun with this jMonkey business, I’ve been messing around with physics now, obviously my player model works fine with the terrain, however when I spawn a cube, as soon as it collides with the terrain, it does some weird shiz, thanks in advance for your insight, here’s a video:


and some code:

[java]public void Initialize_Model() {

b = new Box(location.clone().addLocal(direction.clone().multLocal(10f)),1,1,1);

geometry = new Geometry(“Box”,b);

Material mat = new Material(instance.am,“Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Red);


CollisionShape cs = CollisionShapeFactory.createDynamicMeshShape(geometry);

rbc = new RigidBodyControl(cs,10);





PS: I’ve tried searching but couldn’t find the problem

PPS: The terrain:


terrain = new TerrainQuad(“my terrain”, patchSize,1025,heightmap.getHeightMap());




CollisionShape cs = CollisionShapeFactory.createMeshShape((Node)terrain);

RigidBodyControl landscape = new RigidBodyControl(cs,0);





How do you create the collision shape for the terrain? How does the physics debug view look? (physicsSpace.enableDebug(assetManager))

Hey, I added terrain code as an edit (well the bit which I thought mattered anyways).

When I enabled debug, I can perfectly see the blue mesh around the cube

EDIT: However no mesh around the terrain.

Try not casting the terrain to a node.

Didn’t work unfortunately.

Here’s something though, when I give it a shot of force at the start (so it’s moving faster than usual) this is how it behaves, weird huh?


In the meantime, I’m going to continue looking around my code :slight_smile:

EDIT: Instead of terrain, I spawned a huge plane, it does the exact same thing with the cubes.

EDIT #2: This cube spawning stuff has been in a seperate class, I’ve spawned a cube with ridibody in the main class and it works 100%, I’m gonna try take it from here and if I find the answer I’ll tag as solved and explain incase anyone hits it.


problem was here:

[java]b = new Box(location.clone().addLocal(direction.clone().multLocal(10f)),1,1,1);[/java]

I thought you were meant to enter the location where you wanted your box to start on the first parameter, this was causing the problem. Instead I spawned the box with Vector3f.ZERO and later, with the geometry I setLocalTranslation to the position I wanted for the box.


[java]b = new Box(Vector3f.ZERO,1,1,1);

geometry = new Geometry("Box",b);


Yeah, you are pushing your center of mass out of the box this way.

Cool effect, though ^^

1 Like