I have a cube at the origin which I can push about with applyCentralForce.
I am trying to confine the cube within the screen area. I am successfully getting the size of the screen in world space thru the frustum, and am adding planes at each side to stop the cube straying out.
Now the plane on the north edge works. However, adding the plane on the south side causes the cubes to be rammed into the north side and jitter around madly.
Heres my code:
[java] Plane planeNorth = new Plane( new Vector3f( 0.0f, -1.0f, 0.0f ), -20.0f );
PlaneCollisionShape north = new PlaneCollisionShape( planeNorth );
m_rigidBodyNorth = new RigidBodyControl( north, 0.0f );
m_rigidBodyNorth.setCollisionGroup( 2 );
m_rigidBodyNorth.setCollideWithGroups( 1 );
Plane planeSouth = new Plane( new Vector3f( 0.0f, 1.0f, 0.0f ), 20.0f );
PlaneCollisionShape south = new PlaneCollisionShape( planeSouth );
m_rigidBodySouth = new RigidBodyControl( south, 0.0f );
m_rigidBodySouth.setCollisionGroup( 2 );
m_rigidBodySouth.setCollideWithGroups( 1 );
Likewise, the west plane works but not the east plane.
If I’m reading that right, you’ve put both planes in the same place. The second parameter of the plane will be the distance from origin along the normal. Since the normals are flipped, using a positive distance for the south plane puts the planes in the same place.
-1 * -20 = 20
1 * 20 = 20
My first use of Plane type… guess that makes sense.