One of the advantages of creating a 3-D scene is the ease that they can be viewed from different angles and positions. The Translate and Rotate commands let you set the position from which you view the scene.
In addition, you can use the ArcBall command to enable the user to change the viewing angle interactively.
You have actually seen the Translate command in earlier sample scripts. It sets the position from which the scene is viewed. The arguments give the amount to move from the current position in the x, y, and z direction.
The Rotate command is used to modify the viewing angle of a scene. It has the following format.
Rotate (degrees, xAxis, yAxis, zAxis)
This rotates by degrees around the axis described by the vector (xAxis, yAxis, zAxis). For example, to rotate a model 90 degrees about the x-axis, use Rotate( 90, 1, 0, 0 ).
Note: The Rotate command uses degrees, in contrast to JMP’s trigonometric functions, which use radians.
Translate and Rotate are also used to position objects with respect to each other. The first Translate or Rotate can be thought of as positioning everything that follows with respect to the camera. Subsequent Translate and Rotate commands are used to position objects, such as spheres, cylinders, disks, and display lists in Call List and ArcBall commands. For example, suppose you have a display list named table and another named chair. Your scene might look like this:
Using Translate and Rotate
The following example uses the Rotate command inside a For loop to continuously change the viewing angle of a scene. It draws a cylinder that swings around a central point. This central point is shown by a small sphere.
Rotating a Cylinder
Note the use of the Update command at the end of the scene messages. This command tells JMP to make the displayed screen agree with the current state of the display list. It is important to clear the list at the beginning (so the list does not contain the old angles as well as the current) and update the scene after each change.
The Look At command is an alternative way to set the camera view.
Look At( eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ )
The Look At command puts the camera at the eye coordinates and points it toward the center coordinates. The up vector describes how the camera is rotated on its line of sight. Because the model is typically constructed at the origin, a JMP scene should have either a Look At or a Translate command near its beginning to move the camera away from the origin.
Note: If you use the ortho2d projection, you should not also set the camera position using either Translate or Look At.
Finally, use either Translate or Look At to set the camera position:
An ArcBall creates a sphere around the 3-D scene and enables the user to click on the sphere’s surface and drag it around, thus causing the scene to rotate.
Use an ArcBall instead of a CallList command to place the scene in an ArcBall. Scenes that are attached to an ArcBall automatically respond to clicks and drags of the mouse. Custom programming is not needed. However, rotations made in the arcball are not saved. (Technically, the ArcBall is surrounded by an implicit Push Matrix and Pop Matrix block, so the movements are gone after it returns. See Using the Matrix Stack for details of pushing and popping.)
Note: ArcBall comes from an article by Shoemake (1994) found in Graphics Gems IV, published by Academic Press.
This sets the display so that the ArcBall is always showing. Click and drag on the ArcBall to rotate the scene. The popup menu with Background Color, Use Hardware Acceleration, and Show ArcBall is always available, whether the scene is displayed through a platform, in a journal, or through JSL.
where state is During Drag, Always, or Never.
Showing the Arc Ball