Graphics Programs Reference
In-Depth Information
and moveTo that point (line 179). We then get the screen coordinates of the ending
point and draw a line to that point (line 180). That's all there is to it. Save your movie
as 9_3_3DlinesDONE.fla and check to make sure that everything works as it should.
With a few simple changes, we went from planar 2D shapes to 3D solids.
Exercise 9.4: Modeling Solids with Planes
One major drawback of the previous exercise is that we see lines that normally would
not be visible in a solid object. We want to move toward removing those lines. To do
this, we need to look at the object in terms of the planes that define the object rather
than the lines.
Step 1: Getting started
Open 9_4_3Dplanes.fla in the Chapter 9 folder. This file is a copy of the completed
Exercise 9.3. We'll use it to convert from 3D solids with lines to 3D solids with planes.
The object in this exercise is a cube as shown in Figure 9.14. The data has already been
created for you and saved as cubeData.as . The format of the data is a little different
than in the previous exercise. We enter the coordinates of the object's corner points
into the x , y , and z arrays at the outset. We are also defining a planes array. Each ele-
ment of this array is an array that contains the corner points of one of the planes of the
object, entered in a counterclockwise direction as you are facing the plane.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// initialize data
x = []; // the x-coordinates of the object
y = []; // the y-coordinates of the object
z = []; // the z-coordinates of the object
planes = []; // planes that define the object
// define the corner points
x = [ -50, 50, 50, -50, -50, 50, 50, -50 ]
y = [ 50, 50, -50, -50, 50, 50, -50, -50 ]
z = [-100,-100,-100,-100 , 0, 0, 0, 0 ]
// points defining the planes of the object
planes = [ [0,1,2,3], [1,5,6,2], [5,4,7,6],
[4,0,3,7], [4,5,1,0], [3,2,6,7]
]
Search WWH ::




Custom Search