• ORBITER-FORUM will be temporarily closed at 2026-07-23 18:00 UTC while we complete some OF maintenance tasks. The amount of downtime is expected to take up to one hour, but probably less.

Question Ranger (and other ships) from Interstellar?

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.
 
Ok. back from vacation. Trying to center the elevator trim with a key. I know you can with a mouse and click on the center bar.

Code:
	else if (key == OAPI_KEY_7)//JETTISON
	{

		SetControlSurfaceLevel(AIRCTRL_ELEVATORTRIM, 0);
		return 1;
	}

We are adding some rcs to adjust the elevator/pitch. So if you trim you are adjusting the amount of thrust to apply to thrusters.

But want to press a button and reset trim to 0.

---------- Post added 08-08-16 at 06:00 AM ---------- Previous post was 08-07-16 at 07:29 AM ----------

UGH:shrug: Now we can a ctd. It runs ok in the debug.
 
It runs ok in the debug.

With 99% certainty, "It runs ok in DEBUG" means: There are uninitialized variables, that don't cause problem in DEBUG (because debug initializes memory with test patterns) but cause problems in Release (where memory is not changed during allocation and contains the deceased bits of previous processes)
 
OK. Thanks. I will take a look. I assume when you say uninitialized variables. It is like
in the h.
Code:
double pitchlevel;

then in the cpp pitchlevel is never initialized like "
Code:
pitchlevel =0;
 
Yes, like that.

Uninitialized variable bug = The variable was never set by your program before you read it.

You should ALWAYS initialize your variables, in the best case already in the constructor. Even if you can safely assume that they will be set before you use them in clbkXXXXStep. One small refactoring, and suddenly the variable is used before you have initialized it with a value.

A common error is having a variable like "old_state" and a (hidden) loop like:

If old_state != new_state then
dosomethinghorrible();
old_state = new_state;
end if
 
Last edited:
Well I thought I fixed it. Got it running made changes and now I get a CTD. In debug it opens and then ctd. No symbols loaded is all I get.

So is there a way to check for uninitialized variables?

Code:
	PITCHTRIMLEVEL = 0;
	PITCHTRIMLEVELABS = 0;


Code:
	if (PITCHTRIMLEVEL < 0){
		PITCHTRIMLEVELABS = abs(PITCHTRIMLEVELABS);
		SetThrusterLevel(th_rcs[20], PITCHTRIMLEVELABS);
		SetThrusterLevel(th_rcs[25], PITCHTRIMLEVELABS);
		SetThrusterLevel(th_rcs[27], PITCHTRIMLEVELABS);
		SetThrusterLevel(th_rcs[26], PITCHTRIMLEVELABS);

	
	}
	if (PITCHTRIMLEVEL > 0){
		SetThrusterLevel(th_rcs[21], PITCHTRIMLEVEL);
		SetThrusterLevel(th_rcs[22], PITCHTRIMLEVEL);
		SetThrusterLevel(th_rcs[23], PITCHTRIMLEVEL);
		SetThrusterLevel(th_rcs[24], PITCHTRIMLEVEL);

	
	}
Code:
	else if (key == OAPI_KEY_DELETE)//JETTISON
	{
		
		
		PITCHTRIMLEVEL = PITCHTRIMLEVEL + .01;
		if (PITCHTRIMLEVEL > 1)PITCHTRIMLEVEL = 1;
		return 1;
	}

	else if (key == OAPI_KEY_INSERT)//JETTISON
	{
	PITCHTRIMLEVEL = PITCHTRIMLEVEL - .01;
	if (PITCHTRIMLEVEL <-1)PITCHTRIMLEVEL = -1;
		
		return 1;
	}

PITCHTRIMLEVEL is a counter from 1 to -1 in .01 steps. If it is >0 then fire pitch thrust PITCHTRIMLEVEL amount. if PITCHTRIMLEVEL<0 (negative) then fire pitch thrust abs(PITCHTRIMLEVEL). there are 4 front pitch and 4 rear thrusters. they fire depending if PITCHTRIMLEVELis postive or negative
 
is th_rcs[x] pointing to a valid thruster handle?

---------- Post added at 11:01 AM ---------- Previous post was at 08:27 AM ----------

BTW: abs() is usually the integer version of the function, unless you include cmath. Do you have "#include <cmath>" or "#include <math.h>" in your relevant files? If you want to be on the safe side, use "fabs" instead
 
Last edited:
Back
Top