首先要感谢《OpenGL游戏编程》中的Chess游戏的部分代码。
下面是Bullet物理引擎初试话部分。其中包括一个代表地面的盒子btBoxShape,以及一个球体放置在最中央,最后是我们的角色使用Bullet中的Kinematic类来控制
m_collisionConfiguration = new btDefaultCollisionConfiguration();
//m_collisionConfiguration->setConvexConvexMultipointIterations();
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
m_broadphase = new btDbvtBroadphase();
btVector3 worldMin(-1000,-1000,-1000);
btVector3 worldMax(1000,1000,1000);
btAxisSweep3* sweepBP = new btAxisSweep3(worldMin,worldMax);
m_overlappingPairCache = sweepBP;
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
m_dynamicsWorld->getDispatchInfo().m_allowedCcdPenetration=0.0001f;
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
btBoxShape* box = new btBoxShape(btVector3(btScalar(8.),btScalar(1.0),btScalar(8.)));
// box->initializePolyhedralFeatures();
btCollisionShape* groundShape = box;
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
m_collisionShapes.push_back(groundShape);
// m_colli