You are on page 1of 16

Director 8.

5 3D tutorial for
Director users
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Introduction
This tutorial is designed as an introduction to the Director 8.5 3D features for
users who are already familiar with the basic functions of Director. It will
familiarize you with the differences between 3D cast members and other cast
members. In addition, it demonstrates some of the tasks you’ll perform when
using 3D models in Director.

What you should know


Before starting this tutorial, you should have some knowledge of the basic
workings of Director. When discussing procedures for working with 3D cast
members, this tutorial assumes that you know the basics of Lingo and how to
perform many of the more common tasks in Director. If you are not yet familiar
with the main features of Director, see the chapter “Director 8 Tutorial” in the
Using Director manual or the Director Help.

What you’ll learn


This tutorial will introduce you to the special characteristics of 3D cast members.
You will also practice some of the common tasks you’ll perform when working
with 3D graphics in Director.

Download the tutorial movies


Click the link at the beginning of this tutorial to download the tutorial files. You’ll
find a starter Director movie called 3D Tutor for Dir User Start.dir, the completed
tutorial movie, and a 3D file called Orb.w3d.

1
Work with 3D cast members
The tutorial start movie contains a simple bitmap cast member and a simple
Lingo script. Bitmap cast members are a good example of the simpler types of cast
members that Director can use. They don’t have a very large number of properties
to set or keep track of—unlike 3D cast members, which have a multilayered
hierarchy of properties.
A 3D cast member contains a representation of 3D space, called a 3D world. A
3D world can contain any number of 3D models. These are the things you see
when you view the world. Models are similar to Director sprites, in that each
model uses a model resource, just as each Director sprite uses a cast member. The
model resource contains the mathematical geometry that defines the shape of the
model or models that use it.
Most models in the 3D world have shaders assigned to them. Shaders contain
information that defines the surface appearance of the model. Each shader may
have textures assigned to it. Textures are 2D images that are drawn onto the
surface of the model. All of these items exist as parts of the 3D world. Models that
form parts of a larger model, such as the body and wheels of a car, can be linked to
one another so they are easier to move as a single unit. These sets of linked models
are called groups.
In addition, a 3D world can have multiple cameras, lights, and other objects
within it. Each of these objects has many properties that you can control.
Director provides two ways of looking at the properties and contents of 3D cast
members: the Shockwave 3D window, and the Lingo scripting language.

2
Import a 3D cast member
Once you’ve created a 3D model in 3ds max or another modeling application and
exported it into the W3D (Web 3D) format, you are ready to import it into
Director.
In the same directory as the tutorial starter movie, you should find a W3D file
named Orb.W3D. Now you’ll import that file into the start movie.
1 Open the 3D Tutor for Dir User Start.dir movie.
2 Choose File > Import from the Director menu bar.
The Import Files into “Internal” dialog box opens.
3 Navigate to the directory containing this tutorial and select the file named
Orb.W3D.
4 Click the Add button.
The Orb.W3D file appears in the file list in the bottom half of the Import Files
into “Internal” dialog box.
5 You can choose whether to import 3D cast members as linked files or to import
them completely into your Director file.
When you select Link to External File during import, it is very important that
you not move the file you are importing after the import is complete. Doing so
breaks the reference to the file, causing Director to ask you for the new file
location.
Select Link to External File from the pop-up menu at the bottom of the dialog
box. This tells Director to create a reference to the Orb file rather than
importing its contents entirely into Director.

The Import dialog box

Director 8.5 3D tutorial for Director users 3


6 Click the Import button.
Director completes the import and opens the Cast window.
7 Choose File > Save to save the changes to your Director movie.

Use the Shockwave 3D window


Now that you have imported a 3D cast member, you can view it and manipulate
some of its properties in the Director Shockwave 3D window.
• To view the Orb cast member in the Shockwave 3D window, double-click it in
the Cast window.
The Shockwave 3D window opens, displaying the Orb cast member. The
cast member contains a model of a sphere with the word Macromedia
written across it.

The Shockwave 3D window displaying the Orb cast member

