.dll Question Jettisoning resource module

eveningsky339

Resident Orbiter Slave
Addon Developer
Donator
Joined
May 3, 2008
Messages
1,062
Reaction score
1
Points
0
Location
Western Maine
I should probably ask this before I get too far into coding my addon...

I am creating a vessel which consists of a command module and a resource module (think Apollo or CEV). Obviously, the resource module needs to be jettisoned before re-entry.

My question is, how can I actually implement this into a .dll? I do not want to use the CVE-lite libraries due to their age, but I would think that the VESSEL2 class has everything I need as it is.

I'm guessing that this involves adding and deleting meshes (and creating the resource module as a separate object, of course).
 
Last edited:

CigDriver

Donator
Donator
Joined
Mar 27, 2008
Messages
194
Reaction score
0
Points
0
I don't know the answer, but I bet you could find what yu need in the Atlantis sample code. I'd think the code for the SRB seperation or the tank would do the same thing.
 

eveningsky339

Resident Orbiter Slave
Addon Developer
Donator
Joined
May 3, 2008
Messages
1,062
Reaction score
1
Points
0
Location
Western Maine
I don't know the answer, but I bet you could find what yu need in the Atlantis sample code. I'd think the code for the SRB seperation or the tank would do the same thing.
I've looked at francisdrake's CEV 2, and it looks like he redraws the meshes and creates the jettisoned RM as a separate object. I believe the Atlantis works differently, but I'll definitely take a look.
 

francisdrake

Addon Developer
Addon Developer
Joined
Mar 23, 2008
Messages
1,076
Reaction score
893
Points
128
Website
francisdrakex.deviantart.com
Yes, in the CEV code the jettisoned resource model is created as a new vessel.

Code:
[SIZE=2][COLOR=#008000]
[SIZE=2][COLOR=#008000]//================================================[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]// Create Ressource Module as an individual object[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]//================================================[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] CEV::blowRM() {[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (oapiGetTimeAcceleration() > 10) [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Slow down[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]oapiSetTimeAcceleration(10);[/SIZE]
[SIZE=2]SetConfig2_Reentry(); [/SIZE]
 
[SIZE=2]VESSELSTATUS vs;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] name[256]= {[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]};[/SIZE]
[SIZE=2]THRUSTER_HANDLE th_att_lin[16];[/SIZE]
[SIZE=2]OBJHANDLE h;[/SIZE]
[SIZE=2]VESSEL *v;[/SIZE]
[SIZE=2]GetStatus (vs);[/SIZE]
[SIZE=2]vs.flag[0] = 3;[/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2]VECTOR3 ofs = {0,0,-1.87};[/SIZE]
[SIZE=2]Local2Rel (ofs, vs.rpos);[/SIZE]
[SIZE=2]VECTOR3 vel = _V(0,0,-0.02);[/SIZE]
[SIZE=2]VECTOR3 rofs, rvel = {vs.rvel.x, vs.rvel.y, vs.rvel.z};[/SIZE]
[SIZE=2]Local2Rel (ofs, vs.rpos);[/SIZE]
[SIZE=2]GlobalRot (vel, rofs);[/SIZE]
[SIZE=2]vs.rvel.x = rvel.x+rofs.x;[/SIZE]
[SIZE=2]vs.rvel.y = rvel.y+rofs.y;[/SIZE]
[SIZE=2]vs.rvel.z = rvel.z+rofs.z;[/SIZE]
[SIZE=2]strcpy (name, GetName()); strcat (name, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"-RM"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]h = oapiCreateVessel (name, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"CEV-Orion\\CEV-Orion-RM"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], vs);[/SIZE]
[SIZE=2]v = oapiGetVesselInterface(h);[/SIZE]
[SIZE=2]v-> SetEmptyMass (SM_DRYMASS);[/SIZE]
[SIZE=2]ph_RM = v->CreatePropellantResource( 13.0, 13.0, 1.0 );[/SIZE]
[SIZE=2]th_att_lin[8] = v->CreateThruster (_V( 0.08, 2.65, 0.4), _V(0,-0.2,-1), RCS_THRUST/3, ph_RM, RCS_ISP);[/SIZE]
[SIZE=2]th_att_lin[9] = v->CreateThruster (_V(-0.08, 2.65, 0.4), _V(0,-0.2,-1), RCS_THRUST/3, ph_RM, RCS_ISP);[/SIZE]
[SIZE=2]th_att_lin[10] = v->CreateThruster (_V( 0.08,-2.65, 0.4), _V(0, 0.2,-1), RCS_THRUST/3, ph_RM, RCS_ISP);[/SIZE]
[SIZE=2]th_att_lin[11] = v->CreateThruster (_V(-0.08,-2.65, 0.4), _V(0, 0.2,-1), RCS_THRUST/3, ph_RM, RCS_ISP);[/SIZE]
[SIZE=2]th_att_lin[12] = v->CreateThruster (_V( 2.65, 0.08, 0.4), _V(-0.2, 0,-1), RCS_THRUST/3, ph_RM, RCS_ISP);[/SIZE]
[SIZE=2]th_att_lin[13] = v->CreateThruster (_V( 2.65,-0.08, 0.4), _V(-0.2, 0,-1), RCS_THRUST/3, ph_RM, RCS_ISP);[/SIZE]
[SIZE=2]th_att_lin[14] = v->CreateThruster (_V(-2.65, 0.08, 0.4), _V( 0.2, 0,-1), RCS_THRUST/3, ph_RM, RCS_ISP);[/SIZE]
[SIZE=2]th_att_lin[15] = v->CreateThruster (_V(-2.65,-0.08, 0.4), _V( 0.2, 0,-1), RCS_THRUST/3, ph_RM, RCS_ISP);[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i=8; i<16; i++) {[/SIZE]
[SIZE=2]v->AddExhaust( th_att_lin[i], R_SIZE, tex_rcs);[/SIZE]
[SIZE=2]v->SetThrusterLevel(th_att_lin[i], 1.0 );[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]v-> SetSize(6);[/SIZE]
[SIZE=2]v-> SetCrossSections (_V(24,28,19));[/SIZE]
[SIZE=2]v-> SetCW (0.5, 0.5, 1, 1);[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Hack to display the solar panel around the separated RM[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]solar = 1; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// deploy solar panels in case not yet open[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]GetStatus (vs);[/SIZE]
[SIZE=2]vs.flag[0] = 3; [/SIZE]
[SIZE=2]ofs = _V(0,0,-2);[/SIZE]
 
[SIZE=2]Local2Rel (ofs, vs.rpos);[/SIZE]
[SIZE=2]vel = _V(0,0,-0.02);[/SIZE]
[SIZE=2]rofs, rvel = _V(vs.rvel.x, vs.rvel.y, vs.rvel.z);[/SIZE]
[SIZE=2]Local2Rel (ofs, vs.rpos);[/SIZE]
[SIZE=2]GlobalRot (vel, rofs);[/SIZE]
[SIZE=2]vs.rvel.x = rvel.x+rofs.x;[/SIZE]
[SIZE=2]vs.rvel.y = rvel.y+rofs.y;[/SIZE]
[SIZE=2]vs.rvel.z = rvel.z+rofs.z;[/SIZE]
[SIZE=2]strcpy (name, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"S"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE]
[SIZE=2]h = oapiCreateVessel (name, [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"CEV-Orion\\CEV-Orion-RMS"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], vs); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// config file of created solar panel[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]v = oapiGetVesselInterface(h);[/SIZE]
[SIZE=2]v-> SetEmptyMass (SM_DRYMASS);[/SIZE]
[SIZE=2]ph_RM = v->CreatePropellantResource( 0.9775*13.0, 0.9775*13.0, 1.0 );[/SIZE]
[SIZE=2]th_att_lin[0] = v->CreateThruster (_V( 0, 0, 0), _V(0, 0,-1), 0.9785*8*RCS_THRUST/3, ph_RM, RCS_ISP);[/SIZE]
[SIZE=2]v->SetThrusterLevel(th_att_lin[0], 1.0 );[/SIZE]
[SIZE=2]v-> SetSize(6);[/SIZE]
[SIZE=2]v-> SetCrossSections (_V(24,28,19));[/SIZE]
[SIZE=2]v-> SetCW (0.5, 0.5, 1, 1);[/SIZE]
[SIZE=2]}[/SIZE]

Note: Actually this code creates 2 vessels, the RM and the open solar panels (RMS, hack!). This could probably be better done by just adding both meshes to a single new vessel.

The thruster definition is to have the RCS fire backwards for a clear separation.

A separate cfg file of the jettisoned RM is required.

File CEV-Orion-RM:
; === Configuration file for vessel class ===
; === to handle the Res Module after separation
ClassName = CEV-Orion-RM
MeshName = CEV-Orion\CEV-Orion-RM
 

eveningsky339

Resident Orbiter Slave
Addon Developer
Donator
Joined
May 3, 2008
Messages
1,062
Reaction score
1
Points
0
Location
Western Maine
Thank you francis, the source code you included with your biconic CEV is actually what I'm using to figure out what I need to. :)
 
Top