Graphics Programs Reference
In-Depth Information
54
55
56
57
// set the size as a percent of its distance ratio
thisObj._xscale = thisObj.xscale * dr;
thisObj._yscale = thisObj.yscale * dr;
Save and test your movie. There should be a very noticeable difference in the appear-
ance of the rocks from the changes we have made. We will put just a few finishing
touches in the next step, and we'll be done.
Step 5: Add finishing touches
We'll complete this exercise by including a few additional items to enhance the overall
effect. For example, from our discussion of aerial perspective in Chapter 2, we would
like to have objects farther away from us appear darker than objects close to us. Since
the rocks are appearing on basically a black background, we can easily get the effect
we want by varying the alpha of each rock.
The fundamental variable that we have relating to distance from us is the distance ratio.
An obvious choice would be to set the alpha to 100 times the distance ratio to give us
values between 0 and 100. While this works, visually it seems to take too long for the
rocks to get bright, so we will increase the alpha by 200 times the distance ratio as
shown below. Note that we can get better and more sophisticated results by using the
color transform operator, but this is simpler and meets our need.
We can create more interesting rock motion by having each rock rotate a little as it
moves. We'll increment by 2 degrees each time through the loop. Add the following
lines after line 56.
54
55
56
57
58
59
60
61
62
63
64
// set the size as a percent of its distance ratio
thisObj._xscale = thisObj.xscale * dr;
thisObj._yscale = thisObj.yscale * dr;
// relate the object's alpha to the distance ratio
// for aerial perspective
thisObj._alpha = 200 * dr;
// add some rotation to each object as it moves
thisObj._rotation += 2;
 
Search WWH ::




Custom Search