C++ Question DelThruster

marcogavazzeni

Addon Developer
Addon Developer
Joined
Jan 5, 2009
Messages
219
Reaction score
0
Points
16
Location
Near Verona
Website
orbiteritalia.forumotion.com
Hi guys,
I have created this code for my vessel engine:

Code:
[FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]
[SIZE=2][FONT=Courier New][COLOR=#008000]// main thrusters[/COLOR][/FONT][/SIZE]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]th_main[0] = CreateThruster (_V(0.0,-0.0,-2.91), _V(0,0,1), MAX_MAIN_THRUST, ph_main, ISP);[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]th_main[1] = CreateThruster (_V(-0.0,-0.0,-2.91), _V(0,0,1), MAX_JET_THRUST, ph_jet, ISP);[/FONT][/SIZE]
 
[SIZE=2][FONT=Courier New]CreateThrusterGroup (th_main, 2, THGROUP_MAIN);[/FONT][/SIZE]
 
[SIZE=2][FONT=Courier New]AddExhaust (th_main[0], 3, 0.3, _V(0.0,-0.257,-3.91), _V(0,0,-1),tex_main);[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]AddExhaust (th_main[1], 3, 0.3, _V(-0.0,-0.557,-3.91), _V(0,0,-1),tex_jet);[/FONT][/SIZE]
 
[SIZE=2][FONT=Courier New][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] ShuttlePB::clbkPostStep ([/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] simt, [/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] simdt, [/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] mjd)[/COLOR][/SIZE][/FONT]
[SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] (cover_proc >=0.01)[/COLOR][/SIZE][/FONT]
 
[SIZE=2][FONT=Courier New]{ [/FONT][/SIZE]
[SIZE=2][FONT=Courier New]SetThrusterMax0 (th_main[0],0 );[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]SetThrusterMax0 (th_main[1] ,23045);[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]}[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][COLOR=#000000] (cover_proc <=0.01)[/COLOR][/SIZE][/FONT]
[SIZE=2][FONT=Courier New]{ [/FONT][/SIZE]
[SIZE=2][FONT=Courier New]SetThrusterMax0 (th_main[1] ,0);[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]SetThrusterMax0 (th_main[0] ,14700);[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2]
 
[SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
[/SIZE][/FONT]
[/FONT][/SIZE][/SIZE][/FONT]

The problem is that the flames continue to see, how do I remove the texture when I selected only one mode?
Code:
[COLOR=#000][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] ShuttlePB::clbkPostStep ([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] simt, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] simdt, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] mjd)[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (cover_proc >=0.01)[/SIZE][/FONT]
 
[SIZE=2][FONT=Courier New]{ [/FONT][/SIZE]
[SIZE=2][FONT=Courier New]SetThrusterMax0 (th_main[0],0 );[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]SetThrusterMax0 (th_main[1] ,23045);[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// DelExhaust (th_main[0]) ;[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]}[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (cover_proc <=0.01)[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]{ [/FONT][/SIZE]
[SIZE=2][FONT=Courier New]SetThrusterMax0 (th_main[1] ,0);[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]SetThrusterMax0 (th_main[0] ,14700);[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]// DelExhaust (th_main[1]) ;[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]
 
[SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
[/SIZE][/FONT][/COLOR]
This mode cause CTD :facepalm:
 

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Orbiter Contributor
Addon Developer
Webmaster
GFX Staff
Beta Tester
Joined
Aug 9, 2009
Messages
6,926
Reaction score
794
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
I can only see half of it. Take the black colours out, and then I might be able to assist you.
 

Thorton

sense offender
Addon Developer
Joined
Mar 31, 2008
Messages
330
Reaction score
1
Points
0
Location
Tomsk
What exactly do you want to do?
If you want just switch to another engine construction should be:
Code:
if (cover_proc >=0.01)
{ 
SetThrusterLevel  ( th_main[0],    0.0);
SetThrusterLevel  ( th_main[1],    1.0);
}
if (cover_proc <=0.01)
{ 
SetThrusterLevel  ( th_main[1],    0.0);
SetThrusterLevel  ( th_main[0],    1.0);

}

However it is not good idea to put this code in PostStep, it's better to allow animation function trigger this selection.
Also it looks like you do not understand what is actually SetThrusterMax0 () do.
 
Last edited:

marcogavazzeni

Addon Developer
Addon Developer
Joined
Jan 5, 2009
Messages
219
Reaction score
0
Points
16
Location
Near Verona
Website
orbiteritalia.forumotion.com
I can only see half of it. Take the black colours out, and then I might be able to assist you.

you see?
Code:
if (cover_proc >=0.01)
 
[COLOR=black]{ [/COLOR]
[COLOR=black]SetThrusterMax0 (th_main[0],0 ); [/COLOR]
[COLOR=black]SetThrusterMax0 (th_main[1] ,23045);[/COLOR]
[COLOR=black]}[/COLOR]
[COLOR=black]if (cover_proc <=0.01)[/COLOR]
[COLOR=black]{  [/COLOR]
[COLOR=black]SetThrusterMax0 (th_main[1] ,0);[/COLOR]
[COLOR=black]SetThrusterMax0 (th_main[0] ,14700);[/COLOR]
[COLOR=black]}[/COLOR]



In this mode does not work
What exactly do you want to do?
If you want just switch to another engine construction should be:
Code:
if (cover_proc >=0.01)
{ 
SetThrusterLevel  ( th_main[0],    0.0);
SetThrusterLevel  ( th_main[1],    1.0);
}
if (cover_proc <=0.01)
{ 
SetThrusterLevel  ( th_main[1],    0.0);
SetThrusterLevel  ( th_main[0],    1.0);
 
}


I changed this....
Code:
// animate cover jet engine
 if (cover_status >= DOOR_CLOSING) {
  double da = simdt * COVER_OPERATING_SPEED;
 if (cover_status == DOOR_CLOSING) {
 if (cover_proc > 0.0)
    cover_proc = max (0.0, cover_proc-da);
 
   else {
    cover_status = DOOR_CLOSED;
    SetThrusterMax0 (th_main[1],0 ); 
    SetThrusterMax0 (th_main[0] ,14700);
   }
  } else { // 
   if (cover_proc < 1.0)
    cover_proc = min (1.0, cover_proc+da);
   else {
    cover_status = DOOR_OPEN;
    SetThrusterMax0 (th_main[0] ,0);
    SetThrusterMax0 (th_main[1] ,24000);
  }
  }
  SetAnimation (anim_cover, cover_proc);
  }
But the problem remains,the rendering of flames engine.

I want this:

SetThrusterMax0 (th_main[1],0 ); Flames engine OFF
SetThrusterMax0 (th_main[0] ,14700);Flames engine ON

SetThrusterMax0 (th_main[0] ,0); Flames engine OFF
SetThrusterMax0 (th_main[1] ,24000); Flames engine ON

How can i do?
 

Izack

Non sequitur
Addon Developer
Joined
Feb 4, 2010
Messages
6,665
Reaction score
13
Points
113
Location
The Wilderness, N.B.
You can turn off the WYSIWYG editor (this button:
switchmode.gif
) and remove all the colour tags. It helps to do that if you're using another application to compose your posts. :tiphat:
 

tblaxland

O-F Administrator
Administrator
Addon Developer
Webmaster
Joined
Jan 1, 2008
Messages
7,320
Reaction score
25
Points
113
Location
Sydney, Australia
I changed this....
See what Thornton said. SetThrusterMax0 sets the maximum available thrust, it does not set the current trust from the engine. Unless you are varying the maximum thrust available from the engines (you don't seem to be), you should not need to call this function since you just need to set the thrust correctly when you define the thruster initially. Use SetThrusterLevel to turn the thrusters on and off instead. The exhaust flames will disappear by themselves when you set the thrust level to zero.
 

computerex

Addon Developer
Addon Developer
Joined
Oct 16, 2007
Messages
1,282
Reaction score
17
Points
0
Location
Florida
OK, to me it seems that you are trying to shut off one thruster while some gate is closed, and you are opening it back up once it is open. Keep in mind, that your SetThrusterMax function will be executed multiple times because it is called every timestep. You don't want that. Have some bool in your class, and use that as a flag.
 
Last edited:

marcogavazzeni

Addon Developer
Addon Developer
Joined
Jan 5, 2009
Messages
219
Reaction score
0
Points
16
Location
Near Verona
Website
orbiteritalia.forumotion.com
You can turn off the WYSIWYG editor (this button:
switchmode.gif
) and remove all the colour tags. It helps to do that if you're using another application to compose your posts. :tiphat:
How strange...I use the white backround :shrug:
If I write in red is ok?:cool:

See what Thornton said. SetThrusterMax0 sets the maximum available thrust, it does not set the current trust from the engine. Unless you are varying the maximum thrust available from the engines (you don't seem to be), you should not need to call this function since you just need to set the thrust correctly when you define the thruster initially. Use SetThrusterLevel to turn the thrusters on and off instead. The exhaust flames will disappear by themselves when you set the thrust level to zero.

I already tried this option(SetThrusterLevel),but it produces problem with the adjustment of engine power,if I press Ctrl and + does not work,only work by pressing + and go quicly to full power


Nope.

Here's why:

That's essentially BBcode linguini, there.

Sorry :beathead:

OK, to me it seems that you are trying to shut off one thruster while some gate is closed, and you are opening it back up once it is open. Keep in mind, that your SetThrusterMax function will be executed multiple times because it is called every timestep. You don't want that. Have some bool in your class, and use that as a flag.
My ship has two engines,one engine work in the atmosphere,and one engine work in space.

Using the switch in the VC can be defined as an engine to use,always adjusting the power by pressing CTRL and + for both engines.

The problem is that the rendering of flame engine is not running,no disappears.

I tried using this feature :
bool DelThruster (THRUSTER_HANDLE &th) const;
But i'm not able to produces result :sos:

Sorry for my bad english :cool:
 

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
462
Points
83
Website
orbit.medphys.ucl.ac.uk
The max. thrust rating of a thruster (SetThrusterMax0) is not involved in calculating the visibility of the exhaust texture. Only the current thrust level is considered for this. It is assumed that the vessel code defined the exhaust geometry appropriately for the thruster during initialisation.

What you can try instead is disconnecting the thruster from its fuel tank, using SetThrusterResource with a NULL propellant handle. You should however not do this in clbkPostStep, but only at the point where you actually disable the thruster.
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
How strange...I use the white backround :shrug:
If I write in red is ok?:cool:
Not really OK for all posts you'll write, but I'll tell you how to remove formatting from text in WYSIWYG editor.

Here's for example your red text as seen in WYSIWYG editor for me:


First, place the text cursor somewhere in the text, and then press CTRL+A. This will select all the text in the post:


Next, press the button that is highlighted at the top-left side of the editor on below image:


This is the result of the above operation, and you can submit / save your post, this time without color:
 

Attachments

  • Edit1.jpg
    Edit1.jpg
    162.9 KB · Views: 59
  • Edit2.jpg
    Edit2.jpg
    154.4 KB · Views: 59
  • Edit3.jpg
    Edit3.jpg
    130 KB · Views: 59
  • Edit4.jpg
    Edit4.jpg
    128.7 KB · Views: 61

marcogavazzeni

Addon Developer
Addon Developer
Joined
Jan 5, 2009
Messages
219
Reaction score
0
Points
16
Location
Near Verona
Website
orbiteritalia.forumotion.com
The max. thrust rating of a thruster (SetThrusterMax0) is not involved in calculating the visibility of the exhaust texture. Only the current thrust level is considered for this. It is assumed that the vessel code defined the exhaust geometry appropriately for the thruster during initialisation.

What you can try instead is disconnecting the thruster from its fuel tank, using SetThrusterResource with a NULL propellant handle. You should however not do this in clbkPostStep, but only at the point where you actually disable the thruster.

I created another group, THG_USER and everything works well.
I tried to use SetThrusterResource, but I take issue with the power setting.

Thank you all for your help :cheers:
 
Last edited by a moderator:

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Orbiter Contributor
Addon Developer
Webmaster
GFX Staff
Beta Tester
Joined
Aug 9, 2009
Messages
6,926
Reaction score
794
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
Not really OK for all posts you'll write, but I'll tell you how to remove formatting from text in WYSIWYG editor.

I've edited three or four of marcogavazzeni's posts attempting to remove the inserted [color=#000] tags. That button does not work to remove them.
 
Top