Starting with Hello World

sosssego
Posts: 6
Joined: Sun Nov 29, 2009 2:38 am

Starting with Hello World

Post by sosssego »

Hi!

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()));
			}
		}
	}
Ok, i know, refresh the position of the 2 box and print it on the screen.
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()));
prints the position of the bigger static box? When the position is of the smaller box?

There are another way to get it? There are a Simple way? There are a better (Performance) way?

Thanks in advance.
sosssego
Posts: 6
Joined: Sun Nov 29, 2009 2:38 am

Re: Starting with Hello World

Post by sosssego »

well i found a realy better Hello World at http://bulletphysics.org/mediawiki-1.5. ... ello_World

I can understand this one very well.

cya