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

Physics world<br />

Before you can use a Physics cast member to simulate a physical world, you need to initialize the cast member. To do<br />

this, you need to call physicsMember.init(). To get the simulation to run, you need to call physicsMember.simulate()<br />

once per frame.<br />

Initialization<br />

The init() command takes five parameters:<br />

The 3D cast member which contains the scene to be simulated<br />

A scalingFactor vector (whose value is ignored in <strong>Director</strong> 11.5)<br />

A timeStepMode, whose value may be #automatic or #equal.<br />

A timeStep, whose value is ignored if you choose #automatic for the mode. If you want to use the #equal mode<br />

with the same results as if you were using the #automatic mode, you can use 1.0 / _movie.frameTempo for the<br />

timeStep.<br />

The number of subSteps to use between each screen update. More subSteps create more realistic simulations, but<br />

use more processing time. A recommended value for this parameter is 5.<br />

The following lines of code initialize the Physics member named "Physics" to use the 3D member named “3D” for a<br />

simulation in real time:<br />

-- Lingo syntax<br />

vPhysics = member("Physics")<br />

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

vScale = vector(1, 1, 1) -- necessary but ignored<br />

vMode = #automatic<br />

vTimeStep = 1.0 / _movie.frameTempo -- ignored in this case<br />

vSubSteps = 5<br />

vPhysics.init(v3DMember, vScale, vMode, vTimeStep, vSubSteps)<br />

// JavaScript syntax<br />

vPhysics = member("Physics");<br />

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

vScale = vector(1, 1, 1); // necessary but ignored<br />

vMode = symbol("automatic");<br />

vTimeStep = 1.0 / _movie.frameTempo; // ignored in this case<br />

vSubSteps = 5;<br />

vPhysics.init(v3DMember, vScale, vMode, vTimeStep, vSubSteps);<br />

timeStepMode<br />

The following are the two possible values for timeStepMode.<br />

#automatic: In this mode, the Physics simulation calculates how much time has elapsed since the last update, and<br />

moves the simulation forward by that amount of time. This mode is easier to work with, but it may break down if<br />

there are long interruptions between updates. For example, if the user switches to another application and back, or<br />

if a lengthy process in the movie itself monopolizes the computer processor.<br />

#equal: In this mode, the Physics simulation advances by the same time interval on every update. If the timeStep<br />

is equal to the duration of a <strong>Director</strong> frame (1.0 / _movie.frameTempo), then the result is almost equivalent to<br />

using the #automatic mode with better recovery after long interruptions. If the timeStep is significantly different<br />

from the duration of a <strong>Director</strong> frame, then the animation may seem to run too fast or too slow. In particular, if<br />

your movie is unable to play at the expected frame rate on a slow machine, the entire scene may update slowly.<br />

Last updated 8/26/2011<br />

298

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

Saved successfully!

Ooh no, something went wrong!