07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ADOBE DIRECTOR BASICS<br />

3D: Controlling action<br />

v = randomVector()<br />

trace(v.length)<br />

-- 1.0000<br />

trace(v.magnitude)<br />

-- 1.0000<br />

trace(v.x * v.x + v.y * v.y + v.z * v.z)<br />

-- 1.0000<br />

v[1] = 3<br />

v[2] = 4<br />

v[3] = 12<br />

trace(v)<br />

-- vector( 3.0000, 4.0000, 12.0000 )<br />

trace(v.mag<br />

nitude)<br />

-- 13.0000<br />

Position and translation vectors<br />

A vector is essentially used to express a position in space or a translation through a given distance in a given direction.<br />

A position or translation vector is only meaningful within a parent frame of reference (see “Frames of reference” on<br />

page 202).<br />

A translation expressed as vector(x, y, z) can be thought of as the following movement:<br />

1 A translation of x units parallel with the xAxis of the parent frame of reference<br />

2 A translation of y units parallel to the yAxis of the parent frame of reference, starting from the point arrived at in<br />

step 1<br />

3 A translation of z units parallel to the zAxis of the parent frame of reference, starting from the point arrived at in<br />

step 2<br />

The actual order of the steps is not in fact important.<br />

A position vector can be thought of as the result of a translation that starts from the origin of the parent frame of<br />

reference.<br />

The vector methods and operations described at “Vector methods and operations” on page 364 are only meaningful<br />

when vectors are used to express positions or displacement.<br />

Other uses of vectors<br />

The vector format of (float, float, float) is also useful for expressing quantities other than positions or<br />

translation. For example:<br />

transform.rotation: the x, y and z properties indicate a sequential rotation around each axis. In other words, a<br />

rotation vector says: “Rotate x degrees around the xAxis, then y degrees around the yAxis, and then z degrees<br />

around the zAxis, in that order”.<br />

transform.scale: the x, y and z properties provide a shorthand for transform.xAxis.length,<br />

transform.yAxis.length and transform.zAxis.length.<br />

spotLight.attenuation: the x, y and z properties provide a shorthand for the components of a quadratic<br />

equation used to calculate how the illumination for a spotlight decreases with distance. This can be expressed as<br />

follows:<br />

intensity = attenuation.z * attenuation.z * distance + attenuation.y * distance +<br />

attenuation.x<br />

Last updated 8/26/2011<br />

363

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

Saved successfully!

Ooh no, something went wrong!