I have the following code:
Code: Select all
btVector3 y,
fw,
right,
up;
y.setValue( 0.0f, 0.0f, 1.0f );
fw.setValue( ground_normal.x, ground_normal.y, ground_normal.z );
if( fabsf( fw.z() ) - fabsf( y.z() ) < 0.1f )
{ y.setValue( 0.0f, 1.0f, 0.0f ); }
right = btCross( y, fw ).normalize();
up = btCross( fw, right).normalize();
btMatrix3x3 rot(right.x(), up.x(), fw.x(),
right.y(), up.y(), fw.y(),
right.z(), up.z(), fw.z() );
m_btRigidBody->getWorldTransform().setBasis( rot );