Hello. I am using the following to gimble the main engines based on user input:
The problem is that when you pitch down, the thrusters don't go to the 0,-1,0 direction, instead it stops about half way there. The same with the yaw. I don't know what I am doing in terms of the math, any help would be appreciated.
Code:
VESSEL * vessel = oapiGetFocusInterface();
VECTOR3 dir;
OBJHANDLE thruster;
double cLevel=vessel->GetControlSurfaceLevel(AIRCTRL_ELEVATOR);
double dLevel = vessel->GetControlSurfaceLevel(AIRCTRL_RUDDER);
dir.x=-dLevel;
dir.y=-cLevel;
dir.z=1-cLevel-dLevel;
dir = nrmvec3(dir);
for (int i = 0; i < vessel->GetGroupThrusterCount(THGROUP_MAIN); i++)
{
thruster = vessel->GetGroupThruster(THGROUP_MAIN, i);
vessel->SetThrusterDir(thruster,dir);
}
The problem is that when you pitch down, the thrusters don't go to the 0,-1,0 direction, instead it stops about half way there. The same with the yaw. I don't know what I am doing in terms of the math, any help would be appreciated.