Datasheet

8
Part 1: Getting Started
The curve above is very similar to the gravitational or electrical potential curves found in physics. And it
further suggests that a size scaling force field could be constructed by taking the differential of the
scaling equation. But that ’ s beyond the scope of this book.
Rendering to the Screen
Using perspective scale you ’ ve picked up a 3rd dimension: z. But in order to render it to the Flash Stage
you ’ ve got to get rid of it again. The process is called rendering and occurs by projecting a 3D object
(created from perspective) to a 2D computer screen (or viewport).
Projection onto the Flash screen requires that you convert a 3D point (x, y, z) into a 2D (x, y) point. You
accomplish this by using scaling to drop the z coordinate. A change in z affects the position and size of
an object in 3D space as shown in the code below:
scale=focal length/(focal length + z);
x=x*scale;
y=y*scale;
xscale=yscale=scale*100.
In the code, the scale (based on focal length and z) changes the x and y position and the x and y scale,
resulting in a 2.5D effect described earlier. And it ’ s done the same way in Papervision3D. Throughout
this book, you ’ ll be drilling down into Papervision3D ’ s classes and examining how it does what it does.
Below is a code snippet taken from its
Camera3D class.
z
as z > infinity, scale > 0
as z > fl, scale > infinity
z fl is a singularity at vanishing point
Inversion
z 0
1
1/2
scalez fl
z fl
Figure 1-4
c01.indd 8c01.indd 8 12/14/09 3:03:25 PM12/14/09 3:03:25 PM










