Search form

'Building Interactive Worlds in 3D': The Donut Tutorial — Part 2

VFXWorld presents a new excerpt from Building Interactive Worlds in 3D by Jean-Marc Gauthier. This months excerpt is a tutorial on setting up a camera inside an interactive racetrack.

All images from Building Interactive Worlds in 3D: Virtual Sets and Pre-Visualization for Games, Film & the Web by Jean-Marc Gauthier. Reprinted with permission.

All images from Building Interactive Worlds in 3D: Virtual Sets and Pre-Visualization for Games, Film & the Web by Jean-Marc Gauthier. Reprinted with permission.

This is the latest in a series of excerpts from Building Interactive Worlds in 3D by Jean-Marc Gauthier.

Creating an Interactive Path

Please note that the Follow Path behavior can be found in the Virtual Sets, Resource Folder > Behavior Scripts, located on the right of the screen. You can access this behavior, and many other behaviors created in this book, from the companion CD-ROM. Open Virtools, go to the top menu, select Resources > Open Data Resource and select the file virtual sets.rsc on the CD-ROM. On the right side of the Virtools interface, select Behavior Graphs > Interactive Paths > Follow Path. This behavior was created earlier in section 2.1 of this chapter. You can refer to this section for more details about how to design this behavior. Although we decided to apply the behavior to a camera in this example, you can follow the same steps with other 3D objects or interactive characters. Go to Level Manager > Global > Camera, and drag and drop the Follow Path behavior on the word camera. The script is added under the camera named Path Camera in this example. Double click on the scripts name to open the Schematic window with the Follow Path script. Edit the Position on Curve with the name of the curve used as a path. When testing the scene you will notice that the camera follows the continuous curve without interruption. You may want to change the position and orientation of the camera on the curve. Stop the playback, and go to Initial Conditions. Select and move the camera to a new position. Select Initial Conditions for the camera and hit Play. The camera follows the curve with a new position and orientation. You can edit the direction of the camera by selecting the reference axis of the object following the curve. For example, if the camera moves forward along a Z-axis, it will move backward when you select the Z-axis.

The Follow Path behavior can be found in the Virtual Sets, Resource Folder > Behavior Scripts, located on the right of the screen.

The Follow Path behavior can be found in the Virtual Sets, Resource Folder > Behavior Scripts, located on the right of the screen.

Controlling the Cameras Speed on the Path

The viewer can control the speed of the camera. Please note that the Follow Path & Change Speed behavior can be found in the Virtual Sets, Resource Folder > Behavior Scripts, located on the right of the screen. Please note that this behavior was created earlier in section 2.3 of this chapter. You can refer to this section for more details about how to design this behavior. Open Virtools, go to the top menu, select Resources > Open Data Resource and select the file virtual sets.rsc on the CD-ROM. On the right side of the Virtools interface, select Behavior Graphs > Interactive Paths > Change Speed. Go to Level Manager > Global > Camera, and drag and drop the Follow Path & Change Speed behavior on the word camera. The script is added under the camera named in this example Path Camera. Double click on the scripts name to open the Schematic window with the Follow Path script. Edit the Position on Curve with the name of the curve used as a path. After setting up the Follow Path & Change Speed behavior scene, you will notice that you can accelerate and decelerate the camera by pressing the arrow keys on your keyboard.

Switching between Path Camera and Free Camera

The viewer can use the keyboard to turn a path camera into a free-range camera. We can add a new interactive behavior to the camera by switching between the camera scripts. Please note that the Free Camera script and the Switching Script script can be found in the Virtual Sets, Resource Folder > Behavior Scripts, located on the right of the screen. Please note that these behaviors were created earlier in section 2.4 of this chapter. You can refer to this section for more details about how to design this behavior. Go to Level Manager > Global > Camera, and drag and drop the Free Camera script and the Switching Script script on the word camera. The scripts are added under the camera named Path Camera. Double click on the scripts name to open the Schematic window with the Switching Script script. In the top line, edit the names of the Follow Path Camera and the Free Camera inside the Activate and Deactivate building blocks. After setting up the Switching Script script and the Free Camera script, you will notice that you can press the space bar on your keyboard to turn your path camera into a free camera and vice versa.

Creating Interactive Textures

The viewer can control and/or replace textures applied to the inner and outer rings with scrolling images or videos or by adding interactive blending in relationship with variations of the cameras speed. In this example, we use procedural textures with interactive behaviors described in detail in the chapter about interactive textures (Chapter 3).

Please note that the Background is a procedural texture created in the chapter about interactive textures. In Virtools, the Background texture and its behavior can be found in the Virtual Sets, Resource Folder > Textures Folder, located on the right of the screen. Before setting up the procedural texture, you need to drag and drop the Background texture in the 3D Layout window.

In Virtools, right click on the donut viewed in the 3D Layout window and select Materials from the drop down menu. The Materials Setup window opens in the lower part of the screen. Inside the Materials Setup window, select the Texture pull-down menu and replace the existing texture with a new texture called Background.

Adding an Additional Top View Helps to Keep Track of the Locations of Cameras on the Circuit

The viewer can follow the race with an additional top view created inside the screen. In Virtools, go to 3D Layout and select Top View. Create a new camera. In Level Manager, rename the camera Top View. The behavior Additional View can be found under Building Blocks > Interface > Screen. Drag and drop the behavior on the words Top Camera in Level Manager > Global > Camera. Double click on the script created under Top Camera. This will open the script inside the Schematic window. You can edit the placement and size of the additional top view inside the 3D Layout screen.

The viewer can follow the race with an additional top view created inside the screen.

The viewer can follow the race with an additional top view created inside the screen.

This tutorial helped you to design an interactive experience made of several parameters, textures, depths of field, speeds and camera angles that can change according to the viewers input. This simple scene can be reused in more complex projects for example, a car driving inside a virtual city.

Find more turnkey tutorials that detail all the steps required to build simulations and interactions in Building Interactive Worlds in 3D: Virtual Sets and Pre-Visualization for Games, Film & the Web by Jean-Marc Gauthier: Focal Press, 2005. 422 pages with illustrations. ISBN 0-240-80622-0 ($49.95). Check back to VFXWorld frequently to read new excerpts.

Jean-Marc Gauthier teaches at New York University in the graduate studies department of Interactive Telecommunications and is the author of Interactive 3D Actors and Their Worlds (Morgan Kaufmann Publishers 2000). He is also a consultant at www.tinkering.net and an award-winning 3D artist.