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

Imagine that you want to tip a chair backwards. The center of rotation can be any point on the line between its two<br />

back feet. The axis of rotation would be parallel to the line between its two back feet, and the angle can be anything up<br />

to about 90°, after which its back will hit the floor. The frame of reference would be the chair itself, so you can use<br />

#self, or leave the frame of reference blank.<br />

Imagine that you want to swing the chair around you in a circle, in preparation for throwing it through a window. In<br />

this case, the centre of rotation would be your center of gravity, the axis of rotation would be vertical, and the angle<br />

would be something like 360°. You can consider yourself to be the temporary “parent” of the chair, as its movement is<br />

defined by yours, so you can use #parent or model("me") as the frame of reference.<br />

You can provide these four items of information in a number of different ways.<br />

1 aNode.rotate(position, axis, angle {, relativeTo})<br />

2 aNode.rotate(xAngle, yAngle, zAngle {, relativeTo})<br />

3 aNode.rotate(rotationVector {, relativeTo})<br />

Note: You can also apply the rotate() command to the transform of a node. However, a transform has no parent, so<br />

the rotation can only be applied within its own frame of reference. Providing a frame of reference parameter when using<br />

rotate() with a transform will provoke a script error.<br />

transform.rotate(position, axis, angle)<br />

transform.rotate(xAngle, yAngle, zAngle)<br />

transform.rotate(rotationVector)<br />

Three rotation angles or only one rotation angle? Read the following sections to know more.<br />

Three rotation angles<br />

If you use a rotation vector or three separate rotation angles, then the center of rotation and axis of rotation are defined<br />

implicitly. Consider this example:<br />

chairModel.rotate(17, 23, 41, irateEmployeeModel)<br />

This means:<br />

Rotate chairModel 17° around the origin point of irateEmployeeModel in a plane perpendicular to<br />

irateEmployeeModel's x-axis<br />

Then rotate chairModel 23° around the origin point of irateEmployeeModel in a plane perpendicular to<br />

irateEmployeeModel's y-axis<br />

Finally rotate chairModel 41° around the origin point of irateEmployeeModel in a plane perpendicular to<br />

irateEmployeeModel's z-axis<br />

The end result of any sequence of rotations can be produced by one single rotation. The three separate rotations above<br />

are equivalent to a single rotation of about 47° around the origin point of the irateEmployeeModel on a plane<br />

perpendicular to an axis parallel to the vector(-0.1681, -0.5940, -0.7867) in the irateEmployeeModel's frame<br />

of reference.<br />

Tip: You can use axisAngle to discover the orientation of the axis and the angle of rotation of a node, in its own frame of<br />

reference, after a rotation.<br />

To see a demonstration of this concept, download RandomRotation.dir and launch it.<br />

Last updated 8/26/2011<br />

210

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

Saved successfully!

Ooh no, something went wrong!