The Shockwave 3D window contains tools for modifying the camera position in
the 3D world. You can move the camera in three different ways: panning,
rotating, and dollying.
1 To pan the camera from side to side, click the Pan Camera button on the left
side of the window. Drag in the window to pan the camera and observe the
changes to the view of the models in the world.
2 To rotate the camera, click the Rotate Camera button and then drag in the
window. Hold down the Shift key to constrain the rotation to only the Z axis.
3 Use the Camera Y Up and Camera Z Up buttons to control whether the Y or Z
axis is the up axis when you use the Camera Rotate button.

4
4 To dolly the camera toward and away from the models, click the Dolly Camera
button and drag in the window.
5 After you’ve moved the camera using these buttons, you may want to return it
to its original location in the world. The position of an object in 3D space is
called its transform. To reset the camera’s transform, click the Reset Camera
Transform button. You can think of the little house on the button as the
“return to home position” symbol.
6 To set a new value for the camera’s transform, click the Set Camera Transform
button after you’ve moved the camera to the new position you want.
The new transform will be set in memory.

Exert more control with Lingo


As you can see, the Shockwave 3D window is good for viewing the contents of a
3D cast member and moving the world’s primary camera. However, if you want to
view or control more of the properties of your 3D cast member, you’ll need to use
Lingo.
Lingo has been designed to be easy to learn. The next sections will take you
through some tasks that will allow you to control the playback of your movie,
move objects in your 3D cast member, and view the values of properties of your
3D cast member. To learn more about Lingo in general, see the chapter “Writing
Scripts with Lingo” in the Using Director manual or in Director Help.

Make a 3D sprite
Next, you’ll make a new sprite on the Stage with the 3D cast member.
1 Rewind your movie.
2 Click in the Cast Window or open the Cast window if it is not already open.
3 Drag the Orb cast member from the Cast window to the lower left corner of
the Stage.
4 Click in the Score window or open the Score if it is not already open.
A new sprite has been created. It appears in the Score in channel 1, frames
1 to 28.

Director 8.5 3D tutorial for Director users 5


Add a button of your own
Now that your 3D sprite is on the Stage, you can add some interactivity. You’ll
add a button that will move the camera in the world. Keep in mind that moving
the camera makes the objects in the world appear to move, because the camera’s
perspective changes.
Each sprite you make on the Stage from a 3D cast member represents a single
camera’s view into the 3D world. A 3D cast member can have many cameras in it,
but each sprite usually displays the view from only one camera at a time. The
button you’re going to add will move the camera that the Orb sprite in channel 1
is using.
1 Click the Rewind button in the Control Panel.
The playback head returns to frame 1, ensuring that any new sprites you create
will start in frame 1.
2 The Tool palette should already be open. If it is not, choose Window > Tool
Palette to open it.
3 Click the Push Button tool in the Tool palette.

4 In the lower right corner of the Stage, drag to draw a rectangle for your new
button.
When you release the mouse button, your new button has a text insertion point
in it. The button is now in edit mode, waiting for you to give it a name.

6
5 Type the following:
Camera X+10
When you are finished with this button, it will move the camera along the X
axis in increments of 10.

6 Click outside the button to exit the edit mode for the button.
You’ve successfully added your first button. Now you’ll add some Lingo to it to
make the camera move.

Add a script to the button


Now you’ll add a script to the button’s sprite that will make the camera move
inside the 3D cast member.
1 Click in the Cast window or open the Cast window if it is not already open.
A new button cast member has been created. When you make buttons and
other cast members by using tools from the Tool palette on the Stage, a new
cast member is made at the same time. The sprite you made on the Stage is
actually made by referencing this cast member.
2 Select the new button cast member in the Cast window and name it
CameraX+10 by typing the name in the name text box at the top of the Cast
window. Press Enter (Windows) or Return (Macintosh).
3 In the Score, click the button’s sprite in channel 2 so that the entire sprite span
is selected.

Director 8.5 3D tutorial for Director users 7


4 Control-click (Macintosh) or right-click (Windows) the sprite span and choose
Script from the context menu that appears.
The Script window opens.

5 Without moving the insertion point, type this Lingo:


sprite(1).camera.translate(10,0,0)

