#include #include "BulletObject.h" BulletObject::BulletObject(Environment *bullet) { m_bullet = bullet; } btRigidBody* BulletObject::localCreateRigidBody (btScalar mass, const btTransform& startTransform, btCollisionShape* shape) { bool isDynamic = (mass != 0.f); btVector3 localInertia(0,0,0); if (isDynamic) shape->calculateLocalInertia(mass,localInertia); btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform); btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia); btRigidBody* body = new btRigidBody(rbInfo); m_bullet->getDynamicsWorld()->addRigidBody(body); return body; } btRigidBody* BulletObject::createBulletObject(btCollisionShape* colShape, btVector3 position, btScalar mass) { m_bullet->getCollisionShapes().push_back(colShape); btTransform startTransform; startTransform.setIdentity(); startTransform.setOrigin(SCALING*position); btRigidBody *body = localCreateRigidBody(mass, startTransform, colShape); body->setActivationState(ISLAND_SLEEPING); return body; } btRigidBody* BulletObject::createBulletObject(btCollisionShape* colShape, btTransform transform, btScalar mass) { m_bullet->getCollisionShapes().push_back(colShape); btRigidBody *body = localCreateRigidBody(mass, transform, colShape); body->setActivationState(ISLAND_SLEEPING); return body; }