Working on the Space 1999 eagle. Trying to duplicate the upper left HUD display.
Pretty much got everything to work but the main/retro
Using the orbiter source code for a guide.
Orbiter code
and then mine:
What it is suppose to do is draw a green rectangle for main thrust and a yellow one for retro. But all I get is the green one
As I understand the code is if th >=0 (MAin) draw the rectangle start at the left and draw to the right. if th<0 then draw a yellow rectangle right to left.
But for me th is always 0 or 1.
API
Pretty much got everything to work but the main/retro
Using the orbiter source code for a guide.
Orbiter code
// Update main engine status
vofs += 4;
double th = g_focusobj->GetThrusterGroupLevel(THGROUP_MAIN);
if (!th) th = -g_focusobj->GetThrusterGroupLevel(THGROUP_RETRO);
if (th != engmain) {
engmain = th;
if (th >= 0.0) {
grp->Vtx[vofs].x = grp->Vtx[vofs+2].x = dx+46.0f*scale;
grp->Vtx[vofs+1].x = grp->Vtx[vofs+3].x = dx+(float)((46.0+engmain*94.0)*scale);
for (i = 0; i < 4; i++) grp->Vtx[vofs+i].tu = 4.0f/texw;
} else {
grp->Vtx[vofs].x = grp->Vtx[vofs+2].x = dx+(140.0f+(float)engmain*94.0f)*scale;
grp->Vtx[vofs+1].x = grp->Vtx[vofs+3].x = dx+140.0f*scale;
for (i = 0; i < 4; i++) grp->Vtx[vofs+i].tu = 6.0f/texw;
}
}
// Update main engine readout
vofs += 4*5;
th = (engmain >= 0.0 ? engmain*g_focusobj->GetThrusterGroupMaxth(THGROUP_MAIN) :
-engmain*g_focusobj->GetThrusterGroupMaxth(THGROUP_RETRO));
and then mine:
double th = GetThrusterGroupLevel(THGROUP_MAIN); //get thrust main level
if (!th) th = GetThrusterGroupLevel(THGROUP_RETRO); //get retro thrusters - 1 to 0
if (th != engmain) {
engmain = th;
if (th >= 0.0) {
//draw thrust level
//sprintf(oapiDebugString(), "main %5f th %5f ", engmain, th);
SelectObject(hDC, g_Param.hBrush[1]);//green box
Rectangle(hDC, 130, 144, (int)(130 + engmain * (200)), 187);//thrust
}
//sprintf(oapiDebugString(), "main %5f th %5f ", engmain, th);
//retro
else {
//sprintf(oapiDebugString(), "main %5f th %5f ", engmain, th);
SelectObject(hDC, g_Param.hBrush[2]);//yellow box
Rectangle(hDC, 130, 144, (int)(130 - engmain * (200)), 187);//thrust
}
}
th = (engmain >= 0.0 ? engmain * th :
-engmain * th);
What it is suppose to do is draw a green rectangle for main thrust and a yellow one for retro. But all I get is the green one
As I understand the code is if th >=0 (MAin) draw the rectangle start at the left and draw to the right. if th<0 then draw a yellow rectangle right to left.
But for me th is always 0 or 1.
API
The main/retro engine level has a range of [-1,+1]. A positive value indicates engaged main/disengaged retro thrusters, a negative value indicates engaged retro/disengaged main thrusters. Main and retro thrusters cannot be engaged simultaneously. For vessels without retro thrusters the valid range is [0,+1].
double main; // -1 (full retro) .. +1 (full main)