Graphics Programs Reference
In-Depth Information
The basic idea is that when the dot product is positive, the normal vector is pointing
towards us and the plane is visible. If the dot product is negative, the normal vector is
pointing away from us and the plane is invisible.
Step 4: Test for hidden planes
The function hiddenPlaneTest tests each plane to see whether it is hidden from the
viewer. If it is, a flag is set to 1 so that the plane isn't drawn later. This test uses the
values that have been stored in the boundary matrix.
Step 5: Modify the drawPlanes function
The only change needed in the drawPlanes function is to add a test that looks at the
flags generated by the hidden plane test. If the flag for any given test is 1, the visibility
for that plane is set to false, and it isn't drawn.
Step 6: Update the object
The last step is to update the object using the onEnterFrame handler. As before, calls
to each of the functions are placed in order.
283
284
285
286
287
288
289
290
291
this.onEnterFrame = function()
{
findTheCenterPoint();
createBoundaryMatrix();
testBoundaryMatrix();
hiddenPlaneTest();
getScreenCoords();
drawPlanes();
}
Exercise 9.5: Planes of Different Colors
In this exercise, we will extend the capabilities of our hidden line program to include
assigning different colors to the planes of an object. We will also see how we can
substitute other kinds of user interaction for the buttons.
Step 1: Getting started
Open 9_4_3DsolidsDONE.fla in the Chapter 9 Completed_Exercises folder. The first
thing we need to do is to assign some colors to the planes of the object. Let's place the
information in the same location as numPts and numPlanes . Since the planes array is
Search WWH ::




Custom Search