PDA

View Full Version : Additive rotations - possible?


loocas
05-17-2007, 11:20 PM
Hi there,

I have a problem I can't find solution to. I need to rotate a wheel (a propeller) but based on a multiplier so that it accelerates - rotates at full throttle - deccelerates - and stops.

If I try to wire it, script it or whatever I always end up with a propeller that accelerates but as soon as the multiplier number decreases the propeller stops and then rotates back to 0.0

I need a gradual animation that stops where it deccelerated and not return back to it's original orientation.

I thought of adding up to the propellers rotation value with every frame the animation proceeds, but I have no idea how.

If you know of any better way or any hints, tips, tricks, I'd very much appretiate it!

Thank you in advance! :thumbsup:

Gravey
05-18-2007, 10:49 AM
hey dude check the attached file. I'm not sure why the spinning seems to slow down when the multiplyer stops accelerating but its a start at least!

loocas
05-18-2007, 12:53 PM
Heya, Gravey, thanks a lot for your input man.

However, this is exactly what I end up with no matter what approach I choose (Wiring, Scripting, Constraining...) :sad:

Thtat's why I'm searching for some sort of additive rotational increments.

In your example, if you decrease the multiplier, the propeller stops and then rotates backwards until it stops completely at its original orientation :sad:

Gravey
05-18-2007, 01:25 PM
ah yes i didnt actually try animating it backwards. that is weird! its beyond me why that would happen. maybe someone who's good at math could solve the problem...

rdg
05-18-2007, 02:20 PM
Hi loocas,

this is my version for this issue:


global oldrot
if oldrot == undefined then (
global oldrot = me_start
)
if F <= 0.1 then (
oldrot = newrot = me_start

)else(
newrot = oldrot + me_speed
oldrot = newrot
)
newrot

It works like this:

The old rotation is stored in a global variable 'oldrot'.
On frame 1 the rotation is set to a start value, controlled by a custum attribute.
On any other frame the 'speed' is added to the old rotation and the new rotation is stored in old rotation.

Speed isn't the right term - it is more a increment. But the higher the faster the rotation.

I must admit that I don't like the use of a global variable but all my tries to store the old rotation value into a custom attribute didn't work.

If someone knows a workaround to store the old value, I'd be glad to hear.

This is the standard flash approach of moving stuff around.

Georg

PS: I loved your nokia tutorial.

rdg
05-18-2007, 02:34 PM
But my setup got issues with the start rotation as well ...


Guess thats why I never used it :D

maybe I can find a way to fix this.

Georg

eek
05-18-2007, 03:09 PM
Use a sawtooth wave and control its phase offset by bezier curve with (FA/T) - This will allow for total animator control. If i get time today, i'll try and explain more.

RDG,

The old value could be stored in a struct variable call by a fn, or even refTransform node variable. Eg. $box.refNode.node.'ca'.attribute.. dont know if thats possible. Storing a reference to a node custom attribute value.

rdg
05-18-2007, 03:19 PM
I had a typo in my script-controller.
Also it looks like:
when playing the animation in loop mode max sometimes skips frame 1.
If I stop and goto frame 1 manually everything look ok.


eek:
if you find the time to add some sentences - it would be great - currently I read that there is a easy and professional way but I understand :argh:.
<- I am referring to the sawtooth thing.

-- ---

I stored the oldrot in a #floattab attached to a CA of the propeller.
It updated and if I added a print statement to the script controller it showed the 'right/changing' values but it didn't use it for animation.
I guess there is a lack of very basic knowledge ... but I will fight it down!

Georg

rdg
05-18-2007, 04:08 PM
ok. now I know that a floatTab isn't somekind of fancy 'solve it all' float. its just a array of floats and useless for this.

In the attached file I store the oldrotation value in a custom-attribute.

It only plays in the viewport if the proprties of the scriptcontroller are closed. That's why it didn't work last time I tried.

The oldrotation as a spinner is somewhat diffucult.
If you are trying to animate the increment with auto key the oldrot spinner sets keys also.
The only way to animate the increment is in the trackview -> bad bad bad.

