0
点赞
收藏
分享

微信扫一扫

ape之APEngine


看看前一篇文章的代码都有些什么?

AKA,APEngine是ape的核心类。提供了一系列静态方法用来操作ape。

看看api中都说些什么:

init()方法,初始化引擎。你必须在添加particles或constraints之前调用这个方法。

init(dt:Number = 0.25),有一个参数dt表示时间增量(delta time),(未完

)通常值为1/3或1/4。

较低的值导致较慢,但可以更准确的模拟,更高的导致更快、但不准确。


查看一下APEngine的属性,如下:


//

//getter/setter方法

//


damping:number,阻尼,全局的阻尼,值应该在0-1之间。更高的数字导致更少的阻尼。值1时没有阻尼。当值为0时将不允许任何粒子的移动。缺省值为1。

constraintCycles:int,确定约束和粒子在一个单一的APEngine.step()循环的次数的限制并校正他们的位置。增加这个数字可能导致更硬,更稳定的配置的限制,尤其是当他们在大型复杂的场景中。你要权衡一下越高的数值你设置,性能将会越受影响。

constraintCollisionCycles:int确定约束和粒子在一个单一的APEngine.step()循环的次数的限制并校正他们的位置。这可以极大地增进稳定和防止突破,尤其是大型复杂的安排的约束和粒子。更大的这个数字,更稳定的仿真,在一个以性能为代价。

container默认的容器使用默认的绘画方法的粒子和约束。如果您希望使用内置的绘画方法必须先设置该项。



addForce()和addMasslessForce()的区别:

addForce()方法模仿的是一种近似于风的效果。

addMasslessForce()模仿类似于重力的效果。


*addForce()和addMasslessForce()有一个参数v;

v代表的是一个向量象征添加的力。【A Vector represeting the force added.  】

/

addForce()

Adds a force to all particles in the system. The mass of the particle is taken into account when using this method, so it is useful for adding forces that simulate effects like wind. Particles with larger masses will not be affected as greatly as those with smaller masses. Note that the size (not to be confused with mass) of the particle has no effect on its physical behavior.


addMasslessForce()

Adds a 'massless' force to all particles in the system. The mass of the particle is not taken into account when using this method, so it is useful for adding forces that simulate effects like gravity. Particles with larger masses will be affected the same as those with smaller masses. Note that the size (not to be confused with mass) of the particle has no effect on its physical behavior. 

/



Calling this method will in turn call each particle and constraint's paint method.

 Generally you would call this method after stepping the engine in the main program cycle.

paint()方法,调用这个方法也将会调用每个粒子和约束的绘制方法。通常你需要调用这个方法在进入主程序引擎循环之后。



The main step function of the engine. This method should be called continously to advance the simulation. The faster this method is called, the faster the simulation will run. Usually you would call this in your main program loop. 

step()方法,引擎的主要(阶梯)函数。此方法不停的推进模仿。越快的调用这个方法,越快的模拟将运行。通常你调用这个方法在主程序的循环中。


addGroup()方法。








举报

相关推荐

0 条评论