myWallJSON
myWallJSON

Reputation: 9502

How to set color on collision object in Bullet?

So there I have made a nice debug drawer... And get all world objects drown... Now I want some to be drawn with special color (eg bullets player, enemies mesh representations). So how to spesify mesh color so to get it drawn on dynamicsWorld->getDebugDrawer()->debugDrawWorld(); correctly? I cant find coloring options in btCollisionShape nor in btCollisionObject API=( So how to set color on it?

Upvotes: 1

Views: 920

Answers (2)

Andrei Despinoiu
Andrei Despinoiu

Reputation: 510

Better late than never.

const glm::mat4 transform = glm::mat4(1.0f); // Identiy
btTransform btTransf;
btTransf.setIdentity();
btTransf.setFromOpenGLMatrix(glm::value_ptr(transform));
btRigidBody* rb = new btRigidBody(0.0f, new btDefaultMotionState(btTransf), new btSphereShape(0.5f));
rb->setCustomDebugColor(btVector3(1.0f, 0.0f, 0.0f)); // Red collision

Upvotes: 1

Jeremy Sandell
Jeremy Sandell

Reputation: 435

If I recall correctly, you should be able to control the color when overriding btIDebugDraw::drawLine and btIDebugDraw::drawContactPoint, as the last parameter to both is a const btVector3& representing red, green, and blue - from the class's comments, in a range of [0 .. 1].

Upvotes: 1

Related Questions