C++ Question Animation: Parent

Dany

Addon-Dev F.O.I.
Joined
Apr 7, 2011
Messages
18
Reaction score
0
Points
0
Hi, I have a new problem.
It 's always the last project (http://www.orbiter-forum.com/showthread.php?t=30243) but they are different topics, so I decided to open a new thread, I hope I have done well.

I created two animations, where the second is connected to the first.
The second, however, is divided into two separate actions, here's the problem, where both are connected to the first animation. Now they are linked together.
Here is the animation:
Code:
void MyVessel::DefineAnimations()
{
	ANIMATIONCOMPONENT_HANDLE parent;
	
	// ***** GraArt animation *****
	static UINT RuotaGrp[23] = {8,9,11,12,13,14,17,18,25,26,29,30,33,34,35,36,43,84,85,87,88,89,90};
	static MGROUP_ROTATE Ruota (0, RuotaGrp, 23,
		_V(0, 0, 0), _V(0, 0, 1), (float)(-360*RAD));
	
	static UINT GirosGrp[1] = {40};
	static MGROUP_ROTATE Giros (0, GirosGrp, 1,
		_V(0, 0, 0), _V(0, 0, 1), (float)(1080*RAD));

	anim_GraArt = CreateAnimation (0);
	parent = AddAnimationComponent (anim_GraArt, 0, 1, &Ruota);
	AddAnimationComponent (anim_GraArt, 0, 1, &Giros);

	// ***** Ascen1 animation *****
	static UINT brac1Grp[1] = {44};
	brac1[0] = new MGROUP_TRANSLATE  (0, brac1Grp, 1, _V(0,-4.5,0));
	
	static UINT brac2Grp[1] = {45};
	brac1[1] = new MGROUP_TRANSLATE  (0, brac2Grp, 1, _V(0,-4.5,0));
	
	static UINT brac3Grp[1] = {46};
	brac1[2] = new MGROUP_TRANSLATE  (0, brac3Grp, 1, _V(0,-4.5,0));
	
	static UINT brac4Grp[1] = {47};
	brac1[3] = new MGROUP_TRANSLATE  (0, brac4Grp, 1, _V(0,-4.5,0));
	
	static UINT brac5Grp[1] = {48};
	brac1[4] = new MGROUP_TRANSLATE  (0, brac5Grp, 1, _V(0,-4.5,0));
	
	static UINT brac6Grp[1] = {49};
	brac1[5] = new MGROUP_TRANSLATE  (0, brac6Grp, 1, _V(0,-4.5,0));
	
	static UINT brac7Grp[1] = {50};
	brac1[6] = new MGROUP_TRANSLATE  (0, brac7Grp, 1, _V(0,-4.5,0));
	
	static UINT brac8Grp[1] = {51};
	brac1[7] = new MGROUP_TRANSLATE  (0, brac8Grp, 1, _V(0,-4.5,0));
	
	static UINT brac9Grp[1] = {52};
	brac1[8] = new MGROUP_TRANSLATE  (0, brac9Grp, 1, _V(0,-4.5,0));
	
	static UINT term1Grp[4] = {7,28,32,83};
	brac1[9] = new MGROUP_TRANSLATE  (0, term1Grp, 4, _V(0,-6,0));
	
	static UINT Contr1Grp[1] = {62};
	Contr1[0] = new MGROUP_TRANSLATE  (0, Contr1Grp, 1, _V(0,4.5,0));
	
	static UINT Contr2Grp[1] = {63};
	Contr1[1] = new MGROUP_TRANSLATE  (0, Contr2Grp, 1, _V(0,4.5,0));
	
	static UINT Contr3Grp[1] = {64};
	Contr1[2] = new MGROUP_TRANSLATE  (0, Contr3Grp, 1, _V(0,4.5,0));
	
	static UINT Contr4Grp[1] = {65};
	Contr1[3] = new MGROUP_TRANSLATE  (0, Contr4Grp, 1, _V(0,4.5,0));
	
	static UINT Contr5Grp[1] = {66};
	Contr1[4] = new MGROUP_TRANSLATE  (0, Contr5Grp, 1, _V(0,4.5,0));
	
	static UINT Contr6Grp[1] = {67};
	Contr1[5] = new MGROUP_TRANSLATE  (0, Contr6Grp, 1, _V(0,4.5,0));
	
	static UINT Contr7Grp[1] = {68};
	Contr1[6] = new MGROUP_TRANSLATE  (0, Contr7Grp, 1, _V(0,4.5,0));
	
	static UINT Contr8Grp[1] = {69};
	Contr1[7] = new MGROUP_TRANSLATE  (0, Contr8Grp, 1, _V(0,4.5,0));
	
	static UINT Contr9Grp[1] = {70};
	Contr1[8] = new MGROUP_TRANSLATE  (0, Contr9Grp, 1, _V(0,4.5,0));
	
	static UINT term2Grp[1] = {71};
	Contr1[9] = new MGROUP_TRANSLATE  (0, term2Grp, 1, _V(0,5.2,0));
	
	anim_Ascen1 = CreateAnimation (0);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[0], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[1], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[2], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[3], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[4], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[5], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[6], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[7], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[8], parent);
	AddAnimationComponent (anim_Ascen1, 0, 1, brac1[9], parent);

	parent = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[0], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[1], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[2], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[3], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[4], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[5], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[6], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[7], parent);
	parent = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[8], parent);
	AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[9], parent);
}