In this script, the handler name is on mouseUp. This is because one of the most
common events to happen to sprites is a mouse click. Now when a you click on
your button sprite while the movie is playing, the Lingo you typed will be
executed and the camera will move.
The Lingo you typed uses a scripting convention called dot-syntax. With dot-
syntax you can be very specific about which object you want to manipulate
with Lingo. In this case you are manipulating the camera in sprite 1. The
number 1 refers to the channel number the sprite occupies in the Score. The
word translate is the name of the command you are using to manipulate the
camera.
In English, the Lingo you typed would sound something like this:
Translate the camera of sprite 1.
In this English version, the names of the objects and commands are in the
reverse order from the Lingo version.
The translate command moves the object you specified (the camera) a
specific amount. In this case, you specified (10,0,0). These three numbers
represent movement along the three axes of 3D space: the X, Y, and Z axes. By
specifying (10,0,0), you are saying “move the camera 10 units along the X
axis and 0 units along both the Y and Z axes.”
6 Close the Script window and play your movie.

8
7 Click the Camera X+10 button and watch the perspective change as the camera
moves. Don’t click too many times, or you won’t be able to see the orb any
more with that camera.
Next, you’ll add a second button to move the camera back in the other direction.

Move the camera back


To move the camera back in the other direction, you’ll add another button with a
similar script, but with one important difference. You’ll change the value you use
with the translate command.
1 Click the Rewind button in the Control Panel.
2 Click the Push Button tool in the Tool palette.
3 Draw a new button on the Stage just above the first one. Name the new button
Camera X-10.
4 In the Cast window, name the new cast member CameraX-10.
5 Control-click (Macintosh) or right-click (Windows) in the middle of the sprite
span and choose Script from the context menu.
6 In the Script window, type this Lingo:
sprite(1).camera.translate(-10,0,0)

This time you are saying in Lingo, “translate the camera of sprite 1 minus-ten
units along the X axis and 0 units along the Y and Z axes.”
7 Close the Script window and save your movie.
8 Rewind and play your movie. Click the Camera X-10 button and watch the
camera move back in the opposite direction.
You can click both buttons and watch how they counteract each other.

Rotate the model


To rotate the model, you’ll add two buttons similar to the ones you’ve already
created. With those buttons, your Lingo referred to sprites and cameras. This time
you’ll use Lingo that refers to the 3D cast member and the model and uses the
rotate command.

1 Click the Rewind button in the Control Panel.


2 Click the Push Button tool in the Tool palette, and click and drag to create a
new button on the Stage just above the first two buttons you created earlier.
3 At the button’s text insertion point, type Rotate Y+20.
4 In the Cast window, name the new button cast member RotateY+20

Director 8.5 3D tutorial for Director users 9


5 Control-click (Macintosh) or right-click (Windows) the button’s sprite in the
Score and choose Script from the context menu.
The Script window opens.
6 In the Script window, type the following Lingo inside the default on mouseUp
handler.
member(3).model(1).rotate(0,20,0)

This Lingo tells Director to rotate the first model of the third cast member 20
degrees around the Y (up) axis. Because the number 20 is a positive integer, the
model rotates to the left.
7 Close the Script window and save your movie.
8 Rewind and play your movie. Click the Rotate Y+20 button to rotate the
model 20 degrees to the left.

Add the second rotation button


You will now add a fourth button to rotate the model back to the right.
1 Click the Rewind button in the Control Panel.
2 Click the Push Button tool in the Tool palette, and draw a new button on the
Stage just above the other three buttons.
3 At the button’s text insertion point, type Rotate Y-20.
4 In the Cast window, name the new button cast member RotateY-20.
5 Control-click (Macintosh) or right-click (Windows) the button’s sprite in the
Score and choose Script from the context menu.
The Script window opens.
6 In the Script window, type the following Lingo inside the default on mouseUp
handler.
member(3).model(1).rotate(0,-20,0)

Because the number -20 is a negative integer, the model rotates to the right.
7 Close the Script window and save your movie.
8 Rewind and play your movie. Click the Rotate Y-20 button to rotate the model
20 degrees to the right.

