Programming Question Help with parent/child animations

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
288
Reaction score
67
Points
28
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
Hey there guys, I am trying to make an International Space Station addon in which the solar panel truss rotates along the X-axis, and the individual panels rotate along the truss's Y-axis, (as the truss's starting angle is 90 degrees). I am sure you are all familiar with the International Space Station, and know what I mean. Anyways, I am having a lot of trouble getting the animations to work. I have the truss rotating along the X-axis as it should, but the individual panels rotate along the ship's Y-axis ALWAYS, regardless of what angle the truss is at, this is without making the truss animation a parent for the solar panels, when I do make it the parent animation, the solar panels' behaviour is very strange. I find it difficult to explain what exactly is going on, its almost as if the animation is partly rotating with the truss, and partly not.. Anyways here's my code for DefineAnimations:

Code:
void ISS::DefineAnimations (void)
{
		// ITS truss rotation
	static UINT	meshgroup_truss1[21]	= {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
	static UINT	meshgroup_truss2[21]	= {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
	static MGROUP_ROTATE	mgt_truss1 (Mesh_ITSL, meshgroup_truss1, 21, _V(0,0,0), _V(1,0,0), (float)PI*2); 
	static MGROUP_ROTATE	mgt_truss2 (Mesh_ITSR, meshgroup_truss2, 21, _V(0,0,0), _V(1,0,0), (float)PI*2);
	anim_truss		= CreateAnimation (0.0);
	ach_truss		= AddAnimationComponent (anim_truss, 0.0f, 1.0f, &mgt_truss1);
	AddAnimationComponent (anim_truss, 0.0f, 1.0f, &mgt_truss2);

		// ITS 1 A
	static UINT	meshgroup_ITSR1A[3]	= {9,19,20};
	static MGROUP_ROTATE	mgt_ITSR1A (Mesh_ITSR, meshgroup_ITSR1A, 3, _V(6.087421,0,-0.785489), _V(0, 1, 0), (float)PI*2);
		// ITS 1 B
	static UINT	meshgroup_ITSR1B[3]	= {18,17,16};
	static MGROUP_ROTATE	mgt_ITSR1B (Mesh_ITSR, meshgroup_ITSR1B, 3, _V(21.16185,0,-0.785489), _V(0,1,0), (float)PI*2);
		// ITS 2 A
	static UINT	meshgroup_ITSR2A[3]	= {12,11,10};
	static MGROUP_ROTATE	mgt_ITSR2A (Mesh_ITSR, meshgroup_ITSR2A, 3, _V(6.087421,0, 0.785489), _V(0,1,0), (float)PI*2);
		// ITS 2 B
	static UINT	meshgroup_ITSR2B[3]	= {15,14,13};
	static MGROUP_ROTATE	mgt_ITSR2B (Mesh_ITSR, meshgroup_ITSR2B, 3, _V(21.16185,0, 0.785489), _V(0,1,0), (float)PI*2);
		// ITS 1 A
	static UINT	meshgroup_ITSL1A[3]	= {9,19,20};
	static MGROUP_ROTATE	mgt_ITSL1A (Mesh_ITSL, meshgroup_ITSL1A, 3, _V(-6.087421,0,-0.785489), _V(0,1,0), (float)PI*2);
		// ITS 1 B
	static UINT	meshgroup_ITSL1B[3]	= {18,17,16};
	static MGROUP_ROTATE	mgt_ITSL1B (Mesh_ITSL, meshgroup_ITSL1B, 3, _V(-21.16185,0,-0.785489), _V(0,1,0), (float)PI*2);
		// ITS 2 A
	static UINT	meshgroup_ITSL2A[3]	= {12,11,10};
	static MGROUP_ROTATE	mgt_ITSL2A (Mesh_ITSL, meshgroup_ITSL2A, 3, _V(-6.087421,0, 0.785489), _V(0,1,0), (float)PI*2);
		// ITS 2 B
	static UINT	meshgroup_ITSL2B[3]	= {15,14,13};
	static MGROUP_ROTATE	mgt_ITSL2B (Mesh_ITSL, meshgroup_ITSL2B, 3, _V(-21.16185,0, 0.785489), _V(0,1,0), (float)PI*2);

	anim_ITS		= CreateAnimation (0.0);
	AddAnimationComponent (anim_ITS, 0.0f, 1.0f, &mgt_ITSR1B, ach_truss);
	AddAnimationComponent (anim_ITS, 0.0f, 1.0f, &mgt_ITSR1A, ach_truss);
	AddAnimationComponent (anim_ITS, 0.0f, 1.0f, &mgt_ITSR2B, ach_truss);
	AddAnimationComponent (anim_ITS, 0.0f, 1.0f, &mgt_ITSR2A, ach_truss);
	AddAnimationComponent (anim_ITS, 0.0f, 1.0f, &mgt_ITSL1B, ach_truss);
	AddAnimationComponent (anim_ITS, 0.0f, 1.0f, &mgt_ITSL1A, ach_truss);
	AddAnimationComponent (anim_ITS, 0.0f, 1.0f, &mgt_ITSL2B, ach_truss);
	AddAnimationComponent (anim_ITS, 0.0f, 1.0f, &mgt_ITSL2A, ach_truss);

}

thanks in advance guys.
 

BrianJ

Addon Developer
Addon Developer
Joined
Apr 19, 2008
Messages
1,676
Reaction score
898
Points
128
Location
Code 347
Hi,
duplication of mesh groups maybe? Try this....
Code:
void ISS::DefineAnimations (void)
{
		// ITS truss rotation
	static UINT	meshgroup_truss1[9]	= {0,1,2,3,4,5,6,7,8};
	static UINT	meshgroup_truss2[9]	= {0,1,2,3,4,5,6,7,8};

static MGROUP_ROTATE	mgt_truss1 (Mesh_ITSL, meshgroup_truss1, 9, _V(0,0,0), _V(1,0,0), (float)PI*2); 
static MGROUP_ROTATE	mgt_truss2 (Mesh_ITSR, meshgroup_truss2, 9, _V(0,0,0), _V(1,0,0), (float)PI*2);

etc.................


}
Any good?
 
Last edited:
Top