Wednesday, April 8, 2009

Papervision 3D, ShadowCaster tweaks and ColorMatrixFilter Animation

In this version I "modified" (hacked would be a better word) Andy Zupko's ShadowCaster class because of the problems I was having using it (see my previous post):

Fixed (or hacked really) my problem with the non perFaceCasting, that is using the ShadowCaster.castBoundingSphere() method. My problem was that the shadow was being affected by the rotation of the sphere (see my previous post), so I changed the following in the ShadowCaster class:

var dx:Number = r2d.x-c2d.x;
var dy:Number = r2d.y-c2d.y;
var rad:Number = Math.sqrt(dx*dx+dy*dy);

var dx:Number = r2d.x-c2d.x;
var dy:Number = r2d.y-c2d.y;
var rad:Number = b.radius/1.1

Divided by 1.1 to make the shadow a little smaller than the radius. It’s not accurate but it works and hopefully somebody will address this in a more professional/consistent way.

I also added some some behavior to the mouse and collision events. For now just animated color using ColorMatrixFilter.

Bigger, stand-alone version here.

I also debugged the mouse generated forces (Ad nauseam) because I found some problems with it. Thanks Cesar Cintron for the feedback. A brief explanation is that I was canceling events from being dispatched by the mouse on the wrong side of the sphere. This happened when the mouse movement was very fast and so the event was dispatched late when the mouse had already passed the center of rotation and thus fired on the wrong side of the ball, making it shoot very fast in the opposite direction from that of the mouse movement.

No comments:

Post a Comment