Question Ranger (and other ships) from Interstellar?

Here is a weird issue. The beacon on the Endurance are red and yellow. But id d3d9 they are both green.
Code:
APbeaconcol[17] = {{ 0, 255, 0 },//POD1
red
Code:
static VECTOR3 Cbeaconcol[16] = { { 0, 128, 0 },
yellow
 
Another weird issue. In regular mode Even though hover level is half. on the VC is shows nothing. When I exit and restart it draws it and then it goes away.
nohover1_zpsco6cdjrj.jpg


but when I run it in debug mode it draws it.
nohover2_zpspaw0xwka.jpg


so check to see if changes in levels if so then change the vc
Code:
	fuel_percent1 = int(100 * (GetFuelMass()) / (FUELMASS1));

	if (fuel_percent1 != fuel_percent1_last_redraw){
		fuel_percent1_last_redraw = fuel_percent1;
		oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);
	}

	fuel_percent2 = int(100 * (GetFuelMass()) / (FUELMASS2));

	if (fuel_percent2 != fuel_percent2_last_redraw){
		fuel_percent2_last_redraw = fuel_percent2;
		oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);
	}

	fuel_percent3 = int(100 * (GetFuelMass()) / (FUELMASS3));

	if (fuel_percent3 != fuel_percent3_last_redraw){
		fuel_percent3_last_redraw = fuel_percent3;
		oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);
	}


	current_thrust_main_level = GetThrusterLevel(th_main[0]);

	if (current_thrust_main_level != thrust_main_last_drawn){
		thrust_main_last_drawn = current_thrust_main_level;
		oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);
	}

	current_thrust_hover_level = GetThrusterLevel(th_hover[0]);

	if (current_thrust_hover_level != thrust_hover_last_drawn){
		thrust_hover_last_drawn = current_thrust_hover_level;
		oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);
	}

	current_trim_level = GetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM);

	if (current_trim_level != trim_last_drawn){
		trim_last_drawn = current_trim_level;
		oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);
	}

Code:
void LANDER6::RedrawPanel_Fuelstatus(SURFHANDLE surf, int part)

