bullet物理引擎-配置
2014-06-12 01:17
381 查看
Bullet物理引擎-配置
下载地址:https://code.google.com/p/bullet/downloads/list
如下图:
选择第一个bullet2.82-r2704(这个是sdk)。
下载后解压,如图:
此时lib文件夹下只有一个readme.txt。
进入build文件夹下,如图:
运行vs2010.bat,会在当前目录下生成一个vs2010文件夹,结果如下:
进入vs2010文件夹,问价如下:
第一个文件格式为.sln,表示是vs工程,可以用vs2010打开。
打开后如图:
分别在debug和release模式下生成全部解决方案。完成后可以查看demo运行情况。
生成成功后,bullet文件夹下会显示如下:
说明debug和release模式下生成的文件都存在到了bullet主目录下,而此时的lib文件夹中存在如下文件:
Vs2010工程。
新建一个空白的vs2010控制台工程,添加一个main.cpp文件。拷贝如下内容:
#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;
system("pause");
return 0;
}
保存。
在解决方案上右键—属性,如下:
配置如下:
附加包含目录--添加bullet文件夹下的src文件夹:
附加库目录--下添加bullet文件夹中的lib文件夹:
在debug模式下添加lib文件中的debug模式生成的lib文件。(有debug字符):
同样的,在release模式下添加lib文件夹中的release模式生成的lib文件(无debug字符)。
然后生成解决方案,运行后如图:
配置成功。
下载地址:https://code.google.com/p/bullet/downloads/list
如下图:
选择第一个bullet2.82-r2704(这个是sdk)。
下载后解压,如图:
此时lib文件夹下只有一个readme.txt。
进入build文件夹下,如图:
运行vs2010.bat,会在当前目录下生成一个vs2010文件夹,结果如下:
进入vs2010文件夹,问价如下:
第一个文件格式为.sln,表示是vs工程,可以用vs2010打开。
打开后如图:
分别在debug和release模式下生成全部解决方案。完成后可以查看demo运行情况。
生成成功后,bullet文件夹下会显示如下:
说明debug和release模式下生成的文件都存在到了bullet主目录下,而此时的lib文件夹中存在如下文件:
Vs2010工程。
新建一个空白的vs2010控制台工程,添加一个main.cpp文件。拷贝如下内容:
#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;
system("pause");
return 0;
}
保存。
在解决方案上右键—属性,如下:
配置如下:
附加包含目录--添加bullet文件夹下的src文件夹:
附加库目录--下添加bullet文件夹中的lib文件夹:
在debug模式下添加lib文件中的debug模式生成的lib文件。(有debug字符):
同样的,在release模式下添加lib文件夹中的release模式生成的lib文件(无debug字符)。
然后生成解决方案,运行后如图:
配置成功。
相关文章推荐
- 给osg配置bullet物理引擎
- Bullet 物理引擎 详细分析 Dbvt (2)
- Bullet 物理引擎 详细分析 Dbvt (4)
- Bullet物理引擎及基础知识
- iOS 中引入Bullet 物理引擎
- Bullet物理引擎教程: helloworld
- Bullet 物理引擎 简析[1]
- Bullet物理引擎不完全指南 in Linux
- Bullet 物理引擎 简析[1]
- Bullet 3D 物理引擎 简析(2)
- bullet 物理引擎的角色控制器(character controller) ()
- 【Box 2D物理引擎C++】Box 2D环境配置
- Bullet物理引擎不完全指南(Bullet Physics Engine not complete Guide)
- Bullet物理引擎不完全指南(Bullet Physics Engine not complete Guide)
- Bullet 物理引擎 详细分析 Dbvt (2)
- Bullet 物理引擎 详细分析 Dbvt (3)
- 整合Bullet物理引擎到Ogre on iPhone
- Bullet 3D 物理引擎 简析(2)
- Bullet物理引擎不完全指南(Bullet Physics Engine not complete Guide)
- Bullet物理引擎不完全指南 in Linux