I am trying to start with bullet and opengl.
My objective is to create a Car Game.
I try to start from the begin. The Hello World Demo.
But i have some doubts.
How can I get the position of the objects on the the scene.
The Hello World demo uses a way to put the position on the screen with prinf that i cant understand.
What this code do?
Code: Select all
for (i=0;i<100;i++)
{
dynamicsWorld->stepSimulation(1.f/60.f,10);
//print positions of all objects
for (int j=dynamicsWorld->getNumCollisionObjects()-1; j>=0 ;j--)
{
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[j];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
btTransform trans;
body->getMotionState()->getWorldTransform(trans);
printf("world pos = %f,%f,%f\n",float(trans.getOrigin().getX()),float(trans.getOrigin().getY()),float(trans.getOrigin().getZ()));
}
}
}
But How can i know theses positions to send the information to OpenGL?
When the
Code: Select all
printf("world pos = %f,%f,%f\n",float(trans.getOrigin().getX()),float(trans.getOrigin().getY()),float(trans.getOrigin().getZ()));
There are another way to get it? There are a Simple way? There are a better (Performance) way?
Thanks in advance.