i add a box and let it fall on to the ground(plane) and after the box touched the ground it began to rotate unusually and never stop. the bullet demos are don't like this.
why ?
thanks~~
why the boxs rotates ?
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
-
- Posts: 11
- Joined: Tue Apr 24, 2007 6:20 am
the box shape is
with the mass of 1.0
it falls off from height 10.0 and the ground is at ( 0, 0, 0 )
the bullet initing codes:
i derived the class SceneObject from btDefaultMotionState
in another class RenderableSceneObject i use the setWorldTransform() to synchronize the Ogre SceneNode with the Bullet rigid body:
i can't find any differences with the demos.
are there any problems in my codes ?
thanks~~
Code: Select all
new btBoxShape( btVector3( 2.5, 2.5, 2.5 ) )
it falls off from height 10.0 and the ground is at ( 0, 0, 0 )
the bullet initing codes:
Code: Select all
int ModuleBullet::init(void)
{
btCollisionDispatcher* dispatcher= new btCollisionDispatcher();
btVector3 worldAabbMin( _worldSize[0][0], _worldSize[0][1], _worldSize[0][2] );
btVector3 worldAabbMax( _worldSize[1][0], _worldSize[1][1], _worldSize[1][2] );
btOverlappingPairCache* broadphase= new btAxisSweep3( worldAabbMin, worldAabbMax, _maxProxies );
btSequentialImpulseConstraintSolver* solver= new btSequentialImpulseConstraintSolver();
_world= new btDiscreteDynamicsWorld( dispatcher, broadphase, solver );
_world->setGravity( btVector3( 0, -9.8, 0 ) );
_timer.getTimeNow( _last_step );
return 0;
}
Code: Select all
SceneObject::SceneObject( btScalar __mass, btCollisionShape* __shape, const btTransform& __startTrans, const btTransform& __centerOfMassOffset, btScalar __friction, btScalar __restitution, btScalar __linearDamping, btScalar __angularDamping, bool __addToWorld )
: btDefaultMotionState( __startTrans, __centerOfMassOffset )
{
_body= NULL;
_inWorld= false;
btVector3 localInertia( 0, 0, 0 );
if( __mass != 0.0 ){
__shape->calculateLocalInertia( __mass, localInertia );
}
_body= new btRigidBody( __mass, this, __shape, localInertia, __linearDamping, __angularDamping, __friction, __restitution );
if( __addToWorld ){
_bullet->getWorld().addRigidBody( _body );
}
}
Code: Select all
void RenderableSceneObject::setWorldTransform( const btTransform& __centerOfMassWorldTrans )
{
btDefaultMotionState::setWorldTransform( __centerOfMassWorldTrans );
const btVector3& p= m_graphicsWorldTrans.getOrigin();
_node->setPosition( p.x(), p.y(), p.z() );
btQuaternion& q= m_graphicsWorldTrans.getRotation();
//q.normalize();
_node->rotate( Ogre::Quaternion( q.w(), q.x(), q.y(), q.z() ), Node::TS_WORLD );
}
i can't find any differences with the demos.
are there any problems in my codes ?
thanks~~
-
- Posts: 11
- Joined: Tue Apr 24, 2007 6:20 am