0.1
0.2
0.3
...
8.0
8.1
8.2
8.5 -- this is wierd,since 8.2 is when mario hit the ground
8.2 -- then back to 8.2 which is normal
8.2
8.2
8.2
so the screenshot looks like this: when mario hit the ground, he just go into the ground a little bit normal, then back to normal.
here is the initialize code:
Code: Select all
mv_broadphase = new btDbvtBroadphase();
//gerenic
mvDefaultCollisionConfiguration = new btDefaultCollisionConfiguration();
//mv_broadphase = new btDbvtBroadphase();
mv_constraintSolver = new btSequentialImpulseConstraintSolver();
mv_dispatcher = new btCollisionDispatcher ( mvDefaultCollisionConfiguration );
btVoronoiSimplexSolver* simplex = new btVoronoiSimplexSolver();
btMinkowskiPenetrationDepthSolver* pdSolver = new btMinkowskiPenetrationDepthSolver();
btConvex2dConvex2dAlgorithm::CreateFunc* convexAlgo2d = new btConvex2dConvex2dAlgorithm::CreateFunc ( simplex,pdSolver );
mv_dispatcher->registerCollisionCreateFunc ( CONVEX_2D_SHAPE_PROXYTYPE,CONVEX_2D_SHAPE_PROXYTYPE,convexAlgo2d );
mv_dispatcher->registerCollisionCreateFunc ( BOX_2D_SHAPE_PROXYTYPE,CONVEX_2D_SHAPE_PROXYTYPE,convexAlgo2d );
mv_dispatcher->registerCollisionCreateFunc ( CONVEX_2D_SHAPE_PROXYTYPE,BOX_2D_SHAPE_PROXYTYPE,convexAlgo2d );
mv_dispatcher->registerCollisionCreateFunc ( BOX_2D_SHAPE_PROXYTYPE,BOX_2D_SHAPE_PROXYTYPE,new btBox2dBox2dCollisionAlgorithm::CreateFunc() );
mvDynamicsWorld = new btDiscreteDynamicsWorld ( mv_dispatcher, mv_broadphase, mv_constraintSolver, mvDefaultCollisionConfiguration );
mvDynamicsWorld->setDebugDrawer ( &sDebugDrawer );
Code: Select all
btRigidBody* addBox ( float x,float y,float width,float height,float friciton,float restitution,float mass,bool in3D )
{
btRigidBody * body;
btConvexShape* shape;
// shape = new btConvex2dShape ( new btBoxShape ( btVector3 ( width *PSF,height *PSF,btScalar ( 0.04 ) ) ) );
shape = new btConvex2dShape ( new btBoxShape ( btVector3 ( width * PSF,height *PSF, btScalar ( 0.04 ) ) ) );
//shape->setMargin ( btScalar ( 0.04f ) ); //uncomment this ,same result.
btVector3 localinertia ( 0,0,0 );
shape->calculateLocalInertia ( mass,localinertia );
btTransform defaultTransform;
defaultTransform.setIdentity();
btQuaternion defaultRotation;
defaultRotation.setEuler ( 0,0,0 );
if ( in3D )
defaultTransform.setOrigin ( btVector3 ( x * PSF - width * PSF,-y * PSF + height * PSF,-3 * 61 * PSF ) );
else
defaultTransform.setOrigin ( btVector3 ( x * PSF - width * PSF,y * PSF - height * PSF,0 ) );
defaultTransform.setRotation ( defaultRotation );
btDefaultMotionState* my_motion_state = new btDefaultMotionState ( defaultTransform );
btRigidBody::btRigidBodyConstructionInfo rbInfo ( 0,0,0 );
rbInfo = btRigidBody::btRigidBodyConstructionInfo ( mass,my_motion_state,shape,localinertia );
rbInfo.m_friction = friciton;
rbInfo.m_restitution = restitution;
body = new btRigidBody ( rbInfo );
body->setLinearFactor ( btVector3 ( 1,1,0 ) );
body->setAngularFactor ( btVector3 ( 0,0,0 ) );
body->setActivationState ( DISABLE_DEACTIVATION );
body->setCenterOfMassTransform ( defaultTransform );
//add to the world ha
mvDynamicsWorld->addRigidBody ( body );
and I have to changed the world gravity to -40,to let mario fall a little bit faster,but when I change to -10 ,nothing changes,mario always fall into the ground a little bit ,then back to normal,what param do I need to change? thanks,here is an image that I captured,when mario fall into the ground.
