How to control object rotation speed by custom attribute with smooth rotation adjustments?

How to control object rotation speed by custom attribute with smooth rotation adjustments?

ViperAleks
Advocate Advocate
145 Views
7 Replies
Message 1 of 8

How to control object rotation speed by custom attribute with smooth rotation adjustments?

ViperAleks
Advocate
Advocate

I would like to control rotation of object (helicopter rotor) by a custom attribute parameter. Let say custom attribute parameter changes from 0 to 100. If custom attribute parameter is 0 then there is no rotation on helicopter rotor. If custom attribute parameter is 100 then helicopter rotor is at full rotation speed.  If I make a simple expression for rotation axis as Custom_Attribute_parameter*S  (where S is seconds) then it works fine while custom attribute parameter doesn't change over time. The problem arise when I need smoothly change rotation speed over time, like if helicopter rotor increasing or decreasing rotation over time. Because in my version rotation values change significantly over time depending on the current time, S parameter. Can someone give me a clue how to achieve a smooth rotation speed change in any time on timeline, please?

0 Likes
146 Views
7 Replies
Replies (7)
Message 2 of 8

denisT.MaxDoctor
Advisor
Advisor

Actually, in MAX there is a multiplier curve for this...
Another option is to make a list controller with zero and max speed values, and use the second one's weight to control.

0 Likes
Message 3 of 8

ViperAleks
Advocate
Advocate

Thank you for your reply. I understood your second option and I will give it a try. But I am not sure what you mean by multiplier curve. Could you explain it, please?  

0 Likes
Message 4 of 8

denisT.MaxDoctor
Advisor
Advisor

denisTMaxDoctor_0-1756691996188.png

delete objects

b = box name:#blades width:100 length:10 height:3 
ss = b.rotation.controller[3].controller = float_script()
ss.addconstant #max_speed 0.1
ss.setexpression "-max_speed * F"

power = bezier_float()
addMultiplierCurve ss power
t_0000 = addnewkey power 0
t_0000.value = 0
t_0050 = addnewkey power 50   
t_0050.value = 1
t_0100 = addnewkey power 100   
t_0100.value = 0
0 Likes
Message 5 of 8

denisT.MaxDoctor
Advisor
Advisor

If you still want CA:

denisTMaxDoctor_1-1756693816012.png

delete objects
b = box name:#blades width:100 length:10 height:3 
ss = b.rotation.controller[3].controller = float_script()
ss.addconstant #max_speed 0.1

ca_speed = attributes ca_speed attribid:#(0x10101, 0xa0a0a)
(
	parameters params rollout:params
	(
		speed type:#float default:0 animatable:on ui:ui_speed
	)
	rollout params "Speed Control" 
	(
		spinner ui_speed "Speed:" type:#float range:[-1,1,0] scale:0.001 fieldwidth:60 align:#right
	)
	on create do 
	(
		speed.controller = bezier_float()
	)

)

custattributes.add b ca_speed baseobject:on
ss.addtarget "speed_val" b.baseobject.ca_speed[#speed]
ss.setexpression "-max_speed * F * speed_val"
0 Likes
Message 6 of 8

ViperAleks
Advocate
Advocate

Thank you again for your help. Unfortunately, I was not able to achieve expected result using power curve or expression. The main problem is that when I need to start rotation from 0 to some value and my animation is in frame 2000, for example, then I have a multiplier F (frames) as big value, and rotation jumps from 0 to the high degree suddenly. I cannot get smooth rotation start in this case. All these sudden rotation changes not noticeable during preview, but they are very noticeable during render with the motion blur.

0 Likes
Message 7 of 8

denisT.MaxDoctor
Advisor
Advisor

Your question concerned a technical solution, not an algorithmic one. Technically, I showed you how to do it... but from an algorithmic point of view, you need to control not the absolute value (as shown in my examples), but the relative value (delta) and add it to some initial value.

0 Likes
Message 8 of 8

ViperAleks
Advocate
Advocate

This is true. I came to conclusion that I have to play with current frame and next frame to adjust rotation speed. If I have a constant rotation speed then

next_frame_rotation_angle_delta  =  current_frame_rotation_angle_delta * 1

If I need to slow down rotation then multiplier should be < 1. If I need to increase rotation then multiplier should be > 1.

 

0 Likes