Tuesday, April 14, 2009

Papervision 3D + physics engine.

I've done several updates to the model which I haven't posted about. They are:

- Got rid of ShadowCaster.
- Added click behavior.

The reason I had to eliminate ShadowCaster was because it was downgrading performance too much when the stage was big. Because I am working with full screen stage it was a big issue.

Thanks to Andy Zupko who recommended a better alternative for shadows for what I was trying to do, and even provided the logic for calculating positioning based on light and sphere position. The new version has a plane with blurred circle baked texture material per sphere. Positioned at the bottom of the sphere and with the following logic from Andy to calculate position:

var vector: Number3D = new Number3D(m.x - light.x, m.y-light.y, m.z - light.z);
var spherePos:Number3D = new Number3D(m.x, m.y, m.z);
vector.normalize();
vector.multiplyEq(m.radius);
vector = Number3D.add(vector, spherePos);
this.position = vector;
m being each marble (sphere), and light, well... the light :s.

This runs on every frame as well because as the position of the sphere relative to the light position changes, so does the shadow obviously.



You'll also notice that I added onClick event handler as well finally. More on that on my next posting.

Oops! spheres too big? Visit the bigger site here.

Cheers!

No comments:

Post a Comment