SDK Question Animation not animating

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,868
Reaction score
4
Points
0
Location
San Diego
Ok I need some more help.

I followed the all the steps in the API_Guide but my Animation is not animating.

Here's the animation component as curently defined, the "DefineAnimations" function is called in the constructor as per the pdf.

Code:
void Spider::DefineAnimations (void)
{
	// EVA Hatch
	static UINT HatchGroups[2] = {8};	// participating groups // {EvaHatch}
	static MGROUP_ROTATE Hatch (
		mesh_AS,						// mesh index
		HatchGroups, 2,					// group list and # of groups 
		_V(-0.394,-0.578, 1.661),		// rotation reference point 
		_V( 0, 1, 0),				// rotation axis 
		0.5*PI				// angular rotation range (pi/2 aka 90 DEG)
		);
	
	anim_Hatch = CreateAnimation(0);
	AddAnimationComponent ( anim_Hatch, 0, 1, &Hatch);
}

then in ClbkPost step I have the following which I adapted from the stock DG...

Code:
	// animate hatch *Copied from stock DG*
	if (HatchStatus > CLOSED) 
	{
		double da = simdt * HATCH_OPERATING_SPEED;
		if (HatchStatus == CLOSING) 
		{
			if (hatch_proc > 0.0) hatch_proc = max (0.0, hatch_proc - da);
			else HatchStatus = CLOSED;
		}
		else 
		{
			if (hatch_proc < 1.0) hatch_proc = min (1.0, hatch_proc + da);
			else HatchStatus = OPEN;
		}
		
		LEM::SetAnimation( anim_Hatch, hatch_proc);
	}
	sprintf(oapiDebugString(),"hatch_proc %f Hatch Status %i", hatch_proc, HatchStatus);

finally I have this simple function in clbkConsumebufferedkey

Code:
	// Open Hatch when [K] is pressed.
	if(key == OAPI_KEY_K  && down && !KEYMOD_SHIFT(kstate) && !KEYMOD_CONTROL (kstate) && !KEYMOD_ALT(kstate))
	{
		if (HatchStatus != OPEN) HatchStatus = OPENING;
		else if (HatchStatus != CLOSED) HatchStatus = CLOSING;
		return 1;
	}

now I've been able to confirm via my oapiDebugString that "hatch_proc" and the "HatchStatus" enumerator are both working properly. The question therefore is why isn't the hatch moving?

is it an issue with the "SetAnimation" function or the definition itself.

---------- Post added at 10:02 PM ---------- Previous post was at 03:41 AM ----------

Ok I have it working and have highlighted the things I've changed...



Code:
	// EVA Hatch
	static UINT HatchGroups = 8;	// participating groups // {EvaHatch}
	static MGROUP_ROTATE Hatch (
		[COLOR="red"]3,[/COLOR]								// mesh index
		[COLOR="red"]&[/COLOR]HatchGroups, 1,				// group list and # of groups 
		_V( 0.394,-0.578, 1.661),		// rotation reference point 
		_V( 0.0, 1.0, 0.0),				// rotation axis 
		(float)-85*RAD					// angular rotation range (converted to radians)
		);
	
	anim_Hatch = CreateAnimation(0);
	AddAnimationComponent ( anim_Hatch, [COLOR="red"]0.0f, 1.0f,[/COLOR] &Hatch);

It seems that replacing the mesh index with the mesh index's number was the critical change yet the documentation does not explain why this may be.
 
Last edited:
It seems that replacing the mesh index with the mesh index's number was the critical change yet the documentation does not explain why this may be.
And did `mesh_AS` contain 3? Wasn't it working when you just changed `HatchGroups, 2` to `&HatchGroups, 1`? The mesh index argument is passed by value, so it shouldn't make any difference when it's a variable or a literal, if their value is the same.
 
Back
Top