Monday, March 30, 2009

Papervision 3D + APE Physics Engine, Mouse Forces tweaks.

After some diaper changes, a few baby bottles and a couple of trips to the day care, I was able to implement some needed logic to the spheres model. Here's what I added/changed this time around:

- Calculated the mouse speed and added it into the calculations of the "onOver" force. In this version, the force generated at the collision between mouse and sphere, is proportional to the instantaneous mouse speed at that moment (an the mass of the sphere as well, but this is taken care of by physics engine (APE).

- Played around with various parameters so that the overall movement ends up like I wanted it to.
APEngine.init(1/3);
APEngine.damping=0.98;
CircleParticle.mass = 3
CircleParticle.elasticity=0.4 (this one might be too high)
CircleParticle.friction=0.1
CircleParticle.multisample = 4 (might have to reduce this for performance)
The multisample value is the amount of times the engine checks for collision in each step of the engine.

- Added calculations to reduce the magnitude of the resulting mouse collision velocity vector if the sphere is already moving in the same direction as the mouse. If not, every mouse collision would generate a force as if the sphere was static which results in a bigger force.

Here is the result, view it full screen here for a better experience:





Thanks Axel Bunge, Sebastián Pisa, Esteban Rodriguez, Cesar Cintron & Facundo Gamallo for the feedback.

No comments:

Post a Comment