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

When models are scaled, collisions may be reported incorrectly<br />

Note: There are also other bugs which the Collide.dir movie is not designed to illustrate. These include issues with fastmoving<br />

models, the detection of shallow collisions, and the ability to correctly resolve collisions. In many cases, you will<br />

find that there are better solutions than relying on the collision modifier.<br />

Custom collision detection<br />

In some cases, you can perform collision detection very simply, without the need for any modifiers or xtra extensions.<br />

This article will look at one of these cases. The purpose is to help you to visualize the process of collision detection and<br />

how a collision is resolved.<br />

Collision between two spheres<br />

The simplest case is the detection of a collision between two spheres. Every node has a node.boundingSphere property,<br />

which provides the center and the radius of the smallest sphere that will fit snugly around all the vertices in the node<br />

and in its children. The coordinates and dimensions are given with reference to the world. If a spherical model has no<br />

children, then its boundingSphere gives a perfect description of its own volume.<br />

Here is a handler that will tell whether the boundingSphere of one model intersects that of another.<br />

on SpheresIntersect(aModel1, aModel2)<br />

vSphere1 = aModel1.boundingSphere<br />

vSphere2 = aModel2.boundingSphere<br />

vDistanceBetweenCenters = (vSphere2[1] - vSphere1[1]).magnitude<br />

vMinimumDistance = vSphere1[2] + vSphere2[2]<br />

vIntersection = (vDistanceBetweenCenters

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

Saved successfully!

Ooh no, something went wrong!