views:

146

answers:

2

I'm currently playing with the JME-Jbullet physics engine, and having issues with my terrain.

I have 2 flat boxes, one for the floor, and one to act as a ramp. The issue is as follows:

With the following code:

Box slope = new Box("Slope", new Vector3f(0, -1, 0), 10f, 0f, 15f);
PhysicsNode pSlope = new PhysicsNode(slope, CollisionShape.ShapeTypes.MESH);
pSlope.setMass(0);
pSlope.getLocalRotation().fromAngleNormalAxis( 0.5f, new Vector3f( 0, 0, -1 ) );

Before the rotation is applied, the box acts as normal, if another object is dropped on top, then they collide correctly. After the rotation however, the box is rotated, but its "Physics" doesn't change, so when an object is dropped ontop of what appears to be the ramp, it is acting as though the rotation never happened.

Is there some way to update the ramp so that when an object is dropped on to it, it slides down?

Thanks.

+1  A: 

Hi, are you remembering to update the physics world in your update method?

public void update(float tpf) {
    super.update(tpf);
    pSpace.update(tpf);
}

where pSpace comes from PhysicsSpace pSpace=PhysicsSpace.getPhysicsSpace();

Chris Dennett
A: 

The problem is in the collision shape. A mesh is an extremely expensive shape to calculate collisions for, and as far as I am aware of not working properly (yet) in JME. Replacing it by a box collision shape will solve your problem.

Timo