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

Terrains<br />

Where possible, use several small terrain objects, placed side by side. Using a single large terrain can lead to<br />

performance issues. For your own projects, you may wish to find the optimal balance between multiple terrain objects,<br />

the terrain dimensions and the polygon count for each individual terrain.<br />

Ray casting<br />

Using rayCastAll() and rayCastClosest() are both significantly faster than the native 3D ray-casting methods.<br />

However, even with the simplified geometry used by rigidBody proxies, ray casting can be an expensive operation if<br />

the scene is full of rigidBody objects. Unlike the native 3D ray-casting methods, the Dynamiks xtra does not allow you<br />

to limit the number of objects that the ray will consider, nor does it allow you to indicate a maximum distance at which<br />

to stop searching.<br />

If you are sending multiple ray casts on every frame into a crowded scene, you may like to check whether this is<br />

affecting the rate of playback. If so, you may wish to explore alternative techniques. Here are a couple of examples.<br />

Create a parallel scene with 3D models with very simple geometry and remove it from the world. Use the native<br />

member3D.modelsUnderRay() on a subset of these simple models.<br />

Use a path-finding algorithm, such as A* (see “Finding a path” on page 229) to find a pre-determined path through<br />

a maze of obstacles.<br />

CPU-friendly code<br />

3D operations may not be the only bottleneck in your project. You may unwittingly be creating scripts that use<br />

inefficient techniques.<br />

Both JavaScript and Lingo provide multiple ways for achieving the same ends. A script that uses few lines of code is<br />

not necessarily faster than one that uses more precise commands. This is especially true when using repeat loops.<br />

Placing timer points in your scripts<br />

In any complex process, there may be certain operations that take longer than others. The most likely places to improve<br />

performance are in those operations that take the longest. To determine where these are, you can place timer points in<br />

your script.<br />

To test this concept, download the movie Suspend.dir. At the end of the on beginSprite() handler in the<br />

SuspendUpdates Demo behavior, you will find three lines commented out. Uncomment these lines and launch the<br />

movie. Watch the output in the Message window.<br />

Last updated 8/26/2011<br />

396

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

Saved successfully!

Ooh no, something went wrong!