I would like to "brac1[0]" and "Contr1[0]" connected to "&Rotate".
While now "Contr1[0]" is connected to "brac1[8]".
Considering that I have to do a third animation identical to the second, with eventual "brac2[0]" and "Contr2[0]" connected to "&Rotate".

How I should to do, thanks. :)
 
What about creating a second parent handle and storing "parent" there before overwriting it?
 
Ok, here's how I did it:
Code:
void MyVessel::DefineAnimations()
{
	
	// ***** GraArt animation *****
	static UINT RuotaGrp[23] = {8,9,11,12,13,14,17,18,25,26,29,30,33,34,35,36,43,84,85,87,88,89,90};
	static MGROUP_ROTATE Ruota (0, RuotaGrp, 23,
		_V(0, 0, 0), _V(0, 0, 1), (float)(-360*RAD));
	
	static UINT GirosGrp[1] = {40};
	static MGROUP_ROTATE Giros (0, GirosGrp, 1,
		_V(0, 0, 0), _V(0, 0, 1), (float)(1080*RAD));

	anim_GraArt = CreateAnimation (0);
	ANIMATIONCOMPONENT_HANDLE parent = AddAnimationComponent (anim_GraArt, 0, 1, &Ruota);
	AddAnimationComponent (anim_GraArt, 0, 1, &Giros);

	// ***** Ascen1 animation *****
	static UINT brac1Grp[1] = {44};
	brac1[0] = new MGROUP_TRANSLATE  (0, brac1Grp, 1, _V(0,-4.5,0));
	
	static UINT brac2Grp[1] = {45};
	brac1[1] = new MGROUP_TRANSLATE  (0, brac2Grp, 1, _V(0,-4.5,0));
	
	static UINT brac3Grp[1] = {46};
	brac1[2] = new MGROUP_TRANSLATE  (0, brac3Grp, 1, _V(0,-4.5,0));
	
	static UINT brac4Grp[1] = {47};
	brac1[3] = new MGROUP_TRANSLATE  (0, brac4Grp, 1, _V(0,-4.5,0));
	
	static UINT brac5Grp[1] = {48};
	brac1[4] = new MGROUP_TRANSLATE  (0, brac5Grp, 1, _V(0,-4.5,0));
	
	static UINT brac6Grp[1] = {49};
	brac1[5] = new MGROUP_TRANSLATE  (0, brac6Grp, 1, _V(0,-4.5,0));
	
	static UINT brac7Grp[1] = {50};
	brac1[6] = new MGROUP_TRANSLATE  (0, brac7Grp, 1, _V(0,-4.5,0));
	
	static UINT brac8Grp[1] = {51};
	brac1[7] = new MGROUP_TRANSLATE  (0, brac8Grp, 1, _V(0,-4.5,0));
	
	static UINT brac9Grp[1] = {52};
	brac1[8] = new MGROUP_TRANSLATE  (0, brac9Grp, 1, _V(0,-4.5,0));
	
	static UINT term1Grp[4] = {7,28,32,83};
	brac1[9] = new MGROUP_TRANSLATE  (0, term1Grp, 4, _V(0,-6,0));
	

	static UINT Contr1Grp[1] = {62};
	Contr1[0] = new MGROUP_TRANSLATE  (0, Contr1Grp, 1, _V(0,4.5,0));
	
	static UINT Contr2Grp[1] = {63};
	Contr1[1] = new MGROUP_TRANSLATE  (0, Contr2Grp, 1, _V(0,4.5,0));
	
	static UINT Contr3Grp[1] = {64};
	Contr1[2] = new MGROUP_TRANSLATE  (0, Contr3Grp, 1, _V(0,4.5,0));
	
	static UINT Contr4Grp[1] = {65};
	Contr1[3] = new MGROUP_TRANSLATE  (0, Contr4Grp, 1, _V(0,4.5,0));
	
	static UINT Contr5Grp[1] = {66};
	Contr1[4] = new MGROUP_TRANSLATE  (0, Contr5Grp, 1, _V(0,4.5,0));
	
	static UINT Contr6Grp[1] = {67};
	Contr1[5] = new MGROUP_TRANSLATE  (0, Contr6Grp, 1, _V(0,4.5,0));
	
	static UINT Contr7Grp[1] = {68};
	Contr1[6] = new MGROUP_TRANSLATE  (0, Contr7Grp, 1, _V(0,4.5,0));
	
	static UINT Contr8Grp[1] = {69};
	Contr1[7] = new MGROUP_TRANSLATE  (0, Contr8Grp, 1, _V(0,4.5,0));
	
	static UINT Contr9Grp[1] = {70};
	Contr1[8] = new MGROUP_TRANSLATE  (0, Contr9Grp, 1, _V(0,4.5,0));
	
	static UINT term2Grp[1] = {71};
	Contr1[9] = new MGROUP_TRANSLATE  (0, term2Grp, 1, _V(0,5.2,0));
	
	anim_Ascen1 = CreateAnimation (0);
	ANIMATIONCOMPONENT_HANDLE parent1 = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[0], parent);
	parent1 = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[1], parent1);
	parent1 = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[2], parent1);
	parent1 = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[3], parent1);
	parent1 = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[4], parent1);
	parent1 = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[5], parent1);
	parent1 = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[6], parent1);
	parent1 = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[7], parent1);
	parent1 = AddAnimationComponent (anim_Ascen1, 0, 1, brac1[8], parent1);
	AddAnimationComponent (anim_Ascen1, 0, 1, brac1[9], parent1);

	ANIMATIONCOMPONENT_HANDLE parent2 = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[0], parent);
	parent2 = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[1], parent2);
	parent2 = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[2], parent2);
	parent2 = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[3], parent2);
	parent2 = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[4], parent2);
	parent2 = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[5], parent2);
	parent2 = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[6], parent2);
	parent2 = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[7], parent2);
	parent2 = AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[8], parent2);
	AddAnimationComponent (anim_Ascen1, 0, 1, Contr1[9], parent2);
}
It 'so exact, right? To me it works well.
Thank you very much.:cheers:

---------- Post added at 08:37 PM ---------- Previous post was at 01:49 PM ----------

Here are the animations I've done. The project is still under development, mesh and textures are to be finished.
 
Last edited:
Back
Top