/LGC物理引擎/Box2D:一个 2D rigid body 物理引擎

来源:互联网 发布:对网络语言暴力的看法 编辑:程序博客网 时间:2024/06/06 09:33
Box2D:一个 2D rigid body 物理引擎
作者: 刘鹏
日期: 2009-03-09
Box2D 是一个2D rigid body 物理引擎,本文介绍了它的基本情况、主要特色以及使用 Box2D 开发程序的基本思路。

Overview

Box2D 是一个功能丰富的 2D rigid body 物理引擎,基于 C++ 开发,作者是 Erin Catto。使用 Box2D,开发人员可以使对象运动时具有物理效果,如惯性、自由落体、碰撞等等。

2D rigid body 是一个不会变形的物体,它具有质量和惯性。它的状态由重心和旋转角度决定。它的动态移动由线速度和角速度控制。3

Box2D 已在多个游戏中使用,包括 Crayon Physics Deluxe,该游戏赢得了 2008 Independent Game Festival Grand Prize。

Box2D 已经移植到 Flash、Java、C#、Python、JavaScript、D 和具有定点数运算能力的嵌入式设备上。

Features1

  • Collision
  1. Continuous collision detection.
  2. Contact callbacks: add, persist, remove.
  3. Convex polyons and circles.
  4. Multiple shapes per body
  5. One-shot contact manifolds
  6. Incremental sweep-and-prune broadphase
  7. Efficient pair management
  8. Fast broadphase AABB queries
  9. Collision groups and categories
  • Physics
  1. Continuous physics with time of impact island solver.
  2. Persistent body-joint-contact graph
  3. Island solution and sleep management
  4. Contact, friction, and restitution
  5. Stable stacking with a linear-time solver
  6. Revolute, prismatic, distance, pulley, gear, and mouse joints
  7. Joint limits, motors, and friction
  8. Momentum decoupled position correction
  9. Fairly accurate reaction forces/impulses
  • System
  1. Small block and stack allocators
  2. Centralized tuning parameters
  3. Highly portable C++ with no use of STL containers

Box2D 开发基本思路

  • create a world
  • create a Ground Box
  • Create a Dynamic Body
  • Simulating the World
    • time step is 60Hz 或者 1/60 秒
    • integrator,在离散时间点模拟物理方程
    • simulation loop : call b2World::Step.

细节内容可以参考 box2d manual 中的 helloworld 例子,http://www.box2d.org/manual.html#d0e110 。

Reference

1. Box2D Features

2. box2d wiki

3. Rigid Body

4. box2d manual

原创粉丝点击