Problem Multiple animations for one set of mesh groups

Zatnikitelman

Addon Developer
Addon Developer
Joined
Jan 13, 2008
Messages
2,303
Reaction score
6
Points
38
Location
Atlanta, GA, USA, North America
I'm working on an animated launch pad and have run across a problem. I have a crew access arm that both needs to translate up and down, and then rotate out of the way. I have tried both making the rotation and the translation parents of each other without success, as well as declaring them both static (not child animations of anything). Currently, I'm using Orbiter's semi-automatic animation system.
Here's the code as of now declaring the two:
Code:
    static UINT crewarm2groups[3] = {10,11,12};
    static MGROUP_TRANSLATE crewarmtranslate_ (0, crewarm2groups, 3, _V(0,26.75,0));
    crewarmtranslate = CreateAnimation(0.0);
    crewarmtrans = AddAnimationComponent(crewarmtranslate, 0, 1, &crewarmtranslate_);

    static UINT crewarmgroups[3] = {10,11,12};
    static MGROUP_ROTATE crewarmrot_(0,crewarmgroups, 3, _V(-10.26, 54.553, -5.927), _V(0,1,0), (float)(0.5*PI));
    crewarm = CreateAnimation(0.0);
    crewarmbase = AddAnimationComponent (crewarm, 0, 1, &crewarmrot_);
Currently, they're setup as I last tried, making them both parentless animations.
Should I use the manual animation with clbkAnimate() for this? Or am I just missing something here? Are there any examples of multiple animations applied to the same mesh groups anywhere?
Thanks for any help,
Zatman
 
If you know that the rotation is only ever applied after the translation has completed to end state 1, it's quite straightforward:

Let the translation stage run over the first half of the animation (or more generally, over a fraction split between 0 and 1), and let the rotation run over the second part of the same animation:

Code:
double split = 0.5;
static MGROUP_TRANSLATE crewtrans = ...
static MGROUP_ROTATE crewrot = ...
crewarm_anim = CreateAnimation(0,0);
crewarm_anim_comp1 = AddAnimationComponent (crewarm_anim, 0, split, &crewtrans);
crewarm_anim_comp2 = AddAnimationComponent (crewarm_anim, split,1, &crewrot);
If you set the animation state to anything between 0 and split, it will perform the translation. A state between split and 1 will perform the rotation, with translation and end position. However, you must take care to define the rotation reference for crewrot correctly, referring to the endpoint of the translation.

This only works if the rotation is always performed at the end point of the translation. If you want to allow the rotation at arbitrary translation positions, then you must make the rotation a child of the translation (in practical terms, this means that the translation parent automatically takes care of transforming the rotation reference of its child rotation).
 
Thanks Martin! It seems to work so far. However, I have another problem, at the end of the arm is another translation animation, a whiteroom, and it translates with the arm, but it lags behind it by about 0.5, meaning, when the arm is fully raised, the whiteroom is about halfway up to where it should be.
The code below shows how I currently have the 3 animations set up.
Code:
//Crew arm translate up
	static UINT crewarm2groups[3] = {10,11,12};
	static MGROUP_TRANSLATE crewarmtrans(0, crewarm2groups, 3, _V(0,13.375,0));
	crewarmtranslate = CreateAnimation(0.0);
	crewarmtrans_ = AddAnimationComponent(crewarmtranslate, 0, 1, &crewarmtrans);

	//Crew arm rotate
	static UINT crewarmgroups[3] = {10,11,12};
	crewarmrot = new MGROUP_ROTATE (0,crewarmgroups, 3, _V(-10.26, 54.553, -5.927), _V(0,1,0), (float)(0.5*PI));
	crewarm = CreateAnimation(0.0);
	crewarmbase = AddAnimationComponent (crewarm, 0, 1, crewarmrot, crewarmtrans_);

	//Crew arm white room translate
	static UINT crewarm3groups[5] = {5,6,7,8,9};
	whiteroom = new MGROUP_TRANSLATE(0,crewarm3groups,5,_V(0,2.6,0));
	whiteroomtranslate = CreateAnimation(0.0);
	AddAnimationComponent(whiteroomtranslate,0,1,whiteroom,crewarmbase);
I even tried making whiteroom a rotation animation just to see if it was something weird with translations having translation parents, but I got the same result. So far the first translation animation is the only one I'm animating in code.
Thanks for any help!
 
Grr, sorry, I'm still having problems. I've tried making the white room's mesh groups part of the translation animation, and they stay with the main arm, but I don't get any arm rotation however. Here's the three animation definitions as they stand now:
Code:
        //Crew arm translate up
	static UINT crewarm2groups[8] = {10,11,12,5,6,7,8,9};
	static MGROUP_TRANSLATE crewarmtrans(0, crewarm2groups, 8, _V(0,13.375,0));
	crewarmtranslate = CreateAnimation(0.0);
	crewarmtrans_ = AddAnimationComponent(crewarmtranslate, 0, 1, &crewarmtrans);

	//Crew arm rotate
	static UINT crewarmgroups[8] = {10,11,12,5,6,7,8,9};
	crewarmrot = new MGROUP_ROTATE (0,crewarmgroups, 8, _V(-10.26, 54.553, -5.927), _V(0,1,0), (float)(0.5*PI));
	crewarm = CreateAnimation(0.0);
	crewarmbase = AddAnimationComponent (crewarm, 0, 1, crewarmrot, crewarmtrans_);

	//Crew arm white room translate
	static UINT crewarm3groups[5] = {5,6,7,8,9};
	whiteroom = new MGROUP_TRANSLATE(0,crewarm3groups,5,_V(0,1.3,0));
	whiteroomtranslate = CreateAnimation(0.0);
	AddAnimationComponent(whiteroomtranslate,0,1,whiteroom,crewarmbase);
 
Back
Top