10
Add a texture to the model
You can make many kinds of changes to your 3D cast members in addition to
moving and rotating objects within them. You can change their appearance in a
variety of ways. In this section, you’ll create a button to change the surface
appearance of the orb by adding a texture and applying it to the model.
1 Click the Rewind button in the Control Panel.
2 Click the Push Button tool in the Tool palette, and draw a new button on the
Stage just above the other four buttons.
3 At the button’s text insertion point, type Add Texture.
4 In the Cast window, name the new button cast member AddTexture.
5 Control-click (Macintosh) or right-click (Windows) the button’s sprite in the
Score and choose Script from the context menu.
The Script window opens.
6 In the Script window, type the following Lingo inside the default on mouseUp
handler.
myTexture = member(3).newTexture("red square", #fromCastmember,
member(1))
member(3).model(1).shader.texture = myTexture

In English, these commands would sound like the following:


“Create a new texture inside cast member 3 called red square using the bitmap
in cast member 1, and assign that texture to a variable called myTexture. Then
set the texture of the shader of model 1 in cast member 3 to the texture that the
variable myTexture refers to.”
7 Close the Script window and save your movie.
8 Rewind and play your movie and click the Add Texture button. If you click this
button more than once, a Lingo error will occur. This is because the Lingo you
typed creates a new texture object. Attempting to create another one with the
same name in the same cast member is not allowed.

Director 8.5 3D tutorial for Director users 11


Remove the texture
In order to remove the texture, you’ll now add a button that uses the
resetWorld() command. This command returns the 3D cast member to its
original state and removes any new objects you have created, such as the new
texture you made in the last section.
1 Click the Rewind button in the Control Panel.
2 Click the Push Button tool in the Tool palette, and draw a new button on the
Stage just above the other five buttons.
3 At the button’s text insertion point, type Reset World.
4 In the Cast window, name the new button cast member ResetWorld.
5 Control-click (Macintosh) or right-click (Windows) the button’s sprite in the
Score and choose Script from the context menu.
The Script window opens.
6 In the Script window, type the following Lingo inside the default on mouseUp
handler.
member("Orb").resetWorld()

In English, this Lingo would translate to “Reset the world in the cast member
named Orb to its original state.”
7 Close the Script window and save your movie.
8 Rewind and play your movie and click the Rotate and Camera buttons.
9 Click the Reset World button.
The sphere is returned to its original location and the texture is removed. You
may now click the Add Texture button again without causing a Lingo error.

12
Rotate the model in a frame script
When you are creating your own movies with 3D cast members, you may want to
make models rotate or move on their own without requiring user interaction. In
this section, you’ll modify the frame script in frame 28 by adding Lingo that will
continuously rotate the sphere in the Orb cast member.
1 Open the Score.
2 Double-click the script in the Script channel in frame 28. The Script window
will open displaying the go to the frame script.
3 To make a new line, place the insertion point at the end of the first line that
reads on exitFrame and press Return.
4 In the new line type this Lingo:
member("Orb").model(1).rotate(0,5,0)

This Lingo is very similar to the Lingo you used earlier to create the rotation
buttons. This time, the rotate command causes the model to rotate 5 units to
the right each time the playback head loops in frame 28.
5 Close the Script window and play your movie. You can still use your buttons,
but the effect of the rotate buttons will be less noticable because of the constant
rotation in frame 28.

Test with the Message window


Director includes a significant number of Lingo commands for conrolling 3D cast
members and all of their internal components. You may find it helpful to
experiment with these commands before you use them your own scripts. The
Message window in Director provides a simple way to test the way a command
works before you decide whether or not to use it in your movie.
This section shows you how to use the Message window for testing Lingo. You can
type just about any single line of lingo you want and see the results of the Lingo
immediately.
If you want to finde the value of a variable or a property, you use the put
command. This simple command tells lingo to display the results of your Lingo in
the Message window. You can use the put command in the Message window and
in regular scripts.
If you want to control the appearance of a cast member or sprite, you can type the
neccesary Lingo in the Message window and see the change in the cast member or
sprite immediately. This works whether or not the movie is playing.

Director 8.5 3D tutorial for Director users 13


