07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ADOBE DIRECTOR BASICS<br />

3D: Controlling action<br />

200<br />

0 0 0<br />

0.23439370698124551 0 2.8052391247018487<br />

0.79709400427770416 0 5.5735889387208921<br />

1.4100892089568533 0 8.3189680738959133<br />

2.2041555452853721 0 11.022120463300187<br />

3.13483108877689 0 13.679583825865805<br />

4.2009292738630357 0 16.286207871349418<br />

5.38…<br />

In other words, the file starts with the number of points, then a series of lines that begin with two TAB characters, then<br />

the x component, the y component (always 0), and the z component of a vector position in world space.<br />

Tip: In this movie, the camera is attached as a child to the Train model, and the train model follows the track. This helps<br />

you to visualize the spline in 3D space, and the movement of a node through space.<br />

If you are creating a pre-defined fly-through, you do not need to show either a visible track or a visible parent for the<br />

camera. You can simply move the camera between the points of an invisible spline.<br />

The distances between adjacent points on the spline are not always equal, but the train needs to travel at a constant<br />

speed. The Train behavior uses the data from the text file to create four separate lists:<br />

property plPoints -- list of points on track<br />

property plVectors -- list of vectors that join the dots in<br />

-- plPoints<br />

property plLengths -- list of the lengths of the plVectors<br />

property plTotals -- sorted list of cumulated lengths in<br />

-- plLengths<br />

On each enterFrame, the behavior determines how many milliseconds have elapsed since the train started, and<br />

calculates how far the train will have travelled in that time, as vDistance. The behavior then uses<br />

plTotals.findPosNear(vDistance) to determine which segment of the spline the train is currently on. It works out<br />

how far along that segment the train is, and what direction it is currently traveling in. This gives the current position<br />

and rotation for the Train model. Because it is a child of the Train model, the worldPosition and rotation of the<br />

camera is updated automatically to keep it in the same position relative to the train.<br />

You can use the Train behavior as the starting point for your own fly-through projects.<br />

You can find a demonstration of a similar technique at “Following a path” on page 267.<br />

Steering with the mouse<br />

There are several ways to control the camera with the mouse. This article explains a system based on the mouse<br />

position over the sprite. You can find a different solution at “Moving to a given location” on page 225.<br />

Three in one<br />

The Steer Camera With Mouse script deals with three different features of a walkthrough camera:<br />

Forward and backward movement, and steering.<br />

Looking around from a stationary position. For more information, see “Looking around” on page 222.<br />

Collision detection. For more details, see “Not walking through objects” on page 222.<br />

Last updated 8/26/2011<br />

221

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!