3D Animation Workshop: Lesson 76: Interactivity in Shout3D | WebReference

3D Animation Workshop: Lesson 76: Interactivity in Shout3D


Lesson 76 - Interactivity in Shout3D - Part 2

In conventional pre-rendered animation, you time motion based on the intended playback device. Standard videotape (NTSC) plays at 30 frames per second and film runs at 24 fps. Thus if you want an object to move from Point A to Point B in one second, you would create 30 frames for video and 24 for film. But for realtime work, you need to fix the length of the animation in time, rather than frames, and let the renderer do the best it can with it. In our example, you might set the animation to run in one second. The realtime player will produce the entire movement in one second, but the number of frames will vary, depending on the rendering frame rate. A player running at 30 frames per second will produce a smooth result by producing 30 frames during the one-second segment. A slower player at 10 fps will produce a less smooth result by dividing the motion into only 10 frames over one second. But either way, the animation will be accomplished in 1 second. Those readers with a VRML background will be familiar with this idea already.

Thus the issue of interactivity in Shout3D involves consideration of how mouse and keyboard input can be used in the special context of a 3D realtime rendering engine. Considerable insight is possible by studying the Suit demo, seen in the last lesson and repeated below. The Shout3D 1.0 package will offer the source code for this and a number of other demos.

There are four kinds of responses to user input in this example. Left-clicking and dragging the mouse horizontally rotates the suit. Right-clicking and dragging the mouse vertically moves the suit forward and backward in the world space of the scene. Pressing the two arrow buttons rotate the suit rapidly in the selected direction. If the mouse buttons are not pressed, the suit rotates slowly.

To achieve this result, the basic Shout3DPanel class is extended to create a new Panel class called Suit3DPanel. (The Panel class provides a 3D viewing space in the applet.) The underlying Shout3DPanel class contains only the renderer, without interactivity. The only code needed in extending it to the Suit3DPanel is that which is needed for the interactivity. The Suit3DPanel class is essentially composed of three units. First, there is an initialization function that sets everything up before responding to user input. Second, there is a function that determines what user input has occurred. Finally, there is a function that instructs the renderer what to render, based on the user input. This is, of course, a simplification that will not please the sophisticated programmer, but is an accurate picture for the newbie.

To Continue to Part 3, or Return to Part 1, Use Arrow Buttons

Created: Sept. 26, 1999
Revised: Sept. 26, 1999

URL: https://webreference.com/3d/lesson76/part2.html