SDK Question Animation in a sequence

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
6,215
Reaction score
666
Points
188
Location
Dallas, TX
What is the best way to do a sequence of animations?

For instance The James Webb Ideally when either a key is pressed or detached a sequence starts.
Key pressed ->animation1 begins-> animation 1 ended so start animation2,.......
or use of a timer
At start timer =0;
when the key pressed timer starts timer = timer =1?
When the timer gets to 100 animation1 starts
when timer hits 150 animation2 starts,......

And I suppose that before the 2nd,3rd,..... animation start the one before must be ended.

I suppose also you could have keys assigned to the animation but then one must know animation1 must be done before animation2,.......
 

N_Molson

Addon Developer
Addon Developer
Donator
Addon List Curator
Joined
Mar 5, 2010
Messages
7,504
Reaction score
661
Points
188
Location
Toulouse
I don't think you need a timer, what you want to check is the value of the animation status (number between 0 and 1). When defining the animation you can define where is the 'neutral' state of the anim, like 0.5 for something like a rudder, 0 for something that simply deploys.

Keeping track of those values should very much solve your problems, like 'start anim2 only if anim1 value = 1'.

Also keep in mind you can use a hierarchy with the parent system (see Atlantis RMS)
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
6,215
Reaction score
666
Points
188
Location
Dallas, TX
Thanks. The timer would be more like real life. Where at 45 minutes from separation. animation starts at 2 hours,.......

Keeping track of those values should very much solve your problems, like 'start anim2 only if anim1 value = 1'.
Yes. I guess really all the animations are a one time thing.
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
9,621
Reaction score
452
Points
173
Location
between the planets
I'm not sure how you intend this to go. Do you just want to start a specific animation a specific amount of time into the sim? If yes, timers are fine.

If you really want to sequence animations, where one ending is a criterium for the next one starting, don't use a timer, that way madness lies! I would recommend making a state machine in that case.
 

N_Molson

Addon Developer
Addon Developer
Donator
Addon List Curator
Joined
Mar 5, 2010
Messages
7,504
Reaction score
661
Points
188
Location
Toulouse
OK yes it's more like a launch sequence, something automated and computer-controlled.

Then yes, a timer is a way to do it ; make sure you save the timer value in the scenario file.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
6,215
Reaction score
666
Points
188
Location
Dallas, TX
Thanks. I might redo the James Webb. So that press a key and timer starts and then animation goes when it is suppose to go.
And press a key and the animation goes in sequence.,......
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,627
Reaction score
151
Points
63
Just as a note in case it is not clear: When you talk about "timers", please do not use something like a free running windows-timer!
As the simulation can be paused, run with "accelerated time" or "decelerated time", those timers will not work.

Your animations will be progressed in either clbkPreStep or clbkPostStep, both having the parameters simt, simdt and mjd.
simt is a "always rising" value that might not always step up at the same rate (as frame rate is not constant, or the CPU is doing something else),
simdt is the delta since the last call, also varying due to the same effects,
mjd is the simulation-time stamp value which is also "always rising".
(See also the documentation of those methods in Orbitersdk\include\VesselAPI.h)

So, to start your timer at a specific time, you could compare against a specific mjd (plus minus tolerance),
remember that state and update your animation steps according to the time it should take until the mjd has reached that (end-)time-stamp.
At that point your animation should have stepped from 0.0 through to 1.0 (for a regular deploy/retract action).

If for example the callback was called (on a theoretical very slow machine) 4 times during a one minute (simulation-time),
each step would have increased your animation value by 0.25.
Usually those steps are much smaller though ;)
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
6,215
Reaction score
666
Points
188
Location
Dallas, TX
This sequence is what I am trying to do.
dIU13Hr.jpg

FpjxKpz.jpg

8siZvXJ.jpg


I can do it like the rms but the rms has different animation for the joints so they can move independent.. I would like 1 single animation

The parent (DISH1BASESHOLUDER) should rotate the whole assembly 180 degrees.
next step the assembly rotates 90 and the DISH1BASEFOREARM rotates 90

static UINT DISH1BASESHOLUDER[1] = { GRP_DISH1ARM };//parent rotate 180 static UINT DISH1BASEELBOW[5] = { GRP_DISH1ARM2,GRP_DISH1BASE4,GRP_DISH1BASE1,GRP_DISH1BASE2,GRP_DISH1BASE };//elbow static UINT DISH1BASEFOREARM[1] = { GRP_DISH1ARM1 };// dish1_anim[0] = new MGROUP_ROTATE (0, DISH1BASESHOLUDER, 1, _V(0, 1.442391, -1.113871), _V(0, 0, 1), (float)(180 * RAD));//parent ROTATE WHOLE ASSEBLY 180 dish1_anim[1] = new MGROUP_ROTATE(0, DISH1BASEFOREARM, 1, _V(0, 1.442391, -1.064), _V(1, 0, 0), (float)(-90 * RAD)); dish1_anim[2] = new MGROUP_ROTATE(0, DISH1BASEELBOW, 5, _V(0, 1.442391, .16), _V(1, 0, 0), (float)(-90 * RAD)); PARENTDISH1 = AddAnimationComponent(anim_DISH, 0, .5, dish1_anim[0]);//rotate 180 PARENTDISH1A=AddAnimationComponent(anim_DISH, .5, 1, dish1_anim[2], PARENTDISH1);// rotate elbow 90 PARENTDISH1B = AddAnimationComponent(anim_DISH, .5, 1, dish1_anim[1], PARENTDISH1A);// rotate forearm and assembly 90
 
Top