Project Shavit/Jericho Module Development

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
Ok, to start this thread, I would like to introduce the addon. It uses the Israeli three-stage Shavit launcher with a Jericho ICBM on top. http://en.wikipedia.org/wiki/Jericho_(missile)

And there are some pictures of mine.

Basically, I felt the need to start learning C++ and Orbiter API because of how everyone raves about how much more benefits it has compared to SC3 and Multistage. So I figured, why not make this addon a .dll? It has been almost two weeks or maybe even two that I have been working on it. Let me tell you, it is not an easy task especially if you are new to it, but I like and learn better learning by trial and error.

What I got done so far is the main code for the Shavit launcher and I just need to do some minor adjustments concerning thruster groups, jettisons, and other visual aspects. By the time that I am done, I hope to have a fully functional three-stage rocket with clean and fun flight. Maybe even I will release a surface base for Israel since this is in fact an Israeli rocket.

If anyone is willing to help this new comer in the field of C++ that would be great. For example, I have already received much help from these given names. Xyon, Woo482, Zantikelmen (Can't spell his name :lol:), Orb, and some others.

Thanks all for the help and I surely appreciate it even if I am a pain in the butt. :cheers:

I will keep you guys up to date on this project hopefully daily and weekly and let you know how it is going. Thanks.

P.S. It will be released for Orbiter 2010. In another thread it was being compiled with the old 2006 SDK and I forgot to change that, but now it is for 2010.
 

Attachments

  • S1sep.jpg
    S1sep.jpg
    109.8 KB · Views: 2
  • Inentry.png
    Inentry.png
    299.8 KB · Views: 2
  • Finalsep.jpg
    Finalsep.jpg
    87.1 KB · Views: 3
  • S3burning.jpg
    S3burning.jpg
    51 KB · Views: 5
Last edited:

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
I got a quick and easy question. I understand the syntax of Orbiter SDK when it comes to TouchDownPoints, but what about the .cfg under the vessel folder? In the manual it said that it could read the coordinates differently so I was just wondering. I got the .cpp file down and I just need this since they are different classes I need to define them. For example, in the module, it looks like this...SetTouchdownPoints (_V(0,-1,-7.25),_V(-1,1,-7.25),_V(1,1,-7.25));

Now in the .cfg file, would it look like this....? (0,-1,-7.25), (-1,1,-7.25), (1,1,-7.25)

---------- Post added Sep 6th, 2010 at 09:29 AM ---------- Previous post was Sep 5th, 2010 at 05:02 PM ----------

I have set up a code to jettison after the fuel is below a certain point. Now concerning that it does not jettison after the fuel reaches 0 is what confuses me. Here is the function of jettison and creating vessels.

Code:
void Shavit::SpawnObject(char* classname, char* ext, VECTOR3 ofs) {
  VESSELSTATUS vs;
  char name[256];
  GetStatus(vs);
  Local2Rel (ofs, vs.rpos);
  vs.eng_main = vs.eng_hovr = 0.0;
  vs.status = 0;
  strcpy (name, GetName()); strcat (name, ext);
  oapiCreateVessel (name, classname, vs);
}

void Shavit::Jettison() {
 switch(status) {
    case 0:
      status=1;
      SpawnObject("ShavitS2","_S2",_V(0,0,7));
      break;
    case 1:
      status=2;
      SpawnObject("ShavitS3","_S3",_V(0,0,12));
      break;
	      case 2:
      status=2;
      SpawnObject("ShavitJericho3","_Jericho3",_V(0,0,15));
      break;
  
  }

ShavitS1, ShavitS2, ShavitS3, and ShavitJericho3 are the mesh names while the _S1 and etc is the .cfg file. Anyone got an answer for this?
 
Last edited:

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Addon Developer
Webmaster
GFX Staff
Donator
Beta Tester
Joined
Aug 9, 2009
Messages
6,804
Reaction score
505
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
I don't see where you check against fuel level and call jettison if it's below a certain value.
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
As soon as I get my laptop back I'll get that part of the code. I was in some sort of a rush and had to go to work not knowing I was on schedule. :dry:
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
Here it is.
Code:
Jettison();
  }
  if(status == 0 && GetPropellantMass(ph_main)<1.0*ShavitS1MAIN_PROP_MASS) {
    //First Stage Jettison 
    Jettison();
    //-------------------//
    SetThrusterLevel(th_main,1);
  }

It looks fine to me, but at the same time it is not working so.....
 

Woo482

Moderator
Moderator
Addon Developer
GFX Staff
Joined
Feb 13, 2008
Messages
3,046
Reaction score
19
Points
78
Location
Earth?
Looks like your checking if the current propellant mass is less than the maximum fuel amount :p, which would happen whenever you burn the fuel, try using this code instead, which just checks if the fuel tank has less than 1kg of fuel in it:

Code:
if(status == 0 && GetPropellantMass(ph_main) < 1)
{
    //First Stage Jettison 
    Jettison();
    //-------------------//
    SetThrusterLevel(th_main,1);
}

That code should do Jettison(); whenever the fuel is less than 1kg (or whatever you want to use) :thumbup:
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
Looks like your checking if the current propellant mass is less than the maximum fuel amount :p, which would happen whenever you burn the fuel, try using this code instead, which just checks if the fuel tank has less than 1kg of fuel in it:

Code:
if(status == 0 && GetPropellantMass(ph_main) < 1)
{
    //First Stage Jettison 
    Jettison();
    //-------------------//
    SetThrusterLevel(th_main,1);
}
That code should do Jettison(); whenever the fuel is less than 1kg (or whatever you want to use) :thumbup:
Your code was good and works, but it seems as if the meshes won't attach to the first stage like I put. I set up the meshes and that part of the codes looks something like this.
Code:
void Shavit::Jettison() {
 switch(status) {
    case 0:
      status=1;
      SpawnObject("ShavitS1","_S1",_V(0,0,-0.8));
      break;
    case 1:
      status=0;
      SpawnObject("ShavitS2","_S2",_V(0,0,-0.8));
      break;
    case 2:
      status=0;
      SpawnObject("ShavitS3","_S3",_V(0,0,-0.5));
      break;
          case 3:
      status=0;
      SpawnObject("ShavitJericho3","_Jericho3",_V(0,0,-0.5));
      break;
  
  }
  SetupMeshes();
}
It must have something to do with the names and references. Tomorrow I will have another go at it, but it you see something wrong just point it out and I will try to fix it myself. :thumbup: Thanks for the help.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
36,748
Reaction score
1,410
Points
203
Location
Langendernbach
Do you have configuration files for the stage vessels?
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
Do you have configuration files for the stage vessels?
Here are my .cfg files concerning the vessel parts. I didn't put any attachment points in them because I thought that was already defined and established in the .dll.

I always thought that everything was handled in the actual .dll while the .cfg file would be like a "converter/activator" for Orbiter to read it.
 

Attachments

  • Jericho-cfg.zip
    998 bytes · Views: 3

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Addon Developer
Webmaster
GFX Staff
Donator
Beta Tester
Joined
Aug 9, 2009
Messages
6,804
Reaction score
505
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
It can be, in which case the .cfg file would just point to the module and Orbiter will take the data from there. The reason clbkSetClassCaps is written with an argument of (FILEHANDLE cfg) is so that values in the .cfg file can overwrite information in clbkSetClassCaps, however, which can be incredibly useful for things like fine-tuning attachpoint coordinates without needing to recompile each time.
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
It can be, in which case the .cfg file would just point to the module and Orbiter will take the data from there. The reason clbkSetClassCaps is written with an argument of (FILEHANDLE cfg) is so that values in the .cfg file can overwrite information in clbkSetClassCaps, however, which can be incredibly useful for things like fine-tuning attachpoint coordinates without needing to recompile each time.
So what you are saying is that I need to place the attachment point in the .cfg? I as well, would think that would be easier. :p
 

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Addon Developer
Webmaster
GFX Staff
Donator
Beta Tester
Joined
Aug 9, 2009
Messages
6,804
Reaction score
505
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
I'm not saying you need to, I'm saying you can put it in either. What I do during development is to write them into the .cfg file until I have the numbers spot on, then plug them into the module to hardcode them once they're right, if they're going to be permanent attach points.
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
I'm not saying you need to, I'm saying you can put it in either. What I do during development is to write them into the .cfg file until I have the numbers spot on, then plug them into the module to hardcode them once they're right, if they're going to be permanent attach points.
Alrighty. Will do. I'll go ahead and use your method and see how it unfolds. After all. I got plenty of time. I had some crazy thoughts today at school about making another rocket, but a medium ranged variation. Comes complete with a base and everything. That is way in the future though. Lol.

---------- Post added at 04:20 PM ---------- Previous post was at 04:16 PM ----------

Oh yeah, the landing points are going to look just like this in the cfg right?
Code:
TouchDownPoints = (0,-1,-7.25), (-1,1,-7.25), (1,1,-7.25)

That should make it upright if I am not mistaken. This is in the manual, but there isn't an actual example with numbers. Thanks.
 

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Addon Developer
Webmaster
GFX Staff
Donator
Beta Tester
Joined
Aug 9, 2009
Messages
6,804
Reaction score
505
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
No, cfg files use a slightly different syntax. For instance:

TouchdownPoints = 0 -1.209 0.955 -1.466 -1.209 -0.955 1.466 -1.209 -0.955

Iirc they're the same values in the same order, but with only space separators.
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
Well, Xyon, I am now a step closer to completing the rocket. I am going to be working on contrails and exhaust. Thank you very much. I'll put some pictures up in a sec. :thumbup:

---------- Post added at 06:23 PM ---------- Previous post was at 05:35 PM ----------

Well, I am having bad luck with the exhaust and contrail. It is all right here.

Code:
 PARTICLESTREAMSPEC contrail_main = {
        0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
        PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
        PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
    };
    PARTICLESTREAMSPEC exhaust_main = {
        0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
        PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
        PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
    };
  
  ph_main = CreatePropellantResource(MAIN_PROP_MASS);
  ph_rcs     = CreatePropellantResource(RCS_PROP_MASS);

  th_main[3] = CreateThruster(_V(0,-8,0), _V(0,1,0), MAIN_THRUST, ph_main, MAIN_ISP);
  CreateThrusterGroup(th_main, 3, THGROUP_MAIN);;
    AddExhaust (th_main, 8, 1, _V(0,-5,0), _V(0,-5,0));
  }
I promise to leave you alone after this. :facepalm:
 
Last edited:

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Addon Developer
Webmaster
GFX Staff
Donator
Beta Tester
Joined
Aug 9, 2009
Messages
6,804
Reaction score
505
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
Define "Bad luck"? You're not actually attaching those particle streams to the exhausts in that snippet, that I can see at least. You need an AddExhaustStream to do that.
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
I must have deleted it then. This was right below it.
Code:
    AddExhaustStream (th_main, _V(0,-8,0), &contrail_main);
    AddExhaustStream (th_main[0], _V(0,-10,0), &exhaust_main);
It references itself back to the particle streams, but it is not exactly working. Man, after I changed my code completely I have been having more problems. This code is better, but still harder.
 

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Addon Developer
Webmaster
GFX Staff
Donator
Beta Tester
Joined
Aug 9, 2009
Messages
6,804
Reaction score
505
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
What is th_main, a THRUSTER_HANDLE or an array of them?
 

MJR

C++ developer in the mix
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 19, 2008
Messages
2,460
Reaction score
5
Points
0
Location
United States
It is a thruster handle under the vessel class Shavit. It looks like this.
Code:
THRUSTER_HANDLE th_main[1], th_rcs[5], th_group[1];
The actual vessel class is this. I did not list it under the THRUSTER_HANDLE under the FILEHANDLE cfg because of the format.
Code:
class Shavit: public VESSEL2 {
public:
  Shavit (OBJHANDLE hVessel, int flightmodel)
    : VESSEL2 (hVessel, flightmodel) {}
  void clbkSetClassCaps (FILEHANDLE cfg);
  int  clbkConsumeBufferedKey(DWORD key, bool down, char *kstate);
  THRUSTER_HANDLE th_main[1], th_rcs[6], th_group[1];
  double CalcEmptyMass();
  PROPELLANT_HANDLE ph_main, ph_rcs;
  void SpawnObject(char* classname, char* ext, VECTOR3 ofs);
  void Jettison();
  int status;
 

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Addon Developer
Webmaster
GFX Staff
Donator
Beta Tester
Joined
Aug 9, 2009
Messages
6,804
Reaction score
505
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
Well, it doesn't need to be an array if there's only one of them, now does it?
 
Top