最近研究物理引擎,对网上能找到的开源物理引擎做了一下比较,完整的分析报告没有放出来,只放一些分析资料。
(一) 2D物理引擎
1、 Box2D
A、 地址:http://box2dflash.sourceforge.net/,http://box2dflash.boristhebrave.com/docs/2.0.2/manual
B、 最后更新日期:还在更新,2.1a版
C、 活跃情况:用户活跃,最新的消息在2010年1月,中间停过一段时间
D、 资源消耗:浏览器运行,帧率30,机器人DemoCPU消耗<20% (初始峰值达到40%,在帧率为24的时候机器人Demo不存在该初始峰值,<7%), HelloWorld<3%,
E、 其他相关信息:为游戏设计的一款2D引擎,由C++的Box2D转换而来
主要负责物理模型的处理,数据流为主,图形学方面的东西涉及较少;
有Java的设计风格,比较规范,但是代码量大,使用起来比较啰嗦;
用米做单位,1m = 30pix
功能强大,除了包含基本几何对象外,还包含杠杆、齿轮等复杂对象
在Android上有移植
一共74个文件
相关资料较多
碰撞更加精确
F、 设计建议
Box2D is designed for games, and speed, so it doesn’t always simulate physics accurately. Try to follow the following guidelines:
Don’t stand a large body on top of a small one, or other circumstances than involve passing a lot of force through a small body.
Don’t have long chains of joints, or large stacks.
Don’t expect perfect physics if you are updating something every frame (e.g. resetting a body’s position, or resizing a shape).
If in doubt, you can always increase the number of iterations passed into your call to Step - this improves the simulation quality, at the expense of speed.
G、 设计框架
主要概念: Body、Shape、Constraint、Joint、Joint Limit、Joint Motor、World
2、 APE
A、 地址:http://www.cove.org/ape/index.htm
http://ape.googlecode.com/svn/trunk/
http://www.cove.org/ape/quickstart_fb.htm
http://www.cove.org/ape/docs/api/org/cove/ape/package-detail.html
B、 最后更新日期:2007.06,0.5a版
C、 活跃情况:使用较多
D、 资源消耗:帧率30,机器人demoCPU峰值为24%(帧率为24,<7%)
E、 其他相关信息:
结构简单,功能较弱,只包含球、轮子、矩形块三种粒子,不过很多flash游戏中也只使用这些简单的粒子
如果有特殊用途,以此为基础进行扩展比较合适
像素为单位
可以贴图
一共23个AS文件
相关资料较少
速度快会穿透
APEngine大部分的操作都是静态的,而Box2D中的b2World需要实例化,因而Box2D可以有几个完全不同的世界,但是APEngine只有一个。
F、 设计框架
主要概念:APEngine、Composite、Group、Particle、Constraint
表一:机器人CPU消耗比较图
640*360 | APE(%) | Box2D(%) | 备注 |
CPU极值[24] | 6% | 7% | Core2 Duo 3G,2G内存 |
CPU平均值[24] | 98/20 = 4.9% | 102/20=5.1% | |
CPU极值[30] | 7% | 12% | |
CPU平均值[30] | 123/20= 6.15% | 145/20=7.25% | |
体积 | 16k | 49k |
3、 Flade
A、 地址:http://www.cove.org/flade/
B、 最后更新日期:2005.11后来演化出APE
C、 其他相关信息:暂不研究
4、 FOAM Rigid Body Physics Engine
A、 地址:http://blog.generalrelativity.org/?p=17,
http://code.google.com/p/foam-as3/
http://foam-as3.googlecode.com/
B、 最后更新日期:2007. 11
5、 Fisix
A、 地址:http://fisixengine.com/default.asp
B、 最后更新日期:官方站无法获取最后更新日期,最早Release在2006.12,官方Blog最后更新日期也是2006.12
C、 http://www.fisixengine.com/api/,代码量较少
6、 Motor
A、 地址:http://lab.polygonal.de/motor_physics/
http://lab.polygonal.de/2007/12/31/motor-physics-released/
B、 最后跟新日期:2007.12.31
C、 资源消耗:
D、 其他相关信息:
是haxe项目,以Box2D(c++)为基础做的一个2d物理引擎,针对Box2d的C++版本做了一些算法替换,设计上受到Box2d影响很大,使用方式上也和
Box2d比较类似;
采用世界坐标系,包括碰撞检测等都是在世界坐标系下进行的;
影响比box2dflash差很多;
资料较少;
7、 Ffilmation
A、 地址:http://code.google.com/p/ffilmation/,http://www.ffilmation.org/website, demo: http://www.ffilmation.org/mynameisponcho/
B、 目前还在更新
C、 资源消耗:demo1使用2个灯,有阴影,资源消耗峰值20%;demo2没有使用灯,使用较多素材,有阴影,峰值23%左右;demo3使用4个灯,有阴影,消耗峰值47%
D、 其他相关信息:
针对游戏开发的物理引擎,追求两个方面的目标:易用、高效;
和3d部分有交叉,实现了一些灯光和材质的渲染,但是实现的这些3d功能效果一般;
游戏地图拼接方面效果不太好,存在破面,会出现闪屏现象;
还存在一些视觉上的bug;
和Box2D与APE定位不同,Box2D和APE是纯粹的物理引擎,Ffilmation的定位是一个满足特定类型游戏的Lib;
摘要
The FFilmation Engine is an AS3 isometric programing engine, focused mainly on game development. The aim of the project is providing a robust development platform, where game designers can work on the game’s details and forget about the render engine. It is intended to be really usable from a “real production scenario” point of view. This means:
• Have a programming interface as small and easy as possible, no matter how complex the internal code is. From a software engineering point of view, the OO structure may not be as correct and clean as it could have been. It is not messy, but several decisions where made that improved performance and simplicity at the cost of breaking some “good OO programming” conventions.
• Rendering performance is a major concern when designing all the algorythms. Some of them have been rewritten 4 o 5 times from scratch until one fastest enought was found. If it doesn’t perform well, it is not usable. We’ve all seen several impressive actionscript demos that look really cool and invite to be used in your next project. But then if the effect takes 90% of your CPU, you can’t build anything on top of that.
• Graphic designers should be able to work on the application’s ( game or not ) environments without any programming skills, visually, and with almost immediate previews of what they are doing. Using the engine should be fun to some degree. If you have this terrific engine and adding a wall to your dungeon means you have to write 10 lines of OO gibberish, lazyness will eventually win you over. If art directors can draw and place the walls and lights an floors and enemies and see them appearing onscreen, you have more chances of reaching your deadline.
• Flash has built-in drawing and animation tools. You should be able to take advantage of them !!
All this is important because in reality projects depend on limited resources. Resources are money and time, but also the enthusiasm of indie developers or single individuals doing stuff “for fun” in their bedrooms. Projects, specially the “for fun” ones, have more chances of completion if the production process is gratifying to some degree.
(二) 3D物理引擎
1、 WOW
A. http://code.google.com/p/wow-engine
B. Demo:http://www.kongregate.com/games/buagaga/warship-strafe
2、 JIGLib
A. http://www.jiglibflash.com/
http://www.jiglibflash.com/blog/
http://www.flashbookmarks.com/demos/soccerballdance/
B. Support for Papervison 3D, Away 3D and Sandy 3D
目前网络上使用较多的2D物理引擎是Box2D和APE,其他引擎要么没有更新了,要么不成熟。
3D引擎本身受到3D引擎性能的影响,给出的demo本身消耗CPU比较严重,不实用,暂不研究。