PDA

View Full Version : rotation in 2 dimensions script


djlane
12-31-2004, 10:00 AM
i`ve been working on a script controller that is supposed to work out how much to rotate a ball when its parent dummy is translated in the scene. I`ve seen examples which rely on path constraints or the reactor simulation, but I wanted a solution which allowed me to keyframe a node by hand .

unfortunately my scripting isn't so good and the results are not very useful!



------------------------------------------------------
dependsOn $dummy_move01

--create and initialize variables
radius = 26.766
global xold = 0.0
global yold = 0.0
xnew = $dummy_move01.pos.x
ynew = $dummy_move01.pos.y


--this works out the distance the dummy has traveled using Pythagoras Theorem
distance = sqrt(((xnew - xold)*(xnew - xold)) + ((ynew - yold) *(ynew - yold)))


-- update xold and yold variables with the dummys last position
xold = $dummy_move01.pos.x
yold = $dummy_move01.pos.y

--now the distance is known this next formula rotates the ball the right number of times
output = (distance / radius)* pi / 2)
output


-------------------------------------------------------------------



In natural language i want my scriptcontroller to basically work out:

record where It was and where it went in 3d space.
Then work out how far on the grid it traveled.
then rotate the ball the right number of times based on the distance and its radius.

Has anybody else tackled this problem? if so could anybody give me some tips or examples to make this work.maybe this is not possible with the scriptcontroller?

max scene:
http://www.callnetuk.com/home/djlane/script rot-06.max

Thanks for reading

Dan

CGTalk Moderation
01-20-2006, 07:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.