Coloring bullet objects

Naruto
Posts: 13
Joined: Sun Mar 13, 2011 2:11 am

Coloring bullet objects

Post by Naruto »

Hi,

I am new to bullet. I am using bullet 2.77 and openGL (for rendering). Can anybody tell me how can I paint the objects created using bullet? Is there any function in bullet to do so? Or I can I use openGL and how to use it?
e.g.
// Land Information
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
m_collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-50,0));
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
m_dynamicsWorld->addRigidBody(body);

I know openGL functions like glColor3f(..) etc but I don't know how to apply them to bullet objects.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Coloring bullet objects

Post by Flix »

Well, first of all you should write your own openGL system, since the one used for the Bullet Demos does not support it.

As a starting point, you could add your own "drawing structure" (such as a display list) inside the btCollisionShape "user pointer".

This way you can cycle through the bodies in the world, get their collision shape and draw it.

You can use the btCollisionObject user pointer to store other information like color, texture and so on.

Hope you get the general idea.

More advanced systems usually either derive from btRigidBody (which derives from btCollisionObject), or just store their "big object class" inside its user pointer.
Naruto
Posts: 13
Joined: Sun Mar 13, 2011 2:11 am

Re: Coloring bullet objects

Post by Naruto »

Thanx a lot for the reply.