Hey everybody, I'm wanting to integrate Bullet Physics into my DarkGDK project. I started small with the physics engine and DarkGDK running separately, but I've hit a brickwall. I've properly setup my code, and the Bullet code, but LoopGDK() will not return. Here's my code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <btBulletDynamicsCommon.h>
#include <DarkGDK.h>
void DarkGDK()
{
dbSetDisplayMode(800,600,32);
dbSyncOn();
dbSyncRate(60);
dbAutoCamOff();
dbPositionCamera(0,0,10,-50);
dbMakeObjectSphere(1,1);
dbPositionObject(1,0,50,0);
dbMakeObjectPlain(2,100,100);
dbPointObject(2,0,100,0);
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);
//Will NOT pass this point at all!
while(LoopGDK());
{
dynamicsWorld->stepSimulation(1/60.f,10);
btTransform trans;
fallRigidBody->getMotionState()->getWorldTransform(trans);
dbPositionObject(1,trans.getOrigin().getX(),trans.getOrigin().getY(),trans.getOrigin().getZ());
dbControlCameraUsingArrowKeys(0,5,2.5f);
dbSync();
}
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;
dbEnd();
return;
}
Any ideas?