Also the rotation now changed to radians.
0 = 0°. pi/2 = 90° and so on.

Georg

eek
05-18-2007, 04:18 PM
sawtooth - this is just the top off my head (so im in ideas mode) we derive a sawtooth wgoing from 0 to 180, the phase shift is tied to two frame values, a start and an end frame. We use a fn to check if the slidertime or frame is before the first value to start the phase of the wave -before it we set the value to 0. The end value references an updating variable in a struct that the function calls. If the slidertime/f is past the end value we use this updated struct variable - essentially cutting off the rotors mid revolution albeit slowed down.

We could tie in a squared sin wave after this end frame using the struct variable - this would add the little springing part when the rotors stop.

Something like that.

rdg
05-18-2007, 04:27 PM
ah!
I interpreted it in an different way.
But now I interpret it as:
the sawtooth could be used to animate the rotor with an on/off button rather than setting the increment stepping.
Sounds very cool.

You would store such functions in a custom attribute I guess?

-- ---

I now managed to hide the oldrot value from the interface.
But it still gets keyframes when animating the increment value.

Georg

loocas
05-19-2007, 08:45 AM
Thank you very much for the brainstorming, guys, I'll have to dig into these solutions of yours asap!

Thanks again! Much appretiated! :thumbsup:

Aearon
05-19-2007, 09:45 AM
to store the old value, if you need it, cleanly and efficiently as a variable inside the script controller you can use

this.setConstant "varName" value

inside the script controller

loocas
05-20-2007, 09:29 PM
Awesome stuff guys! Let me thank you again!

I finally cracked the problem and added to your solutions so that it fits nicely into my current rig.

http://www.duber.cz/dump/propeller_rig_tst.gif

A brief description of what I've enhanced.

1) I added a shape controller in the scene that controls the speed of the dummy propeller's rotation

2) The shape of the controller indicates the speed ;) for better animation feedback

3) I added an option to be able to rotate the propeller to any desired initial pose to which the whole system returns when on frame 0. You don't have to go to any CA to change a value, you just rotate the propeller as you would when arranging your scene.

4) Fixed the problem when the script controller was adding keyframes automatically when animating in the "AutoKey" mode. <property>.keyable

5) Added a button to reset the propeller's rotation to 0.0, stored in a CA on the controller

So far, there are some name-dependand changes which bother me slightly, but for now, I'm happy with it and when I'm not as sleepy :D I'll fix the name dependency in the CA (the button)

Please, feel free to examine the dummy scene I setup to test the ideas on. It's animated already, just play the slider.

3ds Max 8 scene | 18KB (http://www.duber.cz/dump/propeller_tst_Max8_loocas_001.rar)

Again, thanks a lot for your input guys, I didn't realize such a solution and I'm pretty sure it'd have taken me a loooong time without your help! :thumbsup:

Duncs
05-23-2007, 12:19 PM
Hi Loocas,

This is really interesting, I've been having a similar problem with a rig I'm building for a spherical character. I want to be able to take the rotation from the previous frame and add to it based on the distance travelled. However, when I try to capture the rotation from the previous frame I get circular dependency errors. I'd really like to dig into your dummy scene but, for some reason, I can't get it to download... Is there any chance you could re-post the link?

Many thanks and keep up the good work!

Duncs

loocas
05-23-2007, 03:04 PM
Hi Loocas,

This is really interesting, I've been having a similar problem with a rig I'm building for a spherical character. I want to be able to take the rotation from the previous frame and add to it based on the distance travelled. However, when I try to capture the rotation from the previous frame I get circular dependency errors. I'd really like to dig into your dummy scene but, for some reason, I can't get it to download... Is there any chance you could re-post the link?

Many thanks and keep up the good work!

Duncs

Ooops, sorry, there was an error in the URL, please, try to download the scene file again, it works now ;)

Duncs
05-23-2007, 03:08 PM
Got it - many thanks Loocas:thumbsup:

CGTalk Moderation
05-23-2007, 03:08 PM
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.