question about scrubber max and min values

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

question about scrubber max and min values // Procedural Animation

1  |  

Post by frootee // Sep 17, 2006, 4:02am

Total Posts: 2667
This question is for Dele or another script expert.

I have a 40 year calendar Rosetta scene with a scrubber. The min and max values for the scrubber are -360 and +360, respectively. I would like to make these values roll-over, as in this numerical pattern below:

358 359 0 1 2 3 4 5 6 7 .....

-358 -359 0 -1 -2 -3 -4 -5 -6 -7.....

I don't think there is a quick way to do this with a scrubber, but a script should do nicely.

I think something like this would work:

if ( (input == 360) || (input == -360) )

input = 0;

this is the C/C++ form; would the jscript form be identical? Need to look that up myself!

What do you think?



Post by trueBlue // Sep 17, 2006, 2:23pm

Total Posts: 1761
Hey Frootee:
Do you have your Scrubber control Steps set at 1.000? I just tested this on a Cube with MIN = -360, MAX = 360, and Steps = 1.000. When I enter either -360 or 360 or 0.00, nothing changes. What I think happens here is 0.000 does nothing.

Post by Délé // Sep 17, 2006, 10:51pm

Total Posts: 1374
Hey frootee,

I wouldn't consider myself an expert yet. Still learning. I'll take a stab at it though. :)

What you have there is written properly but as trueBlue stated, it doesn't seem to work. The scrubber seems to have authority over setting the "input" value. I tried a few different ways to update the "input" through script but I was only able to get it to semi-work. It was glitchy.

I'm not sure if this would work for you but I did think of another way to achieve a similar result. You can create a 360 loop with modular arithmetic within the script. Then set the scrubber values to an absurdly high range like -100,000 to 100,000. If you delete the input field on the node and replace it with another output field, the user will only see -359 through 359. I think the only real downfall to this is that the user "must" then use the scrubber as there would be no input field. I suspect most people would use the scrubber anyway though.

See attached script for example.

p.s. If you only wanted it to show 0 through 360 in positives you could write an if/else statement to keep it positive like below:

if (input < 0)
NewInput = input * -1;
NewInput = input;

// Then perform modulus on 360 with "NewInput" in the output statement

params.convalue("output") = NewInput % (360);

Post by frootee // Sep 25, 2006, 7:22am

Total Posts: 2667
thanks trueblue and Dele. I apologize for such a delayed response. I have tried to reply 3 or 4 times but on each occasion some higher priority or another had to take precedence. I finally have a minute to take a breath.

The increment is actually set to 0.17143 (360 degrees / 21 segments / 100)

21 segments = 3 sets of the week days: SU M TU W TH F SA

360 / 21 ~ 17.143

100 is for increased resolution when spinning the cylinder, so, each increment:

17.143 / 100 = 0.17143

To handle the 0 / 360 case, I could use an if/else statement:

if ( (val == 0) || (val == 360) )

val == 0.17143

I see that Norm has done a course on scripting. I may have to get that!

I'll also take a look at what you sent Dele, thanks!

Talk to you soon,

Frootee is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2020. All Rights Reserved.   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn