Page 1 of 1
DebugDraw - no cylinders drawn for raycast vehicle's wheels?
Posted: Tue Nov 18, 2014 11:34 am
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
Re: DebugDraw - no cylinders drawn for raycast vehicle's whe
Posted: Tue Nov 18, 2014 12:20 pm
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(...)
What decides that which DebugDraw functions will be called?
Posted: Tue Nov 18, 2014 1:28 pm
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 ?
Re: DebugDraw - no cylinders drawn for raycast vehicle's whe
Posted: Tue Nov 18, 2014 4:20 pm
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)