CollisionShapes for scenes created with TerraMonkey

I’m implementing the Terrain interface - that has already the required getHeightMap() method - but not extending the TerrainQuad class. The factory should be modified to catch all Terrain implementations, I guess.

Well, the factory is only for noobs and for recursing through a scenegraph to make compound collision shapes :wink: Just using the heightfieldshape should be fine, again, what doesnt work?

I’m trying to debug it, to find out what the difference is between TerrainQuad’s heightmap array and my one. But I seem to get lost. :frowning:



[java]

float[] heightMap = this.terrain.getHeightMap();

CollisionShape shape = new HeightfieldCollisionShape(heightMap, this.terrain.getLocalScale());

this.terrain.addControl(new RigidBodyControl(shape, 0));

this.bulletAppState.getPhysicsSpace().addAll(this.terrain);

[/java]



If terrain is a TerrainQuad, it’s working fine, but when my FractalTerrain instance the camera just falls below ground towards -infinity.



*****

Meanwhile doing some new modifications it turns out that I must not add RigidBodyControl to the geometry that is the concrete terrain, but the FractalTerrain instance itself (Just like TerrainQuad includes Patches as visible object, I create some geometry as well.). This way it starts to work… :slight_smile: Still getting some strange effects though, but I guess that I might have miscalculated some positions.

1 Like