Matrix loading problems with jbullet and lwjgl
Posted
by
Quintin
on Game Development
See other posts from Game Development
or by Quintin
Published on 2012-06-14T22:53:25Z
Indexed on
2012/06/15
15:28 UTC
Read the original article
Hit count: 211
The following code does not load the matrix correctly from jbullet.
//box is a RigidBody
Transform trans = new Transform();
trans = box.getMotionState().getWorldTransform(trans);
float[] matrix = new float[16];
trans.getOpenGLMatrix(matrix);
// pass that matrix to OpenGL and render the cube
FloatBuffer buffer = ByteBuffer.allocateDirect(4*16).asFloatBuffer().put(matrix);
buffer.rewind();
glPushMatrix();
glMultMatrix(buffer);
glBegin(GL_POINTS);
glVertex3f(0,0,0);
glEnd();
glPopMatrix();
the jbullet is configured as so:
CollisionConfiguration = new DefaultCollisionConfiguration();
dispatcher = new CollisionDispatcher(collisionConfiguration);
Vector3f worldAabbMin = new Vector3f(-10000,-10000,-10000);
Vector3f worldAabbMax = new Vector3f(10000,10000,10000);
AxisSweep3 overlappingPairCache = new AxisSweep3(worldAabbMin, worldAabbMax);
SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();
dynamicWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);
dynamicWorld.setGravity(new Vector3f(0,-10,0));
dynamicWorld.getDispatchInfo().allowedCcdPenetration = 0f;
CollisionShape groundShape = new BoxShape(new Vector3f(1000.f, 50.f, 1000.f));
Transform groundTransform = new Transform();
groundTransform.setIdentity();
groundTransform.origin.set(new Vector3f(0.f, -60.f, 0.f));
float mass = 0f;
Vector3f localInertia = new Vector3f(0, 0, 0);
DefaultMotionState myMotionState = new DefaultMotionState(groundTransform);
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, groundShape, localInertia);
RigidBody body = new RigidBody(rbInfo);
dynamicWorld.addRigidBody(body);
dynamicWorld.clearForces();
Nothing is rendered on the screen. What am I doing wrong?
© Game Development or respective owner