void BasicDemo::renderme() { PhysicalCalculator* pc= &(cdn->getPhysicalCalculatorInstance()); if(!pc) return; btScalar m[16]; int i; btVector3 min,max,wheelColor(1,0,0); m_dynamicsWorld->getBroadphase()->getBroadphaseAabb(min,max); //This is very dirty but I don't know how to //do otherwise. Robot *_robot=Robot::getRobot(); if(_robot != NULL) { //fprintf(stderr, "il y a %d roue\n",_robot->getNumWheels()); for(i=0; i<_robot->getNumWheels();i++) { // this step makes the wheel visible. // We don't want to use the pc in test3dCoordinator. // The work need to be done in the class PhysicalCalculator. _robot->updateWheelTransform(i, true); _robot->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m); m_shapeDrawer->drawOpenGL(m, m_wheelShape, wheelColor,false,min,max); } } DemoApplication::renderme(); }
void btRaycastVehicle::debugDraw(btIDebugDraw* debugDrawer) { for (int v=0; v<this->getNumWheels(); v++) { btVector3 wheelColor(0,1,1); if (getWheelInfo(v).m_raycastInfo.m_isInContact) { wheelColor.setValue(0,0,1); } else { wheelColor.setValue(1,0,1); } btVector3 wheelPosWS = getWheelInfo(v).m_worldTransform.getOrigin(); btVector3 axle = btVector3( getWheelInfo(v).m_worldTransform.getBasis()[0][getRightAxis()], getWheelInfo(v).m_worldTransform.getBasis()[1][getRightAxis()], getWheelInfo(v).m_worldTransform.getBasis()[2][getRightAxis()]); //debug wheels (cylinders) debugDrawer->drawLine(wheelPosWS,wheelPosWS+axle,wheelColor); debugDrawer->drawLine(wheelPosWS,getWheelInfo(v).m_raycastInfo.m_contactPointWS,wheelColor); } }
//to be implemented by the demo 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(); }
void Vehicle::renderme(){ btScalar m[16]; int i; btVector3 wheelColor(1,0,0); btVector3 worldBoundsMin,worldBoundsMax; //cPhysics::Get().GetBulletWorld()->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); glPushMatrix(); cVec3 lTranslation = cPhysics::Get().Bullet2Local(m_vehicle->getWheelInfo(i).m_worldTransform.getOrigin()); cMatrix lTransMatrix, lRotMatrix; lTransMatrix.LoadTranslation(lTranslation); btQuaternion btq = m_vehicle->getWheelInfo(i).m_worldTransform.getRotation(); cVec3 lqAxis = cPhysics::Get().Bullet2Local(btq.getAxis()); lRotMatrix.LoadRotation(lqAxis, btq.getAngle()); cGraphicManager::Get().SetWorldMatrix(lRotMatrix * lTransMatrix); debugWheels(m,m_wheelShape,wheelColor,1, btVector3(1.0,1.0,1.0) /*worldBoundsMin*/, btVector3(1.0,1.0,1.0) /*worldBoundsMax*/); lTransMatrix.LoadIdentity(); cGraphicManager::Get().SetWorldMatrix(lTransMatrix); glPopMatrix(); } }
void BasicDemo::renderme() { PhysicalCalculator* pc= &(cdn->getPhysicalCalculatorInstance()); if(!pc) return; btScalar m[16]; int i; btVector3 min,max,wheelColor(1,0,0); pc->getScene()->getBroadphase()->getBroadphaseAabb(min,max); /* This is very dirty but I don't know how to do otherwise. */ Robot *_robot=cdn->getRobot(Coordinator::MAIN_ROBOT1); for(i=0; i<_robot->getNumWheels();i++) { /* this step makes the wheel visible. We don't want to use the pc in test3dCoordinator. The work need to be done in the class PhysicalCalculator. */ _robot->updateWheelTransform(i, true); _robot->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m); m_shapeDrawer->drawOpenGL(m, m_wheelShape, wheelColor,false,min,max); } DemoApplication::renderme(); }
//to be implemented by the demo void ForkLiftDemo::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); } int lineWidth=250; int xStart = m_glutScreenWidth - lineWidth; int yStart = 20; if((getDebugMode() & btIDebugDraw::DBG_NoHelpText)==0) { setOrthographicProjection(); glDisable(GL_LIGHTING); glColor3f(0, 0, 0); char buf[124]; glRasterPos3f(xStart, yStart, 0); sprintf(buf,"SHIFT+Cursor Left/Right - rotate lift"); GLDebugDrawString(xStart,20,buf); yStart+=20; glRasterPos3f(xStart, yStart, 0); sprintf(buf,"SHIFT+Cursor UP/Down - move fork up/down"); yStart+=20; GLDebugDrawString(xStart,yStart,buf); glRasterPos3f(xStart, yStart, 0); sprintf(buf,"F5 - toggle camera mode"); yStart+=20; GLDebugDrawString(xStart,yStart,buf); glRasterPos3f(xStart, yStart, 0); sprintf(buf,"Click inside this window for keyboard focus"); yStart+=20; GLDebugDrawString(xStart,yStart,buf); resetPerspectiveProjection(); glEnable(GL_LIGHTING); } DemoApplication::renderme(); }
void RaycastCar::debugDraw(btIDebugDraw * debugDrawer) { for (int v = 0; v < getNumWheels(); v++) { btVector3 wheelColor(0.0f,1.0f,1.0f); if (getWheelInfo(v).m_raycastInfo.m_isInContact) { wheelColor.setValue(0.0f,0.0f,1.0f); } else { wheelColor.setValue(1.0f,0.0f,1.0f); } btVector3 wheelPosWS = getWheelInfo(v).m_worldTransform.getOrigin(); btVector3 axle = btVector3( getWheelInfo(v).m_worldTransform.getBasis()[0][getRightAxis()], getWheelInfo(v).m_worldTransform.getBasis()[1][getRightAxis()], getWheelInfo(v).m_worldTransform.getBasis()[2][getRightAxis()]); debugDrawer->drawLine(wheelPosWS,wheelPosWS+axle,wheelColor); debugDrawer->drawLine(wheelPosWS,getWheelInfo(v).m_raycastInfo.m_contactPointWS,wheelColor); } }
//to be implemented by the demo void Hinge2Vehicle::renderScene() { m_guiHelper->syncPhysicsToGraphics(m_dynamicsWorld); #if 0 for (int i=0;i<m_vehicle->getNumWheels();i++) { //synchronize the wheels with the (interpolated) chassis worldtransform m_vehicle->updateWheelTransform(i,true); CommonRenderInterface* renderer = m_guiHelper->getRenderInterface(); if (renderer) { btTransform tr = m_vehicle->getWheelInfo(i).m_worldTransform; btVector3 pos=tr.getOrigin(); btQuaternion orn = tr.getRotation(); renderer->writeSingleInstanceTransformToCPU(pos,orn,m_wheelInstances[i]); } } #endif m_guiHelper->render(m_dynamicsWorld); btVector3 wheelColor(1,0,0); btVector3 worldBoundsMin,worldBoundsMax; getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax); #if 0 int lineWidth=400; int xStart = m_glutScreenWidth - lineWidth; int yStart = 20; if((getDebugMode() & btIDebugDraw::DBG_NoHelpText)==0) { setOrthographicProjection(); glDisable(GL_LIGHTING); glColor3f(0, 0, 0); char buf[124]; sprintf(buf,"SHIFT+Cursor Left/Right - rotate lift"); GLDebugDrawString(xStart,20,buf); yStart+=20; sprintf(buf,"SHIFT+Cursor UP/Down - fork up/down"); yStart+=20; GLDebugDrawString(xStart,yStart,buf); if (m_useDefaultCamera) { sprintf(buf,"F5 - camera mode (free)"); } else { sprintf(buf,"F5 - camera mode (follow)"); } yStart+=20; GLDebugDrawString(xStart,yStart,buf); yStart+=20; if (m_dynamicsWorld->getConstraintSolver()->getSolverType()==BT_MLCP_SOLVER) { sprintf(buf,"F6 - solver (direct MLCP)"); } else { sprintf(buf,"F6 - solver (sequential impulse)"); } GLDebugDrawString(xStart,yStart,buf); btDiscreteDynamicsWorld* world = (btDiscreteDynamicsWorld*) m_dynamicsWorld; if (world->getLatencyMotionStateInterpolation()) { sprintf(buf,"F7 - motionstate interpolation (on)"); } else { sprintf(buf,"F7 - motionstate interpolation (off)"); } yStart+=20; GLDebugDrawString(xStart,yStart,buf); sprintf(buf,"Click window for keyboard focus"); yStart+=20; GLDebugDrawString(xStart,yStart,buf); resetPerspectiveProjection(); glEnable(GL_LIGHTING); } #endif }
void btDiscreteDynamicsWorld::debugDrawWorld() { if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb)) { int i; //todo: iterate over awake simulation islands! for ( i=0;i<m_collisionObjects.size();i++) { btCollisionObject* colObj = m_collisionObjects[i]; if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawWireframe) { btVector3 color(btScalar(255.),btScalar(255.),btScalar(255.)); switch(colObj->getActivationState()) { case ACTIVE_TAG: color = btVector3(btScalar(255.),btScalar(255.),btScalar(255.)); break; case ISLAND_SLEEPING: color = btVector3(btScalar(0.),btScalar(255.),btScalar(0.));break; case WANTS_DEACTIVATION: color = btVector3(btScalar(0.),btScalar(255.),btScalar(255.));break; case DISABLE_DEACTIVATION: color = btVector3(btScalar(255.),btScalar(0.),btScalar(0.));break; case DISABLE_SIMULATION: color = btVector3(btScalar(255.),btScalar(255.),btScalar(0.));break; default: { color = btVector3(btScalar(255.),btScalar(0.),btScalar(0.)); } }; debugDrawObject(colObj->getWorldTransform(),colObj->getCollisionShape(),color); } if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb)) { btPoint3 minAabb,maxAabb; btVector3 colorvec(1,0,0); colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb); m_debugDrawer->drawAabb(minAabb,maxAabb,colorvec); } } for ( i=0;i<this->m_vehicles.size();i++) { for (int v=0;v<m_vehicles[i]->getNumWheels();v++) { btVector3 wheelColor(0,255,255); if (m_vehicles[i]->getWheelInfo(v).m_raycastInfo.m_isInContact) { wheelColor.setValue(0,0,255); } else { wheelColor.setValue(255,0,255); } btVector3 wheelPosWS = m_vehicles[i]->getWheelInfo(v).m_worldTransform.getOrigin(); btVector3 axle = btVector3( m_vehicles[i]->getWheelInfo(v).m_worldTransform.getBasis()[0][m_vehicles[i]->getRightAxis()], m_vehicles[i]->getWheelInfo(v).m_worldTransform.getBasis()[1][m_vehicles[i]->getRightAxis()], m_vehicles[i]->getWheelInfo(v).m_worldTransform.getBasis()[2][m_vehicles[i]->getRightAxis()]); //m_vehicles[i]->getWheelInfo(v).m_raycastInfo.m_wheelAxleWS //debug wheels (cylinders) m_debugDrawer->drawLine(wheelPosWS,wheelPosWS+axle,wheelColor); m_debugDrawer->drawLine(wheelPosWS,m_vehicles[i]->getWheelInfo(v).m_raycastInfo.m_contactPointWS,wheelColor); } } } }