First try a command you’re already familiar with; the rotate command:
1 Stop your movie.
2 Open the Message window by choosing Window > Message.
3 In the Message window, type member("Orb").model(1).rotate(0,50,0).
4 Press Return.
5 With some cast member types, such as 3D cast members, you must click the
sprite on the stage in order to see your Lingo take effect when the movie is not
playing. This forces Director to redraw the contents of the Stage. Click the 3D
sprite on the Stage.
6 Now type member("Orb").model(1).rotate(50,0,0) in the Message
window.
7 Press Return. Do not click the 3D sprite on the Stage. Instead, type
updateStage and press Return. This command also forces Director to redraw
the Stage contents. This time, you see the sphere rotate upwards around the X
axis.
You can see how using the Message window is a great way to experiment with
what happens when you enter different values for the different axes with the
rotate command. Now you can try some new Lingo that you haven’t seen yet.

Look at properties in the Message window


The Message window is great for times when you aren’t sure what’s going on
inside a cast member. Because 3D cast members have so many internal
components you may find yourself in this situation more often.
Here you’ll use the Message window to look at the model’s textureList.
1 Rewind and play your movie.
2 If the sphere has the red texture appied, click the movie’s Reset World button.
3 In the Message window, type this Lingo and then press Return:
put member("Orb").model(1).shader.textureList

Director will immediately display the value of the model’s textureList in the
Message window:
-- [<Void>, <Void>, <Void>, <Void>, <Void>, <Void>, <Void>,
<Void>]

You can see that each of the model’s 8 texture layers is empty.
4 With the movie still playing, click the Add Texture button on the Stage. The
sphere will turn red.

14
5 In the Message window, move the insertion point back to the end of the line of
Lingo from step 3 and press Return. This time the textureList includes the
red square texture created by the script you attached to the Add Texture button.
-- [texture("red square"), <Void>, <Void>, <Void>, <Void>,
<Void>, <Void>, <Void>]

6 With the movie still playing, click the Reset World button on the Stage.
7 In the Message window, move the insertion point back to the end of the line of
Lingo from step 3 and press return.
-- [<Void>, <Void>, <Void>, <Void>, <Void>, <Void>, <Void>,
<Void>]

The textureList has returned to its original value.

Set the color of a light


Now you can try setting the color property of a light in the 3D world. This will
in turn change the color of the sphere. A 3D world can contain as many lights as
you want to put in it. The Orb cast member you imported contains 3 lights. In
this section you’ll determine the name of one of the lights in the world and
modify its color property.
1 First, you’ll ask Director to display the number of lights that exist in the Orb
cast member. With the movie playing, type this Lingo into the Message
window and press Return:
put member("Orb").light.count

The number 3 appears in the Message window:


-- 3

The count property can be used to check the number of any kind of 3D object
in a cast member, including cameras, models, model resources and others.
2 Next, you’ll check the name of the third light in the Orb cast member. In the
Message window, type this Lingo and press Return:
put member("Orb").light(3).name

The Message window displays the name of the third light:


-- "Ambient Light"

3 Now you can set the color of the light named Ambient Light by using the
color property. The color property can be set to any RGB color value. Here,
you’ll set the light to a bright blue. Type this Lingo in the Message window and
press Return:
member("Orb").light("Ambient Light").color = rgb(0, 0, 255)

Since the movie is still playing, the sphere in your 3D sprite should change to a
blue color immediately. This is because the light that is illuminating it is blue.

Director 8.5 3D tutorial for Director users 15


4 Experiment with a green color. Type this Lingo into the Message window and
press Return:
member("Orb").light("Ambient Light").color = rgb(0, 255, 0)

The sphere turns green.


You can experiment with as many RGB values as you like. Each number in the
RGB value must be between 0 and 255.
You can use the Message window like this to try out all the Lingo commands and
properties. If you develop the habit of using it this way, you’ll find it an invaluable
tool for learning how to use the Lingo for each new Director feature you choose to
use in your movies.

Learning more
Because 3D cast members can be very complex and detailed, there is much more
you can do with Lingo to control and add interactivity to your 3D cast members.
For more information about the whole range of capabilities Lingo offers for
working with 3D, see the manual What’s New in Director 8.5, which is included
with Director 8.5.
In addition, you can find a large selection of how-to articles in the Director
Support Center on Macromedia’s Web site at http://www.macromedia.com/
support/director. These articles provide detailed explanations of how to perform
many more essential 3D tasks with Lingo.

16

You might also like