Graphics Programs Reference
In-Depth Information
36
37
38
39
// calculate the min & max y-values for the ellipse
ymin = yc - yr;
ymax = yc + yr;
Finally, once we have determined the object's position, we need to scale it according to
where it is located. This is a somewhat complicated expression. We start the _yscale
at minSize and add to it the proportion of how far it has moved from its minimum ver-
tical position compared with how far it can move. We multiply this latter value by (100
- minSize ) to get the correct scale. Once this is known, we must also set the _xscale
to the same amount to scale things up uniformly.
40
41
42
43
44
45
46
// calculate the size based on its current y-value
// the maximum size is 100% of the original size
object_mc._yscale = minSize +
(object_mc._y - ymin) * (100 - minSize)
/(ymax - ymin);
object_mc._xscale = object_mc._yscale;
}
As a check, when object_mc._y = ymin , the scale is just minSize . Also, when
object_mc._y = ymax, then
object_mc._yscale = minSize + (ymax-ymin)*(100-minSize)/(ymax-ymin)
= minSize + 1*(100-minSize) = 100
If you find this expression confusing, don't worry. In actual 3D, all this becomes very
simple. Save your movie as 5_6_vaseRotating.fla and test it. The visual effect
should be more realistic-looking with the object changing size as it orbits. Try different
values of minSize with different elliptical shapes.
Circles in Perspective
Without actually coming out and formally stating it in so many words, what we have
done so far is to start with circular motion in the vertical x-y plane, and then we cre-
ated the illusion of rotating the circle onto the horizontal x-z plane by vertically scaling
it into an elliptical shape.
 
Search WWH ::




Custom Search