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

[#maxNumberOfModels: ,<br />

#maxDistance: ,<br />

#levelOfDetail: ,<br />

#modelList: [, ...]]<br />

For example:<br />

[#maxNumberOfModels: 1, #levelOfDetail: #detailed, #modelList:<br />

[member("3D").model("Target")]]<br />

When used with this syntax and the value #detailed for the #levelOfDetail property, the output from the function<br />

is a list of property lists, with the format:<br />

[[#model: ,<br />

#distance: ,<br />

#isectPosition: ,<br />

#isectNormal: ,<br />

#meshID: ,<br />

#faceID: ,<br />

#vertices: [, , ],<br />

#uvCoord: [#u: , #v: ]], ...]<br />

The #uvCoord property gives you information about which pixel in the texture image was touched by the ray. See<br />

“Mapping a texture to a mesh resource” on page 150 for more details.<br />

Detecting obstacles in the direction of motion<br />

Imagine a world with one moving object: the player's avatar. Imagine an obstacle some distance away from the avatar.<br />

Imagine that the avatar starts moving and keeps traveling in the same direction. In this case, you only need to send out<br />

one ray to know how far the avatar will need to travel before colliding with the obstacle. If you know the speed of the<br />

avatar, you can calculate the time when the impact will occur.<br />

The concept of using a ray to detect collisions for an avatar steered by the user is explained in detail in “Not walking<br />

through objects” on page 222. This article treats the simpler process required to deal with the movement of a model<br />

traveling in a straight line.<br />

To see a very simple game that illustrates the idea, download and launch the movie AirHockey.dir.<br />

The direction of movement of the mouse defines the direction of the invisible ray<br />

Last updated 8/26/2011<br />

286

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

Saved successfully!

Ooh no, something went wrong!