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 />

3D mathematics<br />

Manipulating objects in 3D space requires the use of 3D mathematical concepts. Often, <strong>Director</strong> can take care of the<br />

mathematics for you, without you being aware of it. Many developers will use strategically-placed group nodes as<br />

parents for visible models, in order to avoid explicit use of mathematics.<br />

This section provides recipes for certain operations that require mathematical knowledge. So long as you understand<br />

the purpose of each recipe, you do not need to understand the underlying mathematics.<br />

This section also provides some insight into the mathematical operations, if you want to explore those further.<br />

In <strong>Director</strong>, 3D mathematics is based on two objects:<br />

vector(): a three-dimensional representation of a point, a direction, a rotation or a scale. For more information,<br />

see “Vectors” on page 361 and “Vector methods and operations” on page 364.<br />

transform(): a three-dimensional representation of a frame of reference, including information on a position in<br />

space and the orientation and scale of 3 axes: x, y and z. For more information, see “Transforms” on page 370,<br />

“Transform properties” on page 372, and “Transforms methods” on page 372.<br />

Vectors<br />

A 3D vector describes both direction and location in 3D space. Vector objects include floating-point values for<br />

position along each of the x-, y-, and z-axes. Vectors can be node- or world-relative. If they are node-relative, their x,<br />

y, and z values are relative to the position of the node. If they are world-relative, their x, y, and z directions are relative<br />

to the world.<br />

Vector mathematics operations perform calculations using each of the x, y, and z values. These calculations are useful<br />

for performing intelligent movement and rotation of models. See “Vector methods and operations” on page 364 for<br />

more details.<br />

Creating a vector<br />

You can create a new vector in three different ways<br />

vector() creates a vector from the given x, y and z values<br />

randomVector() creates a vector with random x, y and z values, such that the length or magnitude of the vector<br />

is 1.0 world unit.<br />

vector.duplicate() creates a copy of a source vector at a different location in the computer's memory.<br />

Pointers and duplicates<br />

Vectors are objects. Like other objects, a vector object points to an address in the computer's RAM space where the<br />

properties of the object are stored.<br />

Imagine two variables that refer to the same vector object. If you changing the properties of the vector using one<br />

variable, the other variable will report exactly the same changes, because it is reading the values from the same address<br />

in RAM space.<br />

To test this, try this experiment in the Message window. (For clarity, the output is shown for a Message window set for<br />

JavaScript. Identical commands will work in Lingo.)<br />

Last updated 8/26/2011<br />

361

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

Saved successfully!

Ooh no, something went wrong!