As with Moach's thread here I have the FADI in my lunar module represnted by an actual 3d sphere and I need to animate it.
I've searched the forum and I've looked at Martins' ShuttleA samples but the code is rather opaque to a C++ newbie such as myself. As it stands I have my velocity and horizon vectors defined in local coordinates but I'm having trouble visualising the physical mechanics required to translate them into a form usable by MGROUP_ROTATE.
My animation definitions are below, I have 360 (+/- 180) degrees along each axis but suspect it's overkill. Using proper Euler angles I should be able to reach any desired orientation using no more than two rotation but how do I get there from here?
Any help would be appreciated.
I've searched the forum and I've looked at Martins' ShuttleA samples but the code is rather opaque to a C++ newbie such as myself. As it stands I have my velocity and horizon vectors defined in local coordinates but I'm having trouble visualising the physical mechanics required to translate them into a form usable by MGROUP_ROTATE.
My animation definitions are below, I have 360 (+/- 180) degrees along each axis but suspect it's overkill. Using proper Euler angles I should be able to reach any desired orientation using no more than two rotation but how do I get there from here?
Code:
// ADI Ball
static UINT ADIGroups = VC_GRP_ADI_Ball;
static MGROUP_ROTATE ADI_X (
4, // mesh index
&ADIGroups, 1, // group list and # of groups
ADI_Center, // rotation reference point
_V( 1, 0, 0), // rotation axis
(float) 2*PI // angular rotation range (radians)
);
anim_ADI_Xrot = CreateAnimation(0.50);
AddAnimationComponent ( anim_ADI_Xrot, 0.0f, 1.0f, &ADI_X);
static MGROUP_ROTATE ADI_Y (
4, // mesh index
&ADIGroups, 1, // group list and # of groups
ADI_Center, // rotation reference point
_V( 0, 1, 0), // rotation axis
(float) 2*PI // angular rotation range (converted to radians)
);
anim_ADI_Yrot = CreateAnimation(0.50);
AddAnimationComponent ( anim_ADI_Yrot, 0.0f, 1.0f, &ADI_Y);
static MGROUP_ROTATE ADI_Z (
4, // mesh index
&ADIGroups, 1, // group list and # of groups
ADI_Center, // rotation reference point
_V( 0, 0, 1), // rotation axis
(float) 2*PI // angular rotation range (converted to radians)
);
anim_ADI_Zrot = CreateAnimation(0.50);
AddAnimationComponent ( anim_ADI_Zrot, 0.0f, 1.0f, &ADI_Z);
Code:
void LEM::UpdateADI(VECTOR3 output)
{
double x_proc, y_proc, z_proc = 0;
normalise(output);
VECTOR3 input = crossp( output, vThrust);
double xDelta = asin(input.x)*DEG;
double zDelta = asin(input.z)*DEG;
double yDelta = asin(input.y)*DEG;
x_proc = (xDelta + 180) / 360;
y_proc = (yDelta + 180) / 360;
z_proc = (zDelta + 180) / 360;
sprintf(oapiDebugString(),"X delta %0.2f Y delta %0.2f Z delta %0.2f", xDelta, yDelta, zDelta);
LEM::SetAnimation( anim_ADI_Xrot, x_proc);
LEM::SetAnimation( anim_ADI_Yrot, y_proc);
LEM::SetAnimation( anim_ADI_Zrot, z_proc);
}
Any help would be appreciated.
