Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Addon Development
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Addon Development Developers post news, updates, & discussions here about your projects in development.

Reply
 
Thread Tools
Old 07-27-2016, 11:30 AM   #196
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

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?
gattispilot is offline   Reply With Quote
Old 07-27-2016, 11:52 AM   #197
GLS
Addon Developer
 
GLS's Avatar
Default

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.
GLS is offline   Reply With Quote
Thanked by:
Old 07-27-2016, 12:10 PM   #198
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Ok. Where did you see 0 to 1?
gattispilot is offline   Reply With Quote
Old 07-27-2016, 12:14 PM   #199
Urwumpe
Not funny anymore
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
 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.
Urwumpe is offline   Reply With Quote
Thanked by:
Old 07-27-2016, 12:15 PM   #200
GLS
Addon Developer
 
GLS's Avatar
Default

Quote:
Originally Posted by gattispilot View Post
 Ok. Where did you see 0 to 1?
SSU uses beacon lights somewhere .
GLS is offline   Reply With Quote
Thanked by:
Old 08-08-2016, 11:00 AM   #201
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

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 Now we can a ctd. It runs ok in the debug.
gattispilot is offline   Reply With Quote
Thanked by:
Old 08-08-2016, 11:08 AM   #202
Urwumpe
Not funny anymore
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by gattispilot View Post
  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)
Urwumpe is offline   Reply With Quote
Thanked by:
Old 08-08-2016, 12:24 PM   #203
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

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;
gattispilot is offline   Reply With Quote
Old 08-08-2016, 12:53 PM   #204
Urwumpe
Not funny anymore
 
Urwumpe's Avatar

Default

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 by Urwumpe; 08-08-2016 at 12:57 PM.
Urwumpe is offline   Reply With Quote
Thanked by:
Old 08-10-2016, 12:42 AM   #205
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

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
gattispilot is offline   Reply With Quote
Old 08-10-2016, 09:01 AM   #206
Urwumpe
Not funny anymore
 
Urwumpe's Avatar

Default

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 by Urwumpe; 08-10-2016 at 09:12 AM.
Urwumpe is offline   Reply With Quote
Old 08-10-2016, 10:18 AM   #207
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Thanks. the issues seems to be in the hover thrust gauge.
initial setup of hover thrusters
Code:
//HOVER
	tank2 = CreatePropellantResource(FUELMASS2);

	th_hover[0] = CreateThruster(_V(5, 0, 5), _V(0, 1, 0), MAXHOVERTH / 4, tank2, ISP);
	th_hover[1] = CreateThruster(_V(-5, 0, -5), _V(0, 1, 0), MAXHOVERTH / 4, tank2, ISP);
	th_hover[2] = CreateThruster(_V(-5, 0, 5), _V(0, 1, 0), MAXHOVERTH / 4, tank2, ISP);
	th_hover[3] = CreateThruster(_V(5, 0, -5), _V(0, 1, 0), MAXHOVERTH / 4, tank2, ISP);

	thg_hover = CreateThrusterGroup(th_hover, 4, THGROUP_HOVER);
commented lines no ctd
Code:
 current_thrust_hover_level = GetThrusterGroupLevel(thg_hover);
if (current_thrust_hover_level != thrust_hover_last_drawn){
		thrust_hover_last_drawn = current_thrust_hover_level;
		redrawpanel = true;
	}
this tells how far to draw the bar
Code:
	hoverx2 = int(hoverx1 + current_thrust_hover_level * 284);
draws the bar
Code:
	Rectangle(hDC, hoverx1, hovery1, hoverx2,hovery2);//HOVERthrust
initialized
Code:
	current_thrust_hover_level = 0;
	thrust_hover_last_drawn = 0;
	hoverx1 = 60;
	hovery1 = 509;
	hoverx2 = 342;
	hovery2 = 534;

One thing I did notice it would draw the hover bar full till it refreshed. I was thinking I could just go to one hover thruster. The reason we have it that way is for the 4 exhaust?
gattispilot is offline   Reply With Quote
Old 08-10-2016, 10:59 AM   #208
Urwumpe
Not funny anymore
 
Urwumpe's Avatar

Default

How is th_hover defined?

And why are you not simply using

current_thrust_hover_level = GetThrusterGroupLevel(THGROUP_HOVER);

Last edited by Urwumpe; 08-10-2016 at 11:01 AM.
Urwumpe is offline   Reply With Quote
Old 08-10-2016, 11:06 AM   #209
gattispilot
Addon Developer
 
gattispilot's Avatar
Default

Bingo that was it I had changed it to
Code:
th_hover[1];



now it is
Code:
th_hover[4];
gattispilot is offline   Reply With Quote
Thanked by:
Old 08-10-2016, 12:26 PM   #210
Urwumpe
Not funny anymore
 
Urwumpe's Avatar

Default

Should have caused a minor annoyance there, but it is one code smell less.
Urwumpe is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Addons > Addon Development


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 01:06 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.