|
|
The Claw (Expressions) Added on: Sat Jul 01 2000 |
Page: 1 2 3 4 |
Now we have all the equations down we can FINALLY write the script. Which is basically already written above. To split the expression up in to sections we need to make a case for each section with "if" statements.
The "if" function follows this syntax "if(a,b,c)" which means in human terms "If a is true, then b, if a is false then c". It HAS to have all three parts or you will get a parsing error. So here is the expression: (cheer)
if(ConPos.z-BallPos.z>21 , Closed ,
if(ConPos.z-BallPos.z>14 & ConPos.z-BallPos.z<21 , degToRad((ConPos.z-BallPos.z-21)*5),
if(ConPos.z-BallPos.z>7 & ConPos.z-BallPos.z<14 , degToRad((7-(ConPos.z-BallPos.z))*5),
Closed)
)
) If it is the first section (above 21 units) then the claw is closed, (remember the closed variable you made, here it is in action) but if the claw isn't abovet 21 units then....if it is above 14 units and below 21 units then open the claw from 0 to -35 degrees if it isn't in this "section" then if the claw is below 14 units and above 7 units then close from -35 to 0 degrees, and if the claw is below 7 units (and clipping with the ball) keep the claw closed anyway.
The only thing I didn't cover is the degToRad() function....since the Euler XYZ controller
works in radians and humans work in degrees this is a handy conversion function that has been built in.
Now Finger 2 should work properly. All that is left to do is to apply the same expression to the rest of the fingers. First apply expression controllers to the rest of the fingers. Note that two of the fingers rotate around the y-axis and two around the x-axis so apply the expression controller to the proper one. Finger 2 and Finger 3 should use the y-axis and Finger 1 and Finger 4 should use the x-axis.
Now close the window and move the shaft up and down. The claw should open/close around the ball.
|
|
|
|