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

Applying one transform to another<br />

As illustrated in the “Parent and child relationships with no nodes” on page 374 section above, the * (multiply)<br />

operator can generate a new transform by applying one transform to another. If you prefer to modify one of the<br />

original transforms you can use one of the following methods:<br />

transform.multiply()<br />

transform.preMultiply()<br />

To test this in the Message window, create a transform t that represents a translation and a transform r that represents<br />

a rotation:<br />

t = transform()<br />

t.translate(13, 17, 19)<br />

r = transform()<br />

r.rotate(90, 0, 0)<br />

Generate a transform that represents a rotation followed by a translation, without changing the original transforms.<br />

Note that the y and the z axes change as the initial rotation occurs around the vector(0, 0, 0) and then the<br />

translation t is applied.<br />

put showTransform(t*r)<br />

-- "<br />

1.00000 0.00000 0.00000 0.00000<br />

0.00000 -0.00000 1.00000 0.00000<br />

0.00000 -1.00000 -0.00000 0.00000<br />

13.00000 17.00000 19.00000 1.00000<br />

"<br />

Create a duplicate of the rotation transform, and apply the translation to it using multiply(). This will modify the<br />

duplicate rotation transform.<br />

r2 = r.duplicate()<br />

r2.multiply(t)<br />

put showTransform(r2)<br />

-- "<br />

1.00000 0.00000 0.00000 0.00000<br />

0.00000 -0.00000 1.00000 0.00000<br />

0.00000 -1.00000 -0.00000 0.00000<br />

13.00000 17.00000 19.00000 1.00000<br />

"<br />

Generate a transform that represents a translation followed by a rotation, without modifying the original transforms.<br />

put showTransform(r*t)<br />

-- "<br />

1.00000 0.00000 0.00000 0.00000<br />

0.00000 -0.00000 1.00000 0.00000<br />

0.00000 -1.00000 -0.00000 0.00000<br />

13.00000 -19.0000017.00000 1.00000<br />

"<br />

Use r.preMultiply() to apply the translation first, followed by the rotation, modifying the r transform in the<br />

process.<br />

Last updated 8/26/2011<br />

377

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

Saved successfully!

Ooh no, something went wrong!