| How well does
Macromedia Flash do 3D?
"More and more Flash developers are catching
on to the power of 3D. Adding 3D effects to Flash
movies can help spice up a navigation system,
make impressive eye candy, or simply entertain
viewers. In fact, the use of 3D in Flash has increased
over the last few years: The trend began at front-running
Web sites such as www.yugop.com and www.mano1.com,
and has just kept growing.
"But Flash is a 2D software program-it doesn't
support 3D models. How, then, can you create 3D
animation in Flash? Easy: You fake it.
"There are two ways to create the illusion
of 3D shape and motion: ActionScript 3D, in which
you code the entire project, and Rendered 3D,
in which you use third-party rendering software,
Flash, and some ActionScript. This chapter will
discuss these two very different methods."
Understanding the mathematics of perspective
"Perspective helps you differentiate between
3D and 2D. Perspective is that omnipresent bend
of the world that positions things in relation
to their distance from you. If you stand in the
middle of a road, looking down it as far as possible,
you'll see that the road's edges begin to come
together. Depending on how far you can see, the
edges will appear to move infinitely closer to
each other until they converge. Perspective also
affects how movement is perceived. For example,
even if objects in the foreground and back-ground
are moving at the same speed, those in the foreground
will appear to move more quickly."
Changing ordered triplets into ordered pairs
"The perspective problem boils down to something
simple. You have an ordered triplet of a point,
(x, y, z), and you want to find where that point
would be placed on your screen if it didn't have
a z-position. Because your computer screen doesn't
have a z-axis, you must find a way to change the
ordered triplet into an ordered pair while taking
into consideration the point's z-position. The
easy way is to merely drop the z value, but if
you do that, the road's edges will never converge.
Instead, they will remain parallel as the road
goes off into the distance."
The authors solve this problem using some simple
geometry. They derive a "crucial equation
for perspective" and show a script that puts
this equation into practice.
"The following script is placed in the clip
events of a movie clip. (The movie clip can be
anything that you want to duplicate many times
and place in space randomly.) The script will
give the movie clip a random ordered triplet between
-100 and 100, and then calculate the point's position
as it appears on screen."
|