View Full Version : Values with history... how to make?

03 March 2008, 12:25 PM

I've been thinking in general about how to create simple rigs which store values on top of old value.

What i mean is pupil size which starts getting smaller when lids are open, and when i close the eyelids, it starts to get bigger. This i got working quite well. (link to older test)

I also have a concept of sticky lips with this idea (it could be used to other things too...), but i seem to run into some problems:

I have object with morpher, and one morph target "Open"

Then i have a point, which has a custom attribute which should store the values. When open mouth is more open in current frame compared to previous frame, i add to the value. And when it's the other way, i substract from the value.

I have created variables for both. "openIs" and "openWas". Later has tick offset to measure value in earlier time.

Script itself is not done, since i have tried to isolate the problem... Script is stored in a custom attribute which i added to a point, and "counter" is another custom attribute in that same point.

if openIs > openWas then
$point.modifiers[1].counter += 1
if openIs < openWas then
$point.modifiers[1].counter -= 1

The problem is, that "Counter" custom attribute evaluates immediately to value of 16 in the frame 0, not to one?

So far i had the impression that script controllers are evaluated once in every frame? I think i'll run more tests on this thing.
If someone has experience in creating similar kind of scripts, i'd be interested in hearing your solutions.


03 March 2008, 01:59 AM
Use a variable, i a custom attribute or a struct. e.g.

struct _test

vala = 0.0,

fn test val =

case of
(vala < -10.0): vala = 10.0
(vala > 10.0):vala = -10.0
if val > 0.0 then
vala += (0.01 * val) -- ie it'll open quicker the eyes open.
vala -= (0.01 * val) -- ie it'll open quicker the eyes open.


test = _test()

then call the function in a script controller referencing a variable for 'val' - vala is a instanced variable you can assign something to. eg.

test.test sliderVal.value - this is script

myRadius.value = test.vala -- this is variable.

you could do the same exact thing with a custom attribute variable.

03 March 2008, 07:27 PM

Thanks eek!

So the solution seems to be to put actual evaluation of value to custom attribute, outside script controller, then then send some values to this fuction, and then get it back to script controller, to serve as final value!
I abandoned the struct, and just used function inside attribute definition, as i don't know how instance the structure once everytime scene is opened or playback is started from the frame zero.

I quickly made a test, and it seems to be working a lot better compared to my version, next i'm going to try it on rigged object, if everything goes ok!

What i did; i made a teapot1, which moves. Then i made teapot2, which then i gave script controller, and added mesh base level custom attribute, which contained a variable "valA" , and function. Then i call this function from teapot2's script controller, and send the value to:
objTeapot2.myCA.testFunction value, and second line of script is just objTeapot2.myCA.valA. When teapot1 moves up or down is add or substract from valA.

Other notes:

I have noticed couple of things; panning trackview causes script controllers value curve to move and fly away. Moving in time restores it.

Another thing is that when i play timerange once from 0-100, i get for example 10.1 for teapot2's location in the frame 100. I play animation once again, this time i might get 10.2.

Bit strange that i end up in slightly different values? This happened earlier too. I'm suspecting that my method of "zeroing" this stored value might be the cause. When ever the timeline is played from the beginning i zero valA with "if currenttime == 0f then valA = 0.0".

My earlier own setup caused horrible flicker, and it seemed like circular dependency kind of problem, yet max didn't give any warnings. So this is definitely progress!

I just wonder if these problems are just features of 2008 version...?

Have you noticed such anomalies?

I guess this can be done in zillion ways, i'm thinking maybe my method is the cause for these bugs.

I'll see if i get this working properly! If you want i can send the scene file to you.

CGTalk Moderation
03 March 2008, 07:27 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.