source: proiecte/SIMEO/Simeo/src/SimeoEngine/BulletObject.cpp @ 167

Last change on this file since 167 was 167, checked in by (none), 14 years ago

Simeo: added final project and also older proof of concept code.

We used Git for version control, so look at the Git repo
in SIMEO/Simeo/ for more info.

File size: 1.3 KB
Line 
1#include <stdio.h>
2#include "BulletObject.h"
3
4BulletObject::BulletObject(Environment *bullet)
5{
6        m_bullet = bullet;
7}
8
9
10btRigidBody* BulletObject::localCreateRigidBody (btScalar mass, const btTransform& startTransform, btCollisionShape* shape) {
11        bool isDynamic = (mass != 0.f);
12
13        btVector3 localInertia(0,0,0);
14        if (isDynamic)
15                shape->calculateLocalInertia(mass,localInertia);
16
17        btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform);
18        btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
19        btRigidBody* body = new btRigidBody(rbInfo);
20
21        m_bullet->getDynamicsWorld()->addRigidBody(body);
22
23        return body;
24}
25
26btRigidBody* BulletObject::createBulletObject(btCollisionShape* colShape, btVector3 position, btScalar mass)
27{
28        m_bullet->getCollisionShapes().push_back(colShape);
29
30        btTransform startTransform;
31        startTransform.setIdentity();
32        startTransform.setOrigin(SCALING*position);
33
34        btRigidBody *body = localCreateRigidBody(mass, startTransform, colShape);
35        body->setActivationState(ISLAND_SLEEPING);
36
37        return body;
38}
39
40
41btRigidBody* BulletObject::createBulletObject(btCollisionShape* colShape, btTransform transform, btScalar mass)
42{
43        m_bullet->getCollisionShapes().push_back(colShape);
44
45        btRigidBody *body = localCreateRigidBody(mass, transform, colShape);
46        body->setActivationState(ISLAND_SLEEPING);
47
48        return body;
49}
Note: See TracBrowser for help on using the repository browser.