编译安装Bullet3-2.87

安装过程其实很简单,有多重源码安装方法,这里提供两种:
方法1:

cd bullet3-2.87
mkdir build && cd build
cmake ..
make
sudo make install

方法2:

cd bullet3-2.87
./build_cmake_pybullet_double.sh

编写一个Bullet版本的Hello World,验证安装是否正确

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project(01_bullet)
find_package(Bullet REQUIRED)
include_directories(${BULLET_INCLUDE_DIR})
set(TARGET_LIB"/usr/local/lib/libBulletDynamics.so""/usr/local/lib/libBulletCollision.so""/usr/local/lib/libLinearMath.so")
add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} ${TARGET_LIB})

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;return 0;
}

输出结果为:

sphere height: 50
sphere height: 49.9972
sphere height: 49.9917
sphere height: 49.9833
sphere height: 49.9722
sphere height: 49.9583
sphere height: 49.9417
sphere height: 49.9222
...
...
...

Bullet3-2.87在Ubuntu16.04下源码编译安装相关推荐

  1. ubuntu安装python_ubuntu18.04下源码编译安装最新版本Python3

    原文链接:ubuntu18.04下源码编译安装最新版本Python3 截止到2019年4月9日,Python3最新的版本是3.7.3. 在ubuntu18.04中已经安装的Python3版本是3.6. ...

  2. python版本升级后编译_ubuntu18.04下源码编译安装最新版本Python3

    截止到2019年4月9日,Python3最新的版本是3.7.3. 在ubuntu18.04中已经安装的Python3版本是3.6.7,下面我们就演示一下如何在ubuntu18.04下源码编译安装Pyt ...

  3. centos lnmp源码安装mysql_CentOS 6.6 下源码编译安装MySQL 5.7.5

    说明:CentOS 6.6 下源码编译安装MySQL 5.7.5 1. 安装相关工具 # yum -y install gcc-c++ ncurses-devel cmake make perl \ ...

  4. Python 3.10版本及其依赖项 Linux下源码编译 安装到指定路径/目录

    Python 3.10版本及其依赖项 Linux下源码编译 安装到指定路径/目录 安装需求 准备工作 Python及其依赖项 libffi glibc GDBM mpdecimal bz2 xz re ...

  5. CentOS7下源码编译安装MySQL5.6.4

    CentOS7下源码编译安装MySQL5.6.4 写这篇博客的主要原因是:请看上一篇博客:CentOS7下更改MySQL5.6.4默认的数据存储位置.对,当初通过rpm安装的mysql5.6.4,一切 ...

  6. Linux 下源码编译安装 vim 8.1

    前言 目前 linux 的各个发行版基本上都是带了一个 vi 编辑器的,而本文要说的 vim 编辑器对 vi 做了一些优化升级,更好用.当我们需要远程操作一台 linux 服务器的时候,只能使用命令行 ...

  7. Linux下源码编译安装新版libxcb

    前言 上一篇文章提到,linux 下编译Qt源码如果要用到Quick的话,那么运行时会依赖qxcb库,而编译生成qxcb库就需要先安装libxcb,并且最低要求 版本大于1.9.1 Requires ...

  8. 【Python 笔记】Linux 下源码编译安装 python

    本文记录在 Linux 上源码编译安装 python 的过程. 文章目录 1. 源码编译安装说明 2. 安装 python2.7 3. 安装 python3.6 1. 源码编译安装说明 安装过程比我想 ...

  9. ubuntu16.04下源码安装arachni扫描器

    前段时候看一个对各开源扫描器的评测,arachni在综合评价上胜出.最近正好想研究一下arachni的源码,那就在ubuntu下先把玩一下.其实之前在kali和ubuntu下源码安装都失败了,这次算是 ...

最新文章

  1. iPhone因安全漏洞上热搜,苹果:暂时无法修复,法国总统也中招
  2. Android模拟器安装程序及上传音乐并播放
  3. 老司机教你将流量价值提升100倍
  4. MySQL高级 - 日志 - 错误日志
  5. basicdatasourcefactory mysql_Java基础-DBCP连接池(BasicDataSource类)详解
  6. 前端学习(3170):react-hello-react之实现底部功能
  7. C语言(CED)递归实现汉诺塔问题
  8. 用汉明距离进行图片相似度检测的Java实现
  9. java 文章目录递归(一级标题,二级标题)
  10. Elasticsearch:InteliJ Elasticsearch plugin 集成
  11. 还在买什么会员?你最需要的IDM下载利器来了~
  12. ZooKeeper Commands: The Four Letter Words
  13. 企鹅形象与Linux[图]
  14. JuiceFS 在多云存储架构中的应用 | 深势科技分享
  15. 神舟电脑装linux双系统,神舟战神肿么装双系统
  16. Hello CTP(五)——CTP仓位计算
  17. OneNote 2007 无法启动的问题
  18. Spark Streaming 项目实战 (4) | 得到最近1小时广告点击量实时统计并写入到redis
  19. 消防物联网(沈阳消防所)
  20. 【移动安全实战篇】————1、Android手机下xx.apk JAVA破解之旅

热门文章

  1. Android动态获取手机是否是充电状态
  2. 路径规划Dijkstra算法
  3. 安装Paddle环境
  4. 详细教你两台电脑之间传文件
  5. 前端传file文件给后端
  6. Django中channels的配置
  7. win7使用telnet客户端
  8. 零售转型电商三重门:双线+定价+物流
  9. HTML 单选按钮(性别实现)
  10. 3D游戏3D素材资源zip压缩解决方案