|
我顺利编译好了bullet、osgworks、osgbullet,然后打算用osgbullet做一个汽车在崎岖山地行驶的场景,可是搭建环境的过程中遇到了难题,把完好可行的osgBullet代码放进自己搭建好的环境却怎么也不能运行出正确的结果来,总是出现类似于下图的提示。我的平台搭建过程参照Example BasicDemo的例子,具体内容详细写在下面了,请大家帮我看看什么地方出错了吧,不尽感激!
具体过程是这样的:
在“环境变量-用户变量-PATH”添加路径:
D:\Program Files\OSG\osgBullet\bin;
在“属性—配置属性—VC++目录—包含目录”中添加:
D:\Program Files\OSG\src;
D:\Program Files\OSG\bin;
D:\Program Files\OSG\osgBullet\bin;
D:\Program Files\OSG\osgWorks\bin;
D:/Program Files/OSG/include;
D:/Program Files/OSG/osgBullet/include;
D:/Program Files/OSG/osgWorks/include;
D:/Program Files/OSG/bullet/src;
在“属性—配置属性—VC++目录—库目录”中添加:
D:\Program Files\OSG\lib;
D:\Program Files\OSG\bullet\lib\Release;
D:\Program Files\OSG\bullet\lib\Debug;
D:\Program Files\OSG\osgWorks\lib;
D:\Program Files\OSG\osgBullet\lib;
参考Example BasicDemo的附加依赖项,在自己的工程里附加依赖项添加如下内容:
OpenThreadsd.lib
osgd.lib
osgAnimationd.lib
osgDBd.lib
osgFXd.lib
osgGAd.lib
osgManipulatord.lib
osgPresentationd.lib
osgShadowd.lib
osgSimd.lib
osgTerraind.lib
osgVolumed.lib
osgUtild.lib
osgViewerd.lib
osgTextd.lib
osgParticled.lib
osgWidgetd.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
D:\Program Files\OSG\osgBullet\lib\osgbDynamicsd.lib
D:\Program Files\OSG\osgBullet\lib\osgbCollisiond.lib
D:\Program Files\OSG\osgWorks\lib\osgwControlsd.lib
D:\Program Files\OSG\osgWorks\lib\osgwQueryd.lib
D:\Program Files\OSG\osgWorks\lib\osgwToolsd.lib
D:\Program Files\OSG\lib\OpenThreadsd.lib
D:\Program Files\OSG\lib\osgd.lib
D:\Program Files\OSG\lib\osgDBd.lib
D:\Program Files\OSG\lib\osgUtild.lib
D:\Program Files\OSG\lib\osgGAd.lib
D:\Program Files\OSG\lib\osgTextd.lib
D:\Program Files\OSG\lib\osgViewerd.lib
D:\Program Files\OSG\lib\osgShadowd.lib
D:\Program Files\OSG\bullet\lib\Debug\BulletDynamics_Debug.lib
D:\Program Files\OSG\bullet\lib\Debug\BulletCollision_Debug.lib
D:\Program Files\OSG\bullet\lib\Debug\LinearMath_Debug.lib
D:\Program Files\OSG\bullet\lib\Debug\BulletSoftBody_Debug.lib
用来测试搭建环境是否可行的代码是“Bullet教程: Hello World 实例”(http://blog.csdn.net/lxdfigo/article/details/8279783)中的源代码,这段源代码被我放在Example BasicDemo下执行过是可用的,可是放在我的环境下不可用。源码如下:- #include <iostream>
- #include <btBulletDynamicsCommon.h>
- int main (void)
- {
- btVector3 worldAabbMin(-10000,-10000,-10000);
- btVector3 worldAabbMax(10000,10000,10000);
- int maxProxies = 1024;
- btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
- 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;
- }
复制代码 |
|