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

v3DMember= member("3D")<br />

pChassis = v3DMember.newGroup("Chassis")<br />

vName = "Wheel_"<br />

vResource = v3DMember.newModelResource(vName, #cylinder)<br />

vResource.height = 10<br />

vRadius = vResource.topRadius<br />

repeat with ii = 1 to 4<br />

vModel = v3DMember.newModel(vName&ii, vResource)<br />

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

vX = (ii mod 2) * 50 - 25<br />

vZ = (ii > 2) * 70 - 35<br />

vModel.translate(vX, vRadius, vZ, #world)<br />

pChassis.addChild(vModel, #preserveWorld)<br />

end repeat<br />

pChassis.scale(0.20)<br />

pChassis.rotate(0, 30, 0)<br />

Node hierarchy<br />

Each node in a 3D world may have one parent and any number of children. By default, each new model is set as a child<br />

of the group(“World”). See “Group("World")” on page 93 for more details.<br />

Each child node inherits the transform of its parent node as a frame of reference. The final position, rotation, and scale<br />

of a model in the world depends on the transform of each node in its hierarchy of parents. See “Frame of reference”<br />

on page 97 for more details.<br />

The primary benefit of these parent-child relationships is that they make it easier to move complex models around in<br />

the 3D world and to have the component parts of those models move together in the proper way. In the example of a<br />

car, if the wheels of the car are defined as children of the car model, then moving the car will cause the wheels to be<br />

moved with the car in the expected manner. If no parent-child relationship is defined between the car and the wheels,<br />

moving only the car causes the wheels to be left behind in their original position in the world.<br />

Scripting terms to use with parent-child relationships<br />

You can use these scripting terms when you are working with parent-child relationships:<br />

node.addChild()<br />

node.child.count (Lingo) or aNode.count("child") (JavaScript)<br />

node.child() (Lingo) or node.getPropRef("child", aIndex) (JavaScript)<br />

node.parent<br />

To test these terms, download and launch the movie WheelDemo.dir.<br />

Last updated 8/26/2011<br />

91

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

Saved successfully!

Ooh no, something went wrong!