PDA

View Full Version : expressions watch animation


gunner89
01-10-2011, 09:48 AM
Hello, i am creating a clock animation for a watch that i am modelling that is created and modeled by python code and expressions, i have done it all and got the hour hand to be correct but i cant figure out what figures i should be putting for the minOffset and the secOffset. Any help would be greatly appreciated. Thanks


#
# Hour hand
#
cmds.rotate(0,0,-timeNow.tm_hour*30,hourHand[0])
hourOffset=-timeNow.tm_hour*30-timeNow.tm_min*0.5
cmds.expression( o='hourHand[0]', s="hourHand.rotateZ=-frame/3000+%d"%hourOffset)

#
# minute hand
#
cmds.rotate(0,0,-timeNow.tm_min*1,minHand[0])
minOffset=-timeNow.tm_min*1-timeNow.tm_min*0.5
cmds.expression( o='minHand[0]', s="minHand.rotateZ=-frame/250+%d"%minOffset)

#
# second hand
#
cmds.rotate(0,0,-timeNow.tm_sec*1,secHand[0])
secOffset=-timeNow.tm_sec*1-timeNow.tm_min*0.5
cmds.expression( o='secHand[0]', s="secHand.rotateZ=-6*frame/25+%d"%secOffset)

#
# applying the expressions
#
cmds.expression( o='secHand[0]', s='secHand.rotateZ=-6*frame/25' )
cmds.expression( o='minHand[0]', s='minHand.rotateZ=-1*frame/250' )
cmds.expression( o='hourHand[0]', s='hourHand.rotateZ=-30*frame/3000' )

zoharl
01-13-2011, 04:03 AM
You need the angles for the three clock hands.
Initialize the three clock hands to 12, and the angle of each one to zero.

Now for s seconds you need the rotation angle:

sec_angle = s/60*2*pi

For m minutes and s seconds:

min_angle = (m/60 + s/60/60)*2*pi

For h hours m minutes and s seconds:

hour_angle = (h/12 + m/60/12 + s/60/60/12)*2*pi

CGTalk Moderation
01-13-2011, 04:03 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.