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

property pPointList -- list of n vector positions<br />

property pRunningTotal -- sorted list of n-1 distances along path<br />

property pTotalLength -- final value in pRunningTotal<br />

on GetPosition(aRatio)<br />

vDistance = pTotalLength * aRatio<br />

vIndex = pRunningTotal.findPosNear(vDistance)<br />

vLast = pPointList[vIndex - 1]<br />

vNext = pPointList[vIndex]<br />

vDirection = (vNext - vLast).getNormalized()<br />

vComplete = pRunningTotal[vIndex - 1]<br />

vRemaining = vDistance - vComplete<br />

vPosition = vLast + vDirection * vRemaining<br />

return vPosition<br />

end GetPosition<br />

Note the use of list.findPosNear() on a sorted list, to give the index of the next value in the sorted list, which is equal<br />

to or greater than the requested value.<br />

You can apply the position along the path to any kind of node, including cameras<br />

Looking along the path<br />

To get the node to turn to face along the path, you can simply ask for a position slightly further along the path, and use<br />

node.pointAt() to make the node face in that direction.<br />

Choose carefully how far ahead to look. Ideally, the position must be on the line segment one or two points further<br />

along the path. If the point to look at is sometimes on the same segment, the node will alternate between rotating and<br />

not rotating, and the effect will not be natural. If it's too far ahead, the node may tend to point in the wrong direction.<br />

Last updated 8/26/2011<br />

269

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

Saved successfully!

Ooh no, something went wrong!