Advanced Question Creating vessels and interacting with them

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,731
Reaction score
2,701
Points
203
Location
Dallas, TX
A couple of questions so Hope someone can help.

I am trying to create 6 new vessels. Then attach them to the mother vessel and from the mother ship interact with a module.
This is the code I am using to create the 6 vessels. But I get a CTD right now. If only create 1 vessel then no CTD.

Code:
void LEONOVOEXT::Airbag_Check()
{
OBJHANDLE airbag;

  VESSELSTATUS2 vs;
  vs.version = 2;
  GetStatusEx (&vs);
   VESSEL *airbag_vessel;
ATTACHMENTHANDLE airbag_attach;     
if (airbag_created == 0 && airbag_jettison == 0)
{ 
  
        airbag = oapiCreateVesselEx ("Airbag1", "leonovairbag1B", &vs);
        airbag = oapiCreateVesselEx ("Airbag2", "leonovairbag2B", &vs);
        airbag = oapiCreateVesselEx ("Airbag3", "leonovairbag3B", &vs);
        airbag = oapiCreateVesselEx ("Airbag4", "leonovairbag4B", &vs);
        airbag = oapiCreateVesselEx ("Airbag5", "leonovairbag5B", &vs);
        airbag = oapiCreateVesselEx ("Airbag6", "leonovairbag6B", &vs);
//airbag_vessel = oapiGetVesselInterface (airbag);
//airbag_attach = airbag_vessel->GetAttachmentHandle (1, 0);
//AttachChild (airbag, BAG1, airbag_attach);


airbag_created =1;
}   }
cfg for leonovairbag1B
Code:
; === Configuration file for vessel class DeltaGlider ===
ClassName = leonovairbag1
MeshName = leonovairbag1
;Module = LEOAIRBAG


So once they are created then attach to the mother ship.
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
cfg for leonovairbag1B
Code:
; === Configuration file for vessel class DeltaGlider ===
ClassName = leonovairbag1
MeshName = leonovairbag1
;Module = LEOAIRBAG

Are leonovairbag2B.cfg, leonovairbag3B.cfg, leonovairbag4B.cfg, leonovairbag5B.cfg, leonovairbag6B.cfg vessel configuration files which you use to create the vessels defined the same way?
 

SolarLiner

It's necessary, TARS.
Addon Developer
Joined
Jun 14, 2010
Messages
1,847
Reaction score
2
Points
0
Location
404 ROAD NOT FOUND
Why do 6 cfg ? If they are the same, just do a "leonovairbar" vessel class and apply it to all of your 6 bags.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,731
Reaction score
2,701
Points
203
Location
Dallas, TX
no
They are different. Because they use different meshes

Code:
; === Configuration file for vessel class DeltaGlider ===
ClassName = leonovairbag2
MeshName = leonovairbag2
;Module = LEOAIRBAG

; === Configuration file for vessel class DeltaGlider ===
ClassName = leonovairbag3
MeshName = leonovairbag3
;Module = LEOAIRBAG


Are leonovairbag2B.cfg, leonovairbag3B.cfg, leonovairbag4B.cfg, leonovairbag5B.cfg, leonovairbag6B.cfg vessel configuration files which you use to create the vessels defined the same way?
 

BruceJohnJennerLawso

Dread Lord of the Idiots
Addon Developer
Joined
Apr 14, 2012
Messages
2,585
Reaction score
0
Points
36
no
They are different. Because they use different meshes

Code:
; === Configuration file for vessel class DeltaGlider ===
ClassName = leonovairbag2
MeshName = leonovairbag2
;Module = LEOAIRBAG

; === Configuration file for vessel class DeltaGlider ===
ClassName = leonovairbag3
MeshName = leonovairbag3
;Module = LEOAIRBAG

So why nott add them as separate meshes in your vessel, then work on each as needed? If I follow correctlyy, you're tryying to create a rover that lands by airbag like the MER-2003 rovers?
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,731
Reaction score
2,701
Points
203
Location
Dallas, TX
What I need to do is created the 6 airbags and attach to certain points.

Code:
BAG1 = CreateAttachment (0, _V( -1.8, 0.1, -19.53), _V( 1, 0, 0), _V(0, 1, 0), "air", 0);
BAG2 = CreateAttachment (0, _V( 1.8, 0.1, -19.53), _V( 1, 0, 0), _V(0, 1, 0), "air", 0);
BAG3 = CreateAttachment (0, _V( -0.6, 2.0, -19.53), _V( 0, 1, 0), _V(0, 0, 1), "air", 0);
BAG4 = CreateAttachment (0, _V( 0.6, 2.0, -19.53), _V( 0, 1, 0), _V(0, 0, 1), "air", 0);
BAG5 = CreateAttachment (0, _V( 0.6, -1.8, -19.53), _V( 0, 1, 0), _V(0, 0, 1), "air", 0);
BAG6 = CreateAttachment (0, _V( -0.6, -1.8, -19.53), _V( 0, 1, 0), _V(0, 0, 1), "air", 0);

The the ;Module = LEOAIRBAG is a separate module that then scales the airbags.

They need to be separate vessels as they then can be detached
 

Loru

Retired Staff Member
Retired Staff
Addon Developer
Donator
Joined
Sep 30, 2008
Messages
3,731
Reaction score
6
Points
36
Location
Warsaw
HCLV loads all LRB meshes into single vessels and then spawns them as separate vessels on separation while hiding those attached to launcher.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,731
Reaction score
2,701
Points
203
Location
Dallas, TX
What is HCLV and is it code available? I don't understand why if more than 1 vessel created then a CTD
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
You have 1 object handle for 6 objects. This is bad juju.

For a working example see my Apollo Application Project's source code, specifically the CSM's SLA separation routine.
 

Loru

Retired Staff Member
Retired Staff
Addon Developer
Donator
Joined
Sep 30, 2008
Messages
3,731
Reaction score
6
Points
36
Location
Warsaw
HCLV Hyperion is a heavy launch vehicle in developement by me and Woo482. It uses for single LRB mesh to display all 2 or 4 LRBs and on separation spawns 2-4 LRB vessels handled by second module from point/time of spawning.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,731
Reaction score
2,701
Points
203
Location
Dallas, TX
You have 1 object handle for 6 objects. This is bad juju.

For a working example see my Apollo Application Project's source code, specifically the CSM's SLA separation routine.

Thanks. where is the code sample?

Code:
OBJHANDLE airbag;
OBJHANDLE airbag1;
OBJHANDLE airbag2;
OBJHANDLE airbag3;
OBJHANDLE airbag4;
OBJHANDLE airbag5;
  VESSELSTATUS2 vs;
  vs.version = 2;
  GetStatusEx (&vs);
   VESSEL *airbag_vessel;
ATTACHMENTHANDLE airbag_attach;     
if (airbag_created == 0 && airbag_jettison == 0)
{ 
  
        airbag = oapiCreateVesselEx ("Airbag1", "leonovairbag1B", &vs);
        airbag1 = oapiCreateVesselEx ("Airbag2", "leonovairbag2B", &vs);
        airbag2 = oapiCreateVesselEx ("Airbag3", "leonovairbag3B", &vs);
        airbag3 = oapiCreateVesselEx ("Airbag4", "leonovairbag4B", &vs);
        airbag4 = oapiCreateVesselEx ("Airbag5", "leonovairbag5B", &vs);
        airbag5 = oapiCreateVesselEx ("Airbag6", "leonovairbag6B", &vs);
//airbag_vessel = oapiGetVesselInterface (airbag);
//airbag_attach = airbag_vessel->GetAttachmentHandle (1, 0);
//AttachChild (airbag, BAG1, airbag_attach);


airbag_created =1;
}   }
tried this and still ctd no log info
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
Download AAPO (See link in sig) Open the source code folder, open the CSM's source file and find the Spacecraft Launch Adapter's separation routine.

void CSM::AdapterSep (void)
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,731
Reaction score
2,701
Points
203
Location
Dallas, TX
Code:
OBJHANDLE airbag;
OBJHANDLE airbag1;
OBJHANDLE airbag2;
OBJHANDLE airbag3;
OBJHANDLE airbag4;
OBJHANDLE airbag5;
  VESSELSTATUS2 vs;
  vs.version = 2;
  GetStatusEx (&vs);
  vs.flag=0;
   VESSEL *airbag_vessel;

still CTD
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
Code:
OBJHANDLE airbag;
OBJHANDLE airbag1;
OBJHANDLE airbag2;
OBJHANDLE airbag3;
OBJHANDLE airbag4;
OBJHANDLE airbag5;
  VESSELSTATUS2 vs;
  vs.version = 2;
  GetStatusEx (&vs);
  vs.flag=0;
   VESSEL *airbag_vessel;
still CTD

Please try it BEFORE using the structure, i.e. before calling GetStatusEx. The flag parameter also controls the getter options.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,731
Reaction score
2,701
Points
203
Location
Dallas, TX
Thanks. now created. But how to attach.
Code:
{
      
OBJHANDLE airbag;
OBJHANDLE airbag1;
OBJHANDLE airbag2;
OBJHANDLE airbag3;
OBJHANDLE airbag4;
OBJHANDLE airbag5;
  VESSELSTATUS2 vs;
  vs.version = 2;
  vs.flag=0;
  GetStatusEx (&vs);
 
   VESSEL *airbag_vessel;
ATTACHMENTHANDLE airbag_attach;     
if (airbag_created == 0 && airbag_jettison == 0)
{ 
  
        airbag = oapiCreateVesselEx ("Airbag1", "leonovairbag1B", &vs);
        airbag1 = oapiCreateVesselEx ("Airbag2", "leonovairbag2B", &vs);
        airbag2 = oapiCreateVesselEx ("Airbag3", "leonovairbag3B", &vs);
        airbag3 = oapiCreateVesselEx ("Airbag4", "leonovairbag4B", &vs);
        airbag4 = oapiCreateVesselEx ("Airbag5", "leonovairbag5B", &vs);
        airbag5 = oapiCreateVesselEx ("Airbag6", "leonovairbag6B", &vs);
airbag_vessel = oapiGetVesselInterface (airbag);
airbag_attach = airbag_vessel->GetAttachmentHandle (1, 0);
AttachChild (airbag, BAG1, airbag_attach);


airbag_created =1;
}   }

Not sure where it gets the child airbag info.
PHP:
Airbag1:leonovairbag1B
  STATUS Orbiting Jupiter
  RPOS 59979190.69 -2205558.91 -108426104.26
  RVEL -28143.715 -2113.239 -12634.729
  AROT -112.89 77.41 58.55
  AFCMODE 7
  NAVFREQ 0 0
END
Airbag2:leonovairbag2B
  STATUS Orbiting Jupiter
  RPOS 59979190.69 -2205558.91 -108426104.26
  RVEL -28143.715 -2113.239 -12634.729
  AROT -112.89 77.41 58.55
  AFCMODE 7
  NAVFREQ 0 0
END
Airbag3:leonovairbag3B
  STATUS Orbiting Jupiter
  RPOS 59979190.69 -2205558.91 -108426104.26
  RVEL -28143.715 -2113.239 -12634.729
  AROT -112.89 77.41 58.55
  AFCMODE 7
  NAVFREQ 0 0
END
Airbag4:leonovairbag4B
  STATUS Orbiting Jupiter
  RPOS 59979190.69 -2205558.91 -108426104.26
  RVEL -28143.715 -2113.239 -12634.729
  AROT -112.89 77.41 58.55
  AFCMODE 7
  NAVFREQ 0 0
END
Airbag5:leonovairbag5B
  STATUS Orbiting Jupiter
  RPOS 59979190.69 -2205558.91 -108426104.26
  RVEL -28143.715 -2113.239 -12634.729
  AROT -112.89 77.41 58.55
  AFCMODE 7
  NAVFREQ 0 0
END
Airbag6:leonovairbag6B
  STATUS Orbiting Jupiter
  RPOS 59979190.69 -2205558.91 -108426104.26
  RVEL -28143.715 -2113.239 -12634.729
  AROT -112.89 77.41 58.55
  AFCMODE 7
  NAVFREQ 0 0
END


I uncommented in the CFG to allow the module to be airbag.

in the cpp of the airbag module I think is where the child attachment is.

Code:
if (_stricmp (GetName(), "airbag1") == 0 || _stricmp (GetName(), "airbag2") == 0)
CreateAttachment (1, _V(0, 0, 0), _V(1, 0, 0), _V(0, 1, 0), "Leonov", 0);
else
CreateAttachment (1, _V(0, 0, 0), _V(0, -1, 0), _V(0, 0, 1), "Leonov", 0);
}
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
If you have not defined an attachment point/handle for your airbag that would be the cause of the ctd.

---------- Post added at 12:42 ---------- Previous post was at 12:36 ----------

I also suspect that AAPO's parachute and drogue code would be highly useful to you.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,731
Reaction score
2,701
Points
203
Location
Dallas, TX
Thanks. I think we may just create the vessels in the scenario editor and attach. But how can I control them from the one mother ship.

In the airbag module. It looks like it gets
Code:
if (bagdoor_operate >= 2 && airbag_jettison == 0)
from the mothership.
Code:
#ifndef __POD_H
#define __POD_H

#include "orbitersdk.h"

#define DLLEXPORT __declspec(dllexport)
#define DLLIMPORT __declspec(dllimport)

//Leonov shared data
DLLIMPORT double bagdoor_proc;
DLLIMPORT int bagdoor_operate;
DLLIMPORT int airbag_jettison;

VESSELSTATUS2 vs;

class Airbag: public VESSEL {
public:
Airbag (OBJHANDLE hObj, int fmodel);
~Airbag ();
 
Top