Graphics Programs Reference
In-Depth Information
59
60
61
62
63
64
65
// display the 3d objects in the picture plane
function displayObj()
{
// restrict the viewer z-movement
if (viewer.z < -1000 ) { viewer.z = -1000 }
if (viewer.z > 700 ) { viewer.z = 700 }
Also in the displayObj() function, you might notice that it contains lines of code that
restricts the viewer's x- and y-movement (lines 66-72). Since we are currently deal-
ing with rotation rather than translation, these lines can be deleted or commented out.
Alternatively, you could put some limits on the viewer rotation.
Tip: What changes would you have to make to the script to put the rotation under the
control of the horizontal position of the cursor? The challenge is to keep the rotation
from increasing so quickly that the user is not able to easily control it. Some options
include increasing the value of viewerSpeed , or alternatively, using the square of the
viewerSpeed such as in the expression below:
viewer.ry += (_xmouse - scene3D._x)/(viewerSpeed*viewerSpeed)
Background Considerations
If we look back at the examples in Chapter 6 and this chapter, most of them have
backgrounds that fall into one of two categories. A number of them are placed on back-
grounds that have an implied, but not clearly defined, horizon line. Examples that fall
into this category are illustrated in Figure 7.29. The background on the left has only a
suggestion of three-dimensional space, while the background on the right is presented
as an actual space. In these cases, the backgrounds are intended to be visually consis-
tent with the objects in the foreground, but they are typically far away from the objects
and do not interact with them.
The other type of backgrounds are those that provide a visual backdrop for the fore-
ground objects and that thematically complement the subject matter but are not meant
to suggest that they are in the same 3D space as the foreground objects. They are
clearly defined, but like the examples above, they are intentionally constructed in such
a way that they do not interact with the objects in the foreground. The objects move,
scroll, rotate, and zoom relative to one another but not to the background.
 
Search WWH ::




Custom Search