Hello everyone,
I have successfully installed bullet and compiled the helloworld example. Now what? How do I interface bullet with another 3D world? There doesn't seem to be any examples of anyone doing this. How do I get bullet to respond to the 3D world I have and move the objects in it.
Thanks for any help,
Warped
Help getting started with bullet in my application
-
- Posts: 2
- Joined: Mon Jan 31, 2011 6:04 am
-
- Posts: 77
- Joined: Thu Nov 26, 2009 6:32 pm
Re: Help getting started with bullet in my application
Create the graphics and the physics objects separately. Then while drawing the graphics objects, just get the motion state transform from physics and push it in to the graphics object. Thats it
For example: This is to create a simple cube of side 1.0
Physics object creation:
Graphics object display:
To get Motion state transform:

For example: This is to create a simple cube of side 1.0
Physics object creation:
Code: Select all
btRigidBody* addPhysicsBox( btVector3 &boxHalfExtends, btVector3 &position, btVector3 &inertia, btScalar mass, btScalar restitution, bool collision ){
btTransform trans;
trans.setIdentity();
trans.setOrigin( position );
btCollisionShape *geom = new btBoxShape ( boxHalfExtends );
geom->calculateLocalInertia( mass, inertia );
btDefaultMotionState* motionstate = new btDefaultMotionState( trans );
btRigidBody* body = new btRigidBody( mass, motionstate, geom, inertia );
m_world->addRigidBody( body );
if( collision )
m_collisionShapes.push_back(geom);
return body;
}
btRigidBody* boxActor;
boxActor = addPhysicsBox(btVector3(0.5,0.5,0.5),btVector3(0.0,5.0,0.0),
btVector3(0.0,0.0,0.0),1.0,0.2,true);
Code: Select all
void renderCube(float m_Side, btTransform &boxTransform)
{
GLfloat tempForm[16];
boxTransform.getOpenGLMatrix(tempForm);
glPushMatrix();
glMultMatrixf(tempForm);
glutSolidCube(m_Side);
glPopMatrix();
}
renderCube(1.0, boxActor->getWorldTransform());
Code: Select all
void getBulletTransform(btRigidBody* rigidBody)
{
btMotionState* shapeMotionTransform;
shapeMotionTransform = rigidBody->getMotionState();
float openGLTransform[16];
btTransform worldTransform;
shapeMotionTransform->getWorldTransform(worldTransform);
worldTransform.getOpenGLMatrix(openGLTransform);
//Return the motion state opengl transform however you want
}
-
- Posts: 2
- Joined: Mon Jan 31, 2011 6:04 am
Re: Help getting started with bullet in my application
Thanks winspear! I should be able to figure it out from here. If I run into anymore problems I will let you know. I can't believe there wasn't already several posts asking how to get started.
Anyway, thanks again,
Warped
Anyway, thanks again,
Warped