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

One easy way to achieve this is to send a ray downwards from above the camera or avatar, and detect where this ray<br />

intersects with the ground model beneath it. To see an example of this in action, download and launch the movie<br />

HugTerrain.dir.<br />

The HugTerrain.dir movie move the avatar up and down as it moves over the terrain<br />

Creating a terrain<br />

The HugTerrain.dir movie uses a terrain mesh whose contours are defined by a height map stored in a grayscale image.<br />

For more information on this technique, see “Creating a terrain mesh” on page 176.<br />

An alternative to the solution described here is to use the “Steering with the mouse” on page 221createTerrain()<br />

method of the Physics Engine to create a terrain which will detect collisions with objects. See “Terrains” on page 319<br />

for more details.<br />

Detecting the terrain under the avatar<br />

The HugTerrain() handler below accepts three parameters:<br />

aNode: may be a first-person camera, an avatar, or the group which acts as the parent for the camera or the avatar<br />

aTerrainModel: the model that describes the collision geometry for the terrain<br />

aDirection: ±1, to indicate whether aNode is attempting to move forward or backwards.<br />

The handler creates a temporary transform at the position where aNode can be after moving. It then raises the<br />

transform vertically by an amount greater than the greatest possible change in height on the terrain, and sends a ray<br />

downwards from that point. If the ray intersects with aTerrainModel then aNode can move to the position of the<br />

intersection between the ray and aTerrainModel.<br />

Last updated 8/26/2011<br />

239

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

Saved successfully!

Ooh no, something went wrong!