Notifications
Clear all

[Closed] Self-reference (at time), possible?

So I wanted to test whether you can animate a rotation with a speed value, but encountered a problem and wanted to see if this is simply impossible in 3ds max due to illegal self-reference, or if there is a workaround.

What I want here is to make the Z rotation look at its previous value, and then add the spin speed value to it. This is put into a Script Float controller on the object:

at time (currentTime-1)
            (
            dragRot = thisObj.rotation.controller.Z_Rotation
            )
            dragRot + spinSpeed

I know 3ds max usually doesn’t like self-referencing like this, but when using at time it makes 3ds max crash instantly.

Is something like this simply impossible in 3ds max, or is there another way to do it?

Thanks.

6 Replies
1 Reply
 lo1
(@lo1)
Joined: 10 months ago

Posts: 0

This doesn’t really make sense. 3dsmax asks your script controller what the value is at time T. You tell it that the result depends on the value at T-1. So it asks the controller what the value is at T-1, you tell it that the result depends on the value at T-2. This doesn’t automagically stop at T==0, since max supports negative frames. Max just keeps going deeper into recursion until it crashes due to stack overflow.

A really easy way to give a constant rotation speed on an axis is to give it a key at frame 1 with the speed you want, and set the out of range type to relative repeat or linear.

There are cases where a history dependent solution is necessary, but this (a) is usually done in a loop, not using recursion, and (b) must supply a base value to start from.

Yeah I see the problem now with my first “solution”.
But I’m also not looking for a constant speed. I know out-of-range is the quickest and easiest way to make something continue at a constant rate, but what I want is a way to animate the rate, in this case rotation, like a wheel or propeller accelerating/decelerating.

Multiply an animation curve (or referencing currentTime) really doesn’t work since anything below 1.0 will reverse the rotation until it halts at 0.0.

So I need the rotation to work in two steps:
First look at what the previous value was, and in the next step add the current spin speed value to it, then loop the procedure. It needs to keep these two steps separated.

Perhaps this is impossible in 3ds max, I’m no max guru, but in principle it means going from 1.0 to 0.0 will slowly make the rotation come to a stop, without reversing the rotation in any way.

Possible, or completely unpossible?

 lo1

you would go along the lines of this:


local val = 0
for t = 0 to currentTime do
(
    val += at time t (yourSpeedValue)
)
return val

Thanks, but your solution still gives me a reverse rotation when I animate the spin value. Here are the curves:

Spin speed curve:

The result:

How I want the curve:

Here is the scene (saved as max2013):
https://dl.dropboxusercontent.com/u/2033376/3d/rotationTest.max

Sorry for tedious questions, I wish I could solve this on my own.

 lo1

you need to assign your speed parameter as a controller, otherwise it is not affected by ‘at time’ contexts, and is always reporting the same speed throughout the loop.

See attached image.

I’ve also added a steps parameter for increased accuracy.

Expect this to go slower when (a) more steps are used and (b) you are calculating later frames, (e.g. frame 300 will take 100 times more time to calculate than frame 3.)

Thanks a lot for the time and effort explaining this. Big thanks!