(Flash) 3D related objects and methods

| No Comments | No TrackBacks
I haven't been really caring about Flash Player 10's 3D functions so far.
I mean to give them a try for a while just for a study.

As a first attempt, I made an example of applying effect of light by computing the angle between the plane surface and the light.

To determine the angle of the plane, two vectors that represent the two sides of it are needed. The cross product, which is a vector perpendicular to the both of the vectors, can be calculated using the formula below.

Vector3D object provides convenient methods to do this process, crossProduct() and angleBetween(), which returns a cross product of two vectors and angle between two vectors, respectively.

I also used Matrix3D class to rotate the plane. This class is especially useful when applying a complex translation, or applying a same movement to a number of objects.



sample movie and scripts


cross product

A×B = [(a2 * b3 - a3 * b2) * (a3 * b1 - a1 * b3) * (a1 * b2 - a2 * b1)] 

for any two vectors A = [a1 a2 a3] and B[b1 b2 b3]

No TrackBacks

TrackBack URL: http://www.kynd.info/cp-bin/mt/mt-tb.cgi/90

Leave a comment