{
	char cbuf[20];
	HDC hDC = oapiGetDC(surf);

	SelectObject(hDC, g_Param.hBrush[4]);//green box


	double level = GetThrusterLevel(th_main[0]);
	double level2 = GetPropellantMass(tank1);//main fuel
	double level3 = GetThrusterLevel(th_hover[0]);//hover
	double level4 = GetPropellantMass(tank2);//hover fuel
	double level5 = GetPropellantMass(tank3);//rcs fuel


	Rectangle(hDC, 62, 256, (int)(62 + level * (280)), 280);//thrust

	Rectangle(hDC, 62, 509, (int)(62 + level3 * (280)), 534);//HOVERthrust

	
	//178,145
	Rectangle(hDC, 154, 224, 180, (int)(224 - (level2 / 50)));  //fuel
	Rectangle(hDC, 226, 224, 249, (int)(224 - (level2 / 50)));  //fuel

	Rectangle(hDC, 81, 468, 106, (int)(468 - (level4 / 50)));  //fuel
	Rectangle(hDC, 152, 468, 176, (int)(468 - (level4 / 50)));  //fuel
	Rectangle(hDC, 225, 468, 250, (int)(468 - (level4 / 50)));  //fuel
	Rectangle(hDC, 296, 468, 322, (int)(468 - (level4 / 50)));  //fuel

	Rectangle(hDC, 499, 486, 525, (int)(486 - (level5 / 23.8)));  //rscfuel
	Rectangle(hDC, 572, 486, 598, (int)(486 - (level5 / 23.8)));  //rscfuel

	Rectangle(hDC, 499, 223, 525, (int)(223 - (level5 / 23.8)));  //rscfuel
	Rectangle(hDC, 572, 223, 599, (int)(223 - (level5 / 23.8)));  //rscfuel

	
	SelectObject(hDC, g_Param.hFont[3]);

	SetTextColor(hDC, RGB(0, 153, 0));
	SetTextAlign(hDC, TA_LEFT);
	SetBkMode(hDC, TRANSPARENT);

	SelectObject(hDC, g_Param.hFont[4]);
	sprintf(cbuf, "%0.1f", level2 / 2);
	TextOut(hDC, 142, 107, cbuf, strlen(cbuf));
	TextOut(hDC, 212, 107, cbuf, strlen(cbuf));

	sprintf(cbuf, "%0.1f", level4 / 4);
	TextOut(hDC, 67, 350, cbuf, strlen(cbuf));
	TextOut(hDC, 139, 350, cbuf, strlen(cbuf));
	TextOut(hDC, 212, 350, cbuf, strlen(cbuf));
	TextOut(hDC, 283, 350, cbuf, strlen(cbuf));

	sprintf(cbuf, "%0.1f", level5 / 4);
	TextOut(hDC, 500, 353, cbuf, strlen(cbuf));
	TextOut(hDC, 571, 353, cbuf, strlen(cbuf));
	TextOut(hDC, 500, 103, cbuf, strlen(cbuf));
	TextOut(hDC, 571, 103, cbuf, strlen(cbuf));

	double trim = (GetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM) - .5);
	double trim1 = GetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM);

	double trim2 = (trim - .5);
	
	
	Rectangle(hDC, 482, (int)(249 - (30* trim2)), 502, (int)(255 - (30* trim2)));  //TRIM

	SelectObject(hDC, g_Param.hFont[3]);
	SetTextColor(hDC, RGB(0, 153, 0));
	SetTextAlign(hDC, TA_LEFT);
	SetBkMode(hDC, TRANSPARENT);

	sprintf(cbuf, "%0.1f", trim1);
	TextOut(hDC, 545, 273, cbuf, strlen(cbuf));
	SelectObject(hDC, g_Param.hFont[2]);

	if (trim<-.5) {
		sprintf(cbuf, "DN", 2);
		TextOut(hDC, 581, 269, cbuf, strlen(cbuf));
	}
	if (trim>-.5) {
		sprintf(cbuf, "UP", 2);
		TextOut(hDC, 581,269, cbuf, strlen(cbuf));
	}

	if (!GetAttachmentStatus(CARGO1)) {
		SetTextColor(hDC, RGB(196, 196, 196));
		sprintf(cbuf, "CARGO1", 6);
		TextOut(hDC, 77, 567, cbuf, strlen(cbuf));
	}

	if (GetAttachmentStatus(CARGO1)) {
		SetTextColor(hDC, RGB(0, 153, 0));
		sprintf(cbuf, "CARGO1", 6);
		TextOut(hDC, 77, 567, cbuf, strlen(cbuf));
	}
	if (!GetAttachmentStatus(CARGO2)) {
		SetTextColor(hDC, RGB(196, 196, 196));
		sprintf(cbuf, "CARGO2", 6);
		TextOut(hDC, 222, 567, cbuf, strlen(cbuf));
	}
	if (GetAttachmentStatus(CARGO2)) {
		SetTextColor(hDC, RGB(0, 153, 0));
		sprintf(cbuf, "CARGO2", 6);
		TextOut(hDC, 222, 567, cbuf, strlen(cbuf));
	}
	
	oapiReleaseDC(surf, hDC);
}

Code:
bool LANDER6::clbkLoadVC(int id) { // ID is the Preset Camera Position
	SURFHANDLE const tex3 = oapiGetTextureHandle(meshhg_VC, TEX_LANDER16VC_LANDERCENTERVC4);
	huds.size = 0.496;
	huds.nmesh = 7;
	huds.ngroup = GRP_LANDER16VC_HUD;
	
	//static VCHUDSPEC huds = { 7, GRP_LANDER16VC_HUD, { -.842, 3.664734, 8.022912 }, 0.496 };
	oapiVCRegisterHUD(&huds);



	viewController->HandleLoadVC(id);
	mfdController->HandleLoadVC(id);
	oapiVCRegisterArea(AID_FUELSTATUS, _R(0, 0, 1024, 1024), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex3);
	//oapiVCRegisterArea(AID_THRUSTSTATUS, _R(0, 0, 512, 512), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex3);
	//oapiVCRegisterArea(AID_PODSTATUS, _R(0, 0, 512, 512), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex3);
	//caseTerminalScreen->HandleLoadVC(id);
	//TARSTerminalScreen->HandleLoadVC(id);


	return HandleLoadVC(id);
}
 
Can't see anything obvious....
This is probably not related, but you might be redrawing a bit too many times. Instead of having oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS); every time a parameter changes, try using a local variable bool redrawpanel = false;, and replace the oapiVCTriggerRedrawArea calls with redrawpanel = true;, and then at the end of all the checks just add if (redrawpanel) oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);. You'll might gain some performance there.
Another thing you could do is use the thrust_main_last_drawn (and others) in the RedrawPanel_Fuelstatus(), so the value that is drawn is always the one you did the check with.
 
Thanks. I will try that. But I commented out most of green rectangles and the same issue. Main thrust works.

Not sure if I follow on the code though
 
ok. So on the code part:
Code:
bool redrawpanel = false;


Code:
fuel_percent1 = int(100 * (GetFuelMass()) / (FUELMASS1));

	if (fuel_percent1 != fuel_percent1_last_redraw){
		fuel_percent1_last_redraw = fuel_percent1;
		redrawpanel = true;
...
current_trim_level = GetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM);

	if (current_trim_level != trim_last_drawn){
		trim_last_drawn = current_trim_level;
		redrawpanel = true;
	}

	}

do this for all of the others. and then add
Code:
 if (redrawpanel) oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);
 
ok. So on the code part:
Code:
bool redrawpanel = false;


Code:
fuel_percent1 = int(100 * (GetFuelMass()) / (FUELMASS1));

	if (fuel_percent1 != fuel_percent1_last_redraw){
		fuel_percent1_last_redraw = fuel_percent1;
		redrawpanel = true;
...
current_trim_level = GetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM);

	if (current_trim_level != trim_last_drawn){
		trim_last_drawn = current_trim_level;
		redrawpanel = true;
	}

	}

do this for all of the others. and then add
Code:
 if (redrawpanel) oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);

Yep! This way if several things change, the panel will only be redrawn once.
 
Ok in d3d9 the beacons are correct. this is red.
Code:
{ 255, 0, 0 },
and yellow
Code:
{ 255, 255, 0 }

but in regular graphics the red one is black and the yellow one is red.
 
Last edited:
I noticed that you are using VECTOR3 for the colors... it might be the source of these issues. In SSU the display colors are defined like this in a header file
Code:
#define CR_RED RGB( 255, 0, 0 )
#define CR_YELLOW RGB( 255, 255, 0 )
etc....
and then we just use CR_RED or CR_YELLOW when it's needed.
 
Thanks. So in the h file I have:
Code:
#define CR_RED RGB( 255, 0, 0 )
#define CR_YELLOW RGB( 255, 255, 0 )

but when I try to change it i get an issue?
Code:
static VECTOR3 Cbeaconcol[16] = { { CR_RED RGB },//bay1
says expected a comma?

---------- Post added at 04:48 AM ---------- Previous post was at 04:39 AM ----------

also:
Code:
fuel_percent1 = int(100 * (GetFuelMass()) / (FUELMASS1));

	if (fuel_percent1 != fuel_percent1_last_redraw){
		fuel_percent1_last_redraw = fuel_percent1;
		redrawpanel = true;
	}

	fuel_percent2 = int(100 * (GetFuelMass()) / (FUELMASS2));

	if (fuel_percent2 != fuel_percent2_last_redraw){
		fuel_percent2_last_redraw = fuel_percent2;
		redrawpanel = true;
	}

	fuel_percent3 = int(100 * (GetFuelMass()) / (FUELMASS3));

	if (fuel_percent3 != fuel_percent3_last_redraw){
		fuel_percent3_last_redraw = fuel_percent3;
		redrawpanel = true;
	}


	current_thrust_main_level = GetThrusterLevel(th_main[0]);

	if (current_thrust_main_level != thrust_main_last_drawn){
		thrust_main_last_drawn = current_thrust_main_level;
		redrawpanel = true;
	}

	current_thrust_hover_level = GetThrusterLevel(th_hover[0]);

	if (current_thrust_hover_level != thrust_hover_last_drawn){
		thrust_hover_last_drawn = current_thrust_hover_level;
		redrawpanel = true;
	}

	current_trim_level = GetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM);

	if (current_trim_level != trim_last_drawn){
		trim_last_drawn = current_trim_level;
		redrawpanel = true;
	}

	if (redrawpanel) oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);

Code:
	oapiVCRegisterArea(AID_FUELSTATUS, _R(0, 0, 1024, 1024), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex3);

actually framerate went down it was 30 now 6
 
Thanks. So in the h file I have:
Code:
#define CR_RED RGB( 255, 0, 0 )
#define CR_YELLOW RGB( 255, 255, 0 )

but when I try to change it i get an issue?
Code:
static VECTOR3 Cbeaconcol[16] = { { CR_RED RGB },//bay1
says expected a comma?


What are you doing with the Cbeaconcol[]? I could be wrong, but I don't think you need/could to store colors in a VECTOR3.

also:
Code:
fuel_percent1 = int(100 * (GetFuelMass()) / (FUELMASS1));

	if (fuel_percent1 != fuel_percent1_last_redraw){
		fuel_percent1_last_redraw = fuel_percent1;
		redrawpanel = true;
	}

	fuel_percent2 = int(100 * (GetFuelMass()) / (FUELMASS2));

	if (fuel_percent2 != fuel_percent2_last_redraw){
		fuel_percent2_last_redraw = fuel_percent2;
		redrawpanel = true;
	}

	fuel_percent3 = int(100 * (GetFuelMass()) / (FUELMASS3));

	if (fuel_percent3 != fuel_percent3_last_redraw){
		fuel_percent3_last_redraw = fuel_percent3;
		redrawpanel = true;
	}


	current_thrust_main_level = GetThrusterLevel(th_main[0]);

	if (current_thrust_main_level != thrust_main_last_drawn){
		thrust_main_last_drawn = current_thrust_main_level;
		redrawpanel = true;
	}

	current_thrust_hover_level = GetThrusterLevel(th_hover[0]);

	if (current_thrust_hover_level != thrust_hover_last_drawn){
		thrust_hover_last_drawn = current_thrust_hover_level;
		redrawpanel = true;
	}

	current_trim_level = GetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM);

	if (current_trim_level != trim_last_drawn){
		trim_last_drawn = current_trim_level;
		redrawpanel = true;
	}

	if (redrawpanel) oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);

Code:
	oapiVCRegisterArea(AID_FUELSTATUS, _R(0, 0, 1024, 1024), PANEL_REDRAW_USER, PANEL_MOUSE_IGNORE, PANEL_MAP_BACKGROUND, tex3);

actually framerate went down it was 30 now 6

Well, that's odd... it should at least be the same or faster. :uhh: Are all those checks in a timestep function, and is the redrawpanel initialized as false?
In any case, you can always go back to what you had before.
 
Well I went back and now the hover gauge doesn't work. But when I commented
Code:
current_thrust_hover_level = GetThrusterLevel(th_hover[0]);

	if (current_thrust_hover_level != thrust_hover_last_drawn){
		thrust_hover_last_drawn = current_thrust_hover_level;
		//oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);
	}

It works but isn't updated. Framerate 34

on the beacons
there are 17 beacons so It sets the color for each one.
 
Well I went back and now the hover gauge doesn't work. But when I commented
Code:
current_thrust_hover_level = GetThrusterLevel(th_hover[0]);

	if (current_thrust_hover_level != thrust_hover_last_drawn){
		thrust_hover_last_drawn = current_thrust_hover_level;
		//oapiVCTriggerRedrawArea(-1, AID_FUELSTATUS);
	}

It works but isn't updated. Framerate 34

on the beacons
there are 17 beacons so It sets the color for each one.

There's something else going on with the panel code then...
How do you set the color? Are the beacons a light or what?
 
yes the beacons are a light. I am using them to show which cargo bay is selected and then where the attachment point is.
Code:
8.8.1 DetailedDescription
vessel beacon light parameters
PublicAttributes
• DWORD shape beacon shape identifier (see Light beacon shape parameters) • VECTOR3∗pos pointer to position in vessel coordinates • VECTOR3∗col pointer to beacon RGB colour
• double size beacon radius
• double falloff distance falloff parameter
• double period strobe period (0 for continuous)
• double duration strobe duration
• double tofs strobe time offset
• bool active beacon lit?
 
OK, I see now. You are using values from 0 to 255, but that only wants from 0 to 1. So forget the #defines and try using (1.0, 0.0, 0.0) for red and (1.0, 1.0, 0.0) for yellow (etc) in the VECTOR3 array.
 
Ok. Where did you see 0 to 1?

That is standard Orbiter convention in many places - for example you also have 0 ... 1 for the color components in mesh material definitions.

0 ... 255 is only used in some 2D drawing contexts AFAIR.
 
Back
Top