DebugDraw - no cylinders drawn for raycast vehicle's wheels?

Post Reply
User avatar
manmohan29
Posts: 15
Joined: Wed Aug 20, 2014 9:26 pm
Location: Chandigarh, India

DebugDraw - no cylinders drawn for raycast vehicle's wheels?

Post by manmohan29 »

I have proper drawLine() function declared in my DebugDrawer class implementation.

Now I have a raycast vehicle in my physics world. I can see the bounding box for vehicle's chassis i.e. a btBoxShape.
Wheels of the vehicle are having collision shape of btCylinderShapeX

Why there are no cylinders drawn for the 4 wheels of a raycasted vehicle ?
Isn't drawCylinder called automatically for the Cylindrical shapes ?

I am using BulletPhysics v2.82 r2704
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: DebugDraw - no cylinders drawn for raycast vehicle's whe

Post by Flix »

Because that isn't something Bullet does by default.
If you look at the Bullet VehicleDemo, in VehicleDemo::renderme():

Code: Select all

void VehicleDemo::renderme()
{	
	updateCamera();
	btScalar m[16];int i;

	btVector3 wheelColor(1,0,0);
	btVector3	worldBoundsMin,worldBoundsMax;      getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax);
       for (i=0;i<m_vehicle->getNumWheels();i++)
	{
		//synchronize the wheels with the (interpolated) chassis worldtransform
		m_vehicle->updateWheelTransform(i,true);
		//draw wheels (cylinders)
		m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m);         m_shapeDrawer->drawOpenGL(m,m_wheelShape,wheelColor,getDebugMode(),worldBoundsMin,worldBoundsMax);
	}
	DemoApplication::renderme();
}
the rendering is done inside: m_shapeDrawer->drawOpenGL(...)
User avatar
manmohan29
Posts: 15
Joined: Wed Aug 20, 2014 9:26 pm
Location: Chandigarh, India

What decides that which DebugDraw functions will be called?

Post by manmohan29 »

I've seen code for VehicleDemo.

btIDebugDraw.h has functions like :

Code: Select all

drawCylinder
drawCone
drawBox
drawAabb
... etc.
drawBox, drawAabb are being called as I can see debug drawing of box shapes.
What decides that which functions will be called automatically and which not ?
User avatar
manmohan29
Posts: 15
Joined: Wed Aug 20, 2014 9:26 pm
Location: Chandigarh, India

Re: DebugDraw - no cylinders drawn for raycast vehicle's whe

Post by manmohan29 »

Okay, I've figured out a bit myself.
I will be using this function for debug drawing the wheels of my raycast vehicle.

Code: Select all

btIDebugDraw::drawCylinder ( btScalar  radius,
		btScalar  halfHeight,
		int  upAxis,
		const btTransform &transform,
		const btVector3 &color 
	) 	
I have wheel's radius from my constructor
wheelRadius = 0.5f; (radius)

wheelWidth = 0.2f; (can I use this value divided by "2" for halfHeight ??)

upAxis = ??? (where do I get this from for individual wheel ??)


wTrans = vehicle->getWheelTransformWS(i); (transform)

btVector3(1.0f, 0.0f, 0.0f); (color)
Post Reply