diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-03-09 23:55:49 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-03-09 23:55:49 -0500 |
| commit | 2831e232b886c5e3b0791ea5192f9e5194e6abf3 (patch) | |
| tree | 4fb9309d18f388673b7a21b8f0e927727006f585 /src/test_bullet.cpp | |
| parent | 35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940 (diff) | |
| download | brokengine-2831e232b886c5e3b0791ea5192f9e5194e6abf3.tar.gz brokengine-2831e232b886c5e3b0791ea5192f9e5194e6abf3.tar.bz2 brokengine-2831e232b886c5e3b0791ea5192f9e5194e6abf3.zip | |
Added IGUIImages
Added the ability to display itextures on the gui
Diffstat (limited to 'src/test_bullet.cpp')
| -rw-r--r-- | src/test_bullet.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/test_bullet.cpp b/src/test_bullet.cpp new file mode 100644 index 0000000..fa17f6a --- /dev/null +++ b/src/test_bullet.cpp @@ -0,0 +1,72 @@ +#include <iostream> + +#include <btBulletDynamicsCommon.h> + +int main (void) +{ + + btBroadphaseInterface* broadphase = new btDbvtBroadphase(); + + btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(); + btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration); + + btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver; + + btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration); + + dynamicsWorld->setGravity(btVector3(0, -10, 0)); + + + btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0, 1, 0), 1); + + btCollisionShape* fallShape = new btSphereShape(1); + + + btDefaultMotionState* groundMotionState = new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, -1, 0))); + btRigidBody::btRigidBodyConstructionInfo + groundRigidBodyCI(0, groundMotionState, groundShape, btVector3(0, 0, 0)); + btRigidBody* groundRigidBody = new btRigidBody(groundRigidBodyCI); + dynamicsWorld->addRigidBody(groundRigidBody); + + + btDefaultMotionState* fallMotionState = + new btDefaultMotionState(btTransform(btQuaternion(0, 0, 0, 1), btVector3(0, 50, 0))); + btScalar mass = 1; + btVector3 fallInertia(0, 0, 0); + fallShape->calculateLocalInertia(mass, fallInertia); + btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass, fallMotionState, fallShape, fallInertia); + btRigidBody* fallRigidBody = new btRigidBody(fallRigidBodyCI); + dynamicsWorld->addRigidBody(fallRigidBody); + + + for (int i = 0; i < 300; i++) { + dynamicsWorld->stepSimulation(1 / 60.f, 10); + + btTransform trans; + fallRigidBody->getMotionState()->getWorldTransform(trans); + + std::cout << "sphere height: " << trans.getOrigin().getY() << std::endl; + } + + dynamicsWorld->removeRigidBody(fallRigidBody); + delete fallRigidBody->getMotionState(); + delete fallRigidBody; + + dynamicsWorld->removeRigidBody(groundRigidBody); + delete groundRigidBody->getMotionState(); + delete groundRigidBody; + + + delete fallShape; + + delete groundShape; + + + delete dynamicsWorld; + delete solver; + delete collisionConfiguration; + delete dispatcher; + delete broadphase; + + return 0; +} |
