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

Torque and angularImpulse<br />

A torque is a turning force applied to an object, like using a wrench. An angular impulse provides an object with<br />

angular momentum. You can think of the difference as between starting to push a merry-go-round in a children's park<br />

(force) and jumping off the merry-go-round while it is already in motion (momentum).<br />

member(3).getRigidBody("box").applyTorque(vector(0,0,-10))<br />

member(3).getRigidBody("box").applyAngularImpulse(vector(0,0,-10))<br />

Note that torque and an angularImpulse applied along the zAxis create a rotation around the zAxis. Use the right hand<br />

rule to determine the direction of the rotation. Point your thumb along the axis of rotation and curl your fingers. A<br />

positive rotation will be in the direction in which your fingers point.<br />

attemptMoveTo()<br />

This method checks if the target position is free of obstacles. If so, the rigidBody is moved to the required position. If<br />

not, it does not move at all.<br />

When you set the position property of a rigidBody directly, you can move one rigidBody into a collision position with<br />

another. If either body is free to move, it will move to a collision-free position on the next simulation step.<br />

Reset the RigidBody.dir movie, and then try the example below in the Message window. Notice how the ball does not<br />

collide with the block until the fourth call, when its position is set so that it intersects with the block. Compare the<br />

results you achieve by setting the position with the results of using attemptMoveTo(), where no movement will occur<br />

if it will end in a collision.<br />

member(3).getRigidBody("ball").position = vector(0, 0, 3)<br />

member(3).getRigidBody("ball").attemptMoveTo(vector(0, 0, 2))<br />

member(3).getRigidBody("ball").attemptMoveTo(vector(0, 0, 0.3))<br />

member(3).getRigidBody("ball").position = vector(0, 0, 0.3)<br />

member(3).getRigidBody("ball").position = vector(4, 0, -0.5)<br />

member(3).getRigidBody("ball").attemptMoveTo(vector(4, 0, 0.5))<br />

Reset the movie again, then check the isPinned button, and try the last command again. Notice how the behavior is<br />

different when the block is prevented from moving.<br />

Rigid body proxies<br />

The Dynamiks xtra allows you to define both convex and concave proxy templates. Use the following methods to<br />

create proxy templates and to create rigidBody objects from them:<br />

physicsMember.addProxyTemplate()<br />

physicsMember.createRigidBodyFromProxy()<br />

physicsMember.createProxyTemplate()<br />

physicsMember.loadProxyTemplate()<br />

For a complete demonstration on how to use these methods, download and launch the movie Rigid Body Proxy<br />

Shapes.dir.<br />

Last updated 8/26/2011<br />

317

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

Saved successfully!

Ooh no, something went wrong!