|How to work with 3DPI - Example One.
||Docs | Last
D. Animating the Cube
Directors 3D technology is offering unlimited possibilities for
creating animations and interactions. The key to this world is
the script language Lingo.
This part of the example will describe the way, how to write the
script to animate the Cube, which is quite easy with the help
of the 3DPI.
Changing the view.
Rotating the Cube.
Getting the Script.
Animating the Cube.
Before starting to animate the Cube, it will be
helpful first to reset its rotation and to find a better view to watch
(The Model-TAB is still active.)
- Reset the models rotation by typing 0
into all three fields beside "rotation".
|After resetting the rotation, only one side
of the Cube will be visible, because the camera is by default
placed in front of the worlds center point and is looking
Another trick within the 3DPI to reset the complete transform
of a node is by clicking on the "Paste Transform
" Button while keeping the option key (=
alt key) pressed.
If the "Paste Transform" Button is not active,
click on the "Copy Transform" Button first.
On PC this trick also works by clicking with the right
mouse Button on the "Paste Transform" Button.
- Click on the Camera-TAB.
The 3DPI will display all cameras. Currently only one exists, the
- Within the name list, click in the row
of the "DefaultCamera".
The camera will be selected, and in the bottom part of the 3DPI
all properties of a camera will be displayed, as well as the current
values of the selected "DefaultCamera".
- Move the camera up, by increasing the
y-value of the position (the second value).
While changing the value, one can notice the Cube "moving
down". In fact the model itself stays of course where
it is, it´s only the cameras view which is changing.
So the missing thing at the moment is to point the camera
back to the model again.
- Click on the "pointAt..." Button
to open the dialog for pointAt.
A dialog will open, asking for the "vectorPosition" (where
to look at) and a "vectorUp" (which is normally optional).
It is not necessary to change the values within this dialog
for this example, but nevertheless here is a short explanation about
the pointAt() function and this dialog:
In this example the position of the Cube should be used for the
"vectorPosition", because there the camera should point
at. Within this dialog the 3DPI can help you to fill the fields
with the correct values: Open the last popUp and select the "model_1"
(or however you named your model). After selecting it, the 3DPI
will automatically fill the fields of the vectorPosition with the
values of the Cube´s position. "0.000" will appear
three times, according the Cubes position in the world.
The values for vectorUp can also stay like appearing in the dialog
by default: vector(0,1,0), because in this example the y-axis is
the vertical axis.
- Click "OK" to close the
dialog and to point the camera at the Cube.
|The rotation of the camera is now changed in a way, that
the Cube appears in the center of the view.
A nice and easy animation is to rotate the Cube. Let´s have
a look, how to do this:
- Click on the Model-TAB.
The 3DPI will activate the Model-TAB, will select the
model of the Cube and show all its properties.
- Click on the "rotate..." Button to open
the dialog for rotating the Cube.
A dialog will open asking for the values, how the model should
- Type "10" inside the yIncrement.
- Click OK to close the dialog and to rotate the Cube.
The Cube is now rotated 10 degrees around the y-axis, the vertical
Now it´s time to learn another 3DPI trick.
To repeat a transform function (translate, rotate,
pointAt and scale) without opening the dialog again, one
simply needs to click on the Button for the function while
keeping the option key (= alt key) pressed.
On PC the dialog can also be skipped by clicking with the
right mouse Button.
So click again alot of times on the "rotate..." Button,
either with the option key pressed, or with the right mouse button.
Each time clicking, the Cube will rotate again about 10 degrees.
This is the way the animation can happen, so the only missing
thing now is, to let Director do the job for rotating the Cube.
The following explanation will finally reveal how to get the Lingo
script from the 3DPI for rotating the Cube and how to deal with
this script. You will be surprised, how easy it is!
|The most important element in the 3DPI for getting Lingo code
is placed in the right upper corner of it´s window:
the "Trace" Button.
This Buttons offers 3 different functions. Click on the
Button and keep the mouse Button pressed. A PopUp opens,
where the functions are listed and can be switched.
Select the last entry "Trace changes".
The Trace Button now appears pressed, which means active for
When clicking on the Button shortly, one can switch the "Trace
changes" function off or on. So as long as the Button appears
pressed, the function is active, if the Button is displayed
unpressed, the function is inactive and no scripts will be putted.
While the "Trace changes" function is active, the scripts
for each action, that one does within the 3DPI, will be put into
the message window.
- Open the message window.
- Click on the "rotate..." Button in the 3DPI.
- Type "5" inside the yIncrement of the dialog
- Click "OK" to close the dialog and to rotate the
Now look at the message window: the scriptlines for rotating
the model did appear.
The first lines creates a reference to the model and stores it
in the variable "theModel".
The second line rotates the model.