翻译: Jan 17, 2010 by Alex Liu
Documentation  

Chipmunk Physics

Note: The documentation on this wiki documents Chipmunk v5.0.0.

First of all, Chipmunk is a 2D rigid body physics library distributed under the MIT license. Though not yet complete, it is intended to be fast, numerically stable, and easy to use. I've put hundreds of hours of work into making Chipmunk what it is today. If you find Chipmunk has saved you a lot of time, please consider donating. You'll make an indie game developer very happy.

I would like to give a Erin Catto a big thank you, as the most of the ideas for the constraint solver I use now come from his Box2D example code. (Now a full fledged physics engine all it's own: Box2D). His contact persistence idea allows for stable stacks of objects with very few iterations of the contact solution. Previously my solver produced mushy piles of objects or required a large number of iterations in order to get a stable behavior.

这个文档针对于v5 .0而言

首先,Chipmunk是一个2D的刚体物理引擎库,遵守MIT协议。虽然现在还没有完成,但是它被设计更快,更稳定,使用更简单。我已经投入了上百个小时在Chipmunk里面如果你发现使用了Chipmunk能给你节省时间,那么你可以考虑捐赠。它能够是游戏开发者变得快乐。

我非常的感谢Erin Catto, 因为它是我从众多的解决方案中Box2D例子得来得。。。。。略。。

Overview 概述

There are 4 basic things you need to know about in order to work with Chipmunk.

为了能够使用Chipmunk,你需要按顺序了解以下几个基本特征。

  • Rigid Bodies: A rigid body holds the physical properties of an object. (mass, position, rotation, velocity, etc.) It does not have a shape by itself. If you’ve done physics with particles before, rigid bodies differ in that they are able to rotate.
  • 刚体,是一个对象的物理属性,他没有自己的形状,如果在物力上对粒子有了解,刚体不同于粒子,它可以旋转。
  • Collision Shapes: By attaching shapes to bodies, you can define the a body’s shape. You can attach as many shapes to a single body as you need to in order to define a complex shape. Shapes contain the surface properties of an object such as how much friction or elasticity it has.
  • 冲突形状:通过物体形状的附加,你可以定义一个物体的形状。你可以给一个单一的物体附上很多你需要的形状,很复杂的形状。形状包括表面的属性,就好像有多少摩擦或者弹性(elasticity猜的)
  • Constraints/Joints: Constraints and joints describe how bodies are attached to each other.
  • 限制和连接:描述物体之间如何接触。
  • Spaces: Spaces are the basic simulation unit in Chipmunk. You add bodies, shapes and joints to a space, and then update the space as a whole.
  • 空间:Chipmunk最基本单元的模拟。添加物体,形状,到一个空间,然后以一个整体进行更新这个空间。

Support

The best way to get support is to visit the Chipmunk Forums. There are plenty of people around using Chipmunk on the just about every platform I've ever heard of. If you are working on a commercial project, Howling Moon Software is also available for contracting.

Chipmunk最好的支持就是Chipmunk论坛,它有很多使用Chipmunk的开发人员,它们把它应用在很多我所听过的平台。如果你工作在一个商业的项目上, 签协议?

Rigid bodies, collision shapes and sprites: 刚体,冲突形态和精灵

There is often confusion between rigid bodies and their collision shapes in Chipmunk and how they relate to sprites. A sprite would be a visual representation of an object, the sprite is drawn at the position and rotation of the rigid body. Collision shapes representation of the object, and how it should collide with other objects. A sprite and collision shape have little to do with one another other than you probably want the collision shape to match the sprite’s shape.

人们常常混淆这刚体,冲突和精灵的关系。精灵是一个虚拟的,物体的呈现,精灵以一种位置和旋转过的刚体位置来绘制。冲突形态表现的是物体的冲突,它和其他物体冲突的时候应该如何表现。精灵和冲突形态之间需要做的就是,你可能回把冲突形态与精灵的形状向匹配。

Chipmunk Basics Chipmunk的一些基础知识

Initialization 初始化

Before you do anything else, you must initialize Chipmunk. Otherwise you will crash as soon as the first collision happens.

cpInitChipmunk(); // That is all

Additionally, if you didn't compile Chipmunk with the NDEBUG flag, it will print out the debug mode message and the current version number to stdout.

再你开始之前,你必须初始化

Chipmunk,否则将会crash,初始化使用以上那个函数。除此之外,如果你还没有通过NDEBUG flag 编译

Chipmunk的话,你需要打印出debug模式的信息,和当前的stdout版本号。

Memory Management the Chipmunk way

Chipmunk内存管理之道

For many of the structures you will use, Chipmunk uses a more or less standard set of memory management functions. For example: 对于很多你使用过的框架,

Chipmunk使用的是标准的内存管理函数,例如:

cpSpaceAlloc() allocates but does not initialize a cpSpace struct.cpSpaceInit(cpSpace *space) initializes a cpSpace struct.cpSpaceDestroy(cpSpace *space) frees all memory allocated by the cpSpaceInit(), but does not free the cpSpace struct itself.cpSpaceNew() allocates and initializes a cpSpace struct (calls cpSpaceAlloc () and cpSpaceInit()).cpSpaceFree(cpSpace *space) calls cpSpaceDestroy() and then frees the cpSpace struct.

While you will probably use the new/free versions exclusively if you are using C/C++, but the alloc/init/destroy functions can be helpful when writing language extensions so that you can more easily work with a garbage collector.

In general, you are responsible for freeing any structs that you allocate. Chipmunk does not have any fancy reference counting or garbage collection.

当你使用c/c++的时候,你可能选择不去使用new/free分配内存。但是分配/初始化/销毁 函数将会给你的语言扩展带来很大的帮助,所以会使得垃圾回收机制变得更加容易的工作。

通常来讲,你要对你自行分配的任何结构使用free来销毁这是你的责任。

Chipmunk没有任何引用记数和垃圾回收?(没看懂什么意思)

Math the Chipmunk way 匹配

First of all, Chipmunk uses double precision floating point numbers throughout it's calculations by default. This is likely to be faster on most modern desktop processors, and means you have to worry less about floating point round off errors. You can change the floating point type used by Chipmunk when compiling the library. Look in chipmunk.h.

首先,

Chipmunk在计算的时候,缺省使用的双精度浮点数。这是对于当前的桌面处理器来说,很快速。并且意味着你不用去担心舍去所出现的问题。你可以改变浮点的type,当你编译库的时候。详细的参看

Chipmunk.h

Chipmunk defines a number of aliases for common math functions so that you can choose to use floats or doubles for Chipmunk's floating point type. In your own code, there probably isn't a strong reason to use these aliases unless you expect you might want to change Chipmunk's floating point type later and a 2% performance hit from using the wrong float/double version of math functions will matter.

Chipmunk定义了一些列的数学运算函数,这使得你可以选择使用单精度或者是双精度浮点类型。

在你自己的代码中,这可能不是一个很大的因素去使用这些函数,除非你期望改变

Chipmunk浮点数的类型,使用了float/double造成的并且一个2%性能损失,并不会太大。

That said, there are a few functions you will probably find very useful:

cpFloat cpfclamp(cpFloat f, cpFloat min, cpFloat max)

Clamp f to be between min and max.

cpFloat cpflerp(cpFloat f1, cpFloat f2, cpFloat t)

Linearly interpolate between f1 and f2. f1和f2之间额外的直线

cpFloat cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d)

