Code: Select all
btRigidBody* Bullet::CreateBoxBody(const btVector3 &scale, btVector3 &rot, btScalar mass, const btVector3 &pos)
{
btCollisionShape *shape = new btBoxShape(btVector3(1, 1, 1));
shape->setLocalScaling(scale);
btQuaternion rotQuat;
rotQuat = rotQuat.getIdentity();
rotQuat.setX(rot.getX());
rotQuat.setY(rot.getY());
rotQuat.setZ(rot.getZ());
rotQuat.setW(1.0f);
btDefaultMotionState *motionState =
new btDefaultMotionState(btTransform(rotQuat, pos));
btVector3 fallInertia(0, 0, 0);
shape->calculateLocalInertia(mass, fallInertia);
btRigidBody::btRigidBodyConstructionInfo
bodyCl(mass, motionState, shape, fallInertia);
btRigidBody *body = new btRigidBody(bodyCl);
dynamicsWorld->addRigidBody(body);
dynamicsWorld->updateSingleAabb(body);
btTransform trans;
body->getMotionState()->getWorldTransform(trans);
std::cout << trans.getRotation().getX() << std::endl;
return body;
}