Graphics Programs Reference
In-Depth Information
At this point, we are ready to begin drawing. The border of the planes is set to an
opaque blue (line 182) while the interior will be filled with a 10% blue (line 183). For
each plane, we will moveTo() the first point and then use lineTo() to draw the lines
around the plane (lines 185-189) and finish the job with an endFill() .
Step 4: Update the object
The only thing left to do is make a one-line change inside the onEnterFrame handler to
reflect the substitution of the drawPlanes() function for the drawLines() function.
198
199
200
201
202
203
this.onEnterFrame = function()
{
findTheCenterPoint();
getScreenCoords();
drawplanes();
}
This completes the exercise. Save your movie as 9_4_3DplanesDONE.fla and test it.
Removing Hidden Lines
Now that we have objects defined in terms of their planes, it is time to get rid of planes
that can't be seen. This will require a little more coding and some geometry. If you
want to see where the gory details are heading, open 9_4_3DsolidsDONE.swf in the
Chapter 9 folder.
Step 1: Getting started
We'll use 9_4_3DplanesDONE.fla as our starting point. We will need an additional array,
b , which we'll call the boundary matrix since it will be an array that holds other arrays
within it. The data it will contain consists of vectors that are perpendicular to each of the
planes of the object.
23
24
25
26
27
// define the 3D and screen coordinate arrays
xs = []; // the screen x-coordinates of the shape
ys = []; // the screen y-coordinates of the shape
b = []; // the boundary matrix of normal vectors
 
Search WWH ::




Custom Search