got some problems with the physics/collision in my terrain from a golf simulation project.
I made an HeightfieldCollisionShape from Heightmap data of the golf terrain.
After that I made an SphereCollisionShape that represents the golf ball.
Collision works, but I think there are holes in the CollisionShape, so that the ball is not colliding at different positions.
The smaller I set the radius of the golf ball CollisionShape, the more often
the ball is falling through the terrain and does not collide with it.
It also depends on the angle I shot the ball how often it is not colliding.
So my question:
How can I debug that? What could be the Problem? Why isn’t the HeightfieldCollisionShape solid?
Is there a possibility to make the HeightfieldCollisionShape visible? Like a grid or something?
Here are the appropriate code extracts for creating terrain collision and golf ball collision:
terrain = new TerrainQuad(“Golfcourse”, 65, 1025, hmap.getHeightMap());
List cameras = new ArrayList();
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
terrain.setLocalTranslation(0f, 0f, 0f);
terrainCollisionShape = new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale());
terrain_phy = new RigidBodyControl(terrainCollisionShape, 0f);
Golf Ball Collision:
SphereCollisionShape BallCollisionShape = new SphereCollisionShape(0.4f);
Sphere sphere = new Sphere(32, 32, 0.2f, true, false);
Geometry ball_geo = new Geometry(“cannon ball”, sphere);
ball_geo.setMaterial(new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”));
/** Position the golf ball and activate shadows /
/* Make the ball physcial with a mass > 0.0f /
ball_phy = new RigidBodyControl(BallCollisionShape);
/* Add physical ball to physics space. /
/* Accelerate the physcial ball to shoot it. */
curBallGeo = ball_geo;
Would be very thankful if someboy could help me with that
Nobody got some Tips or work arounds?
You’ve probably solved it, but you might want to have a look at this anyways:
I also saw @normen mentioning problems with jBullet and ccd, so native bullet could be benefitial.