Datasheet

Chapter 1: Understanding Flash3D
15
Using the Big 3
Fundamental to 3D graphics and physics are three fundamental motions: translation, rotation and
scaling. All motions (at least for Newtonian motion) can be broken down into combinations of these
three motions.
You can apply these 3D transformations all at once using a Matrix3D object. You can rotate, scale, and
then move an object by applying three separate transformations or more efficiently by using one
Matrix3D transformation. It ’ s important to remember that these matrix operations aren ’ t generally
commutative: which means that applying a rotation and then translation won ’ t necessarily give the same
results as applying the reverse order (a translation then rotation). The following code snippet shows
how to cascade a series of transformations: rotation, scale, translation, and then rotation again.
var matrix:Matrix3D = myDisplayObject.transform.matrix3D;
matrix.appendRotation(45, Vector3D.Y_AXIS);
matrix.appendScale(2, 1, 3);
matrix.appendTranslation(10, 150, -300);
matrix.appendRotation(10, Vector3D.X_AXIS);
myDisplayObject.transform.matrix3D = matrix;
Performing difficult matrix maths is unnecessary . . . that ’ s great news! Adobe has made it pretty easy to
do this just by applying the simple transformations shown above. And in many cases it ’ s done
automatically without the user even knowing it ’ s being performed. Consider translation, for example,
when you explicitly set the z property of a display object to a numeric value, the object automatically
creates a 3D transformation matrix. It all happens behind the scenes giving you more time to
concentrate on building stellar 3D experiences.
Translation
Adding a native z coordinate, in Flash 10, enables you to treat z just as you ’ ve treated x and y in the past.
But using translation doesn ’ t just mean you ’ re traveling in a straight line. You can use z to constrain an
element to a 3D trajectory path. As an example, consider a parametric path on a 3D surface such as
a torus.
The parametric curves for a torus (and any other 3D surface) can be found at WolframMathWorld
( www.mathworld.wolfram.com ).
So what ’ s a parametric equation?
Parametric equations are a set of equations that define the coordinates of the dependent variables
(x, y and z) of a curve or surface in terms of one or more independent variables or parameters. That ’ s a
mouthful, but basically if you iterate over the range of your parameters (of the parametric equation)
your torus will be plotted in 3D space. This is a very useful device as it gives you the vertices of your
torus, and in Appendix A the parametric equation for a number of 3D objects are given.
c01.indd 15c01.indd 15 12/14/09 3:03:28 PM12/14/09 3:03:28 PM