Linearly interpolate from f1 towards f2 by d.

To represent vectors, Chipmunk defines the cpVect type and a set of inline functions for working with them (cpv, cpvadd, cpvmult, etc). See the API reference for more information..

Chipmunk C API (c语言API)

Main API 主要的API

cpVect - Create and manipulate 2D vectors. 创建和操作一个2D的矢量cpBB - Create and manipulate 2D axis-aligned bounding boxes. 创建和操作一个2D坐标轴绑定的boxcpBody - Create and work with rigid bodies. 创建一个具有刚体属性的物体cpShape - Attach collision shapes to rigid bodies. 给刚体加上一个冲突形状cpSpace - Create a "space" to put your objects into and simulate them. 给物体和模拟它们之间创建一个空间cpConstraint - Create joints and other constraints. 创建一个连接和其他约束Learn about how CollisionDetection in Chipmunk works. 学习如何处理

Chipmunk冲突工作

Learn about Chipmunk's CallbackSystem and cpArbiter struct for recieving collision events and adding custom behavior to your physics. 以上两个结构接受冲突时间,加入一个自定义的物理表现。Learn about Queries. Point queries and segment queries (raycasting). 学习如何查询,指出查询的片断。

Links (以下就是相关的链接)

http://www.slembcke.net/forums/viewforum.php?f=1 - The official forum 官方论坛Games - A list of games done with Chipmunk 使用了

Chipmunk引擎的游戏列表

BindingsAndPorts - A list of bindings and ports of Chipmunk to other languages.

本来说好下午翻译,或者先看看cocos2d的应用的。结果郁闷的无所事事的墨迹到晚上。。。k。。

只能翻译好了再睡觉。。MACOS输入法好难用啊。。

注:本文不是全文一句句的翻译。大概就是那么个意思。大体的讲讲。不重要的一概忽略了。。需要的,自己详细读吧。不过这也只是一个概述而已。。。具体还要深入分析研究才是。。

转载于:https://www.cnblogs.com/AlexLiu/archive/2010/01/17/1650241.html

[翻译]ChipMunk 2D 游戏重力引擎相关推荐

  1. [翻译]Why Functional Programming Matters

    Why Functional Programming Matters 函数式程序设计为什么至关重要 作者: John Hughes 翻译: CloudiDust [http://blog.csdn.n ...

  2. [翻译]在Asp.net 2.0中操作数据::母板页和站点导航

    在Asp.net 2.0中操作数据::母板页和站点导航 英文原文 |  下载示例代码(C#)  |  翻译进度  |  英文教程目录 导言 通常,用户友好的个性化站点都有着一致的,站点统一的页面布局和 ...

  3. [翻译]PHP中define()和const定义常量的区别

    在PHP中可以通过define()和const两种方式定义常量 可是在开发中我们应该什么时候用define()定义常量,什么时候用const定义常量? 这两种方式定义常量的主要区别是什么? 从5.3版 ...

  4. 开发2d游戏要用什么引擎_下一个游戏要使用什么2D游戏引擎

    开发2d游戏要用什么引擎 A few weeks ago, I posted about my experience attempting to make a prototype in a bunch ...

  5. 2d游戏引擎_8年,从2D到3D,我的学习之路

    Mickey 写了一篇 <一个本科毕业生创业两年的感悟>,从他的视角,总结了我们合作的两年经历. 我也来写一篇,介绍我的学习之路,希望对大家有所帮助,谢谢大家- 我的学习方法 1.直接从0 ...

  6. Unity大魔王私藏的开发2D游戏的常用插件合集

    Unity以开发3D游戏见长,早期版本的Unity在开发2D游戏时不慎方便,因此Asset Store出现了很多2D游戏开发引擎.现在Unity对2D游戏的支持越来越好,而这些开发2D游戏的Unity ...

  7. Android 2D游戏引擎AndEngine快速入门教程

    Android 2D游戏引擎AndEngine快速入门教程 介绍:AndEngine是一款知名的Android 2D游戏引擎.该引擎代码开源,并且可以免费使用.本书详细讲解如何使用AndEngine引 ...

  8. Godot3游戏引擎入门之零一:【翻译】为什么要选择 Godot 引擎

    前言 本文作为我的 Godot 系列文章的第二篇,是一篇翻译文作为 Godot 的优点说明吧,虽然文章发布于去年,但还是很有借鉴意义,翻译的不是很好请海涵! :smile: 作者简介:Rock Mil ...

  9. 配置JDKAndroid 2D游戏引擎AndEngine

    配置JDKAndroid 2D游戏引擎AndEngine JDK全称为Java Development Kit(也即Java开发包),是用于支持Java 编程的基础.无论是什么编程,只要用到了Java ...

  10. Android 2D游戏引擎AndEngine配置环境

    Android 2D游戏引擎AndEngine配置环境 1.2  配置环境 在任何编程中,都需要一些软件或者硬件的支持.否则,没有硬件软件是不可能存在的,而想要编写对应语言的的程序,这需要对应语言库和 ...

最新文章

  1. Winform中对ZedGraph的曲线标签进行设置,比如去掉标签边框
  2. 消息队列入门案例-环境搭建
  3. 六类网线和超六类网线有什么区别呢 怎么区分
  4. ObjectAnimator属性动画应用demo
  5. Android逆向笔记-Unity3D逆向一般思路(静态分析)
  6. c调用python接口_通过Python自带C/C++接口实现python与c/c++相互调用
  7. 水表模型更新--170323
  8. MySQL在Windows和Linux减少数据库
  9. ASP.NET程序中常用代码汇总(五)
  10. 将一个对象的空值全部设置为null
  11. 【IDEA】报错:Warning:java: 源值1.5已过时, 将在未来所有发行版中删除
  12. iphone电池怎么保养_手机电池不耐用怎么办啊?平时要怎么保养呢?我来告诉你...
  13. git@github.com: Permission denied
  14. HTML的DOCTYPE是什么意思
  15. Logstash:使用 mutate 过滤器
  16. Redis——Redis入门和一些笔记
  17. @media screen and 不起作用原因汇总。(转载)
  18. PostgreSQL官网下载
  19. 气化及燃烧相关知识点
  20. 使用ffmpeg批量转码的命令行(以mkv转mp4为例)

热门文章

  1. Mac上将Lightroom目录导入Capture One的详细步骤
  2. MacOS六个常用的终端命令
  3. PDFelement如何快速地将文本添加到PDF?
  4. 使用shell创建一个简单的菜单bash select用法
  5. 测试 JavaScript 函数的性能
  6. 关于一些nginx的高级扩展应用
  7. PostgreSQL Excel包含中文字符的数据导入方法
  8. StreamInsight 浅入浅出(三)—— 适配器
  9. idea 快捷键修改去除 自动导入import 相关整理
  10. java 序列化 学习