Project Soviet Superbooster: YaKhR-2

Graham2001

Well-known member
Joined
Mar 20, 2008
Messages
1,523
Reaction score
73
Points
48
I've started work on my first attempt at building a launch vehicle for Orbiter.

The spacecraft in question was an early superbooster proposal by the Korolev bureau. Essentially a 'super' R-7, the YaKhR-2 used six strap on boosters to launch an ammonia burning nuclear-thermal core designed to place up to 40 tons into low earth orbit. (See: Astronautix: YaKhR-2)

I'm planning to create this vehicle by modifying the [nomedia="http://www.orbithangar.com/searchid.php?ID=1462"]CVEL Soyuz v0.4[/nomedia] code and have hit an unusual problem when I tried to compile my first step, a modified version of the original code designed to place an extra pair of boosters on the Soyuz. It seems that my version of Vistual C++ is too new to work with the lightly modified code.:blush:

I do not know enough about C++ coding to modify what I have created to avoid this, so I am putting out an official request for help and placed a copy of the code I have created below. It is intended to work with the original Soyuz header from CVEL Soyuz, if an attempt is made to compile, rename the resulting .dll 'Soyuz6.dll'.

Code:
// ==============================================================
// $Id: soyuz.cpp,v 1.7 2004/09/07 00:35:29 dh219 Exp $
// Proton-K by D Henderson [email protected]
// Copyright 2004
// Released under the terms of the LGPL: http://www.gnu.org/licenses/lgpl.txt

/*
    This software and sourcecode is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/

/*Modified by Graham2001 to add two extra boosters to the original rocket
*/

// ==============================================================

#include "soyuz.h"


SOYUZ::SOYUZ (OBJHANDLE hObj, int fmodel) : COMMON_VESSEL_EX( hObj )
{

	hbooster[0] = oapiLoadMeshGlobal ("r7blockb");
	hbooster[1] = oapiLoadMeshGlobal ("r7blockw");
	hbooster[2] = oapiLoadMeshGlobal ("r7blockg");
	hbooster[3] = oapiLoadMeshGlobal ("r7blockd");
    hbooster[4] = oapiLoadMeshGlobal ("r7blockx");
    hbooster[5] = oapiLoadMeshGlobal ("r7blocky");
	hstage1 = oapiLoadMeshGlobal ("r7blocka");
	hstage2 = oapiLoadMeshGlobal ("r7blocki");
	hstage2alt = oapiLoadMeshGlobal ("r7blockiNoPAF");
	hfairb = oapiLoadMeshGlobal ("soyufair1");
	hfairf = oapiLoadMeshGlobal ("soyufair2");
	hfairl = oapiLoadMeshGlobal ("soyshrd1");
	hfairr = oapiLoadMeshGlobal ("soyshrd2");
	histg[0] = oapiLoadMeshGlobal ("r7skirt3p1");
	histg[1] = oapiLoadMeshGlobal ("r7skirt3p2");
	histg[2] = oapiLoadMeshGlobal ("r7skirt3p3");
	hring = oapiLoadMeshGlobal( "soyuring" );
	hescape = oapiLoadMeshGlobal ("r7tmaer");

	tex = oapiRegisterExhaustTexture ("Exhaust2");

	manual_separate=false;
	fair_attached = false;
	manned_launch = false;
	no_PAF = false;

	comshift = 0.0;

	stage = 2;


	ph_booster[0]	= NULL;	
	ph_booster[1]	= NULL;	
	ph_booster[2]	= NULL;	
	ph_booster[3]	= NULL;	
	ph_booster[4]	= NULL;	
	ph_booster[5]	= NULL;	
	ph_first        = NULL;
	ph_second       = NULL;

	OFF_BOOSTER[0] = _V(3.2,0,0);
	OFF_BOOSTER[1] = _V(0,3.2,0);
	OFF_BOOSTER[2] = _V(-3.2,0,0);
	OFF_BOOSTER[3] = _V(0,-3.2,0);
	OFF_BOOSTER[4] = _V(0,-1.6,0);
	OFF_BOOSTER[5] = _V(0,1.6,0);

	OFF_STG1 = _V(0, 0, 4);
	OFF_STG2= _V(0,0,22.2);
	OFF_ISTG[0] = _V(0.665,0.33,19.19);
	OFF_ISTG[1] = _V(-0.665,0.33,19.19);
	OFF_ISTG[2] = _V(0,-1.05,19.19);
	OFF_LHF = _V(0,0,0); // these get assigned in refresh()
	OFF_RHF = _V(0,0,0);

	OFF_ESCAPE = _V(0,0,38.5);

	OFF_RING= _V(0,0,27);
}

SOYUZ::~SOYUZ()
{
}

void SOYUZ::SetClassCaps(  FILEHANDLE cfg )
{

}
int SOYUZ::ConsumeBufferedKey(DWORD dwKey, bool fPressed, const char *keystate) {

		if (KEYDOWN (keystate, OAPI_KEY_J) && !KEYMOD_CONTROL(keystate) && !KEYMOD_SHIFT(keystate) ) 
		{ // "Jettison Stage"
			if (oapiAcceptDelayedKey (OAPI_KEY_J, 1.0))
				manual_separate=true;
			return 1;
		}
		else if (KEYDOWN (keystate, OAPI_KEY_J) && KEYMOD_CONTROL(keystate) && !KEYMOD_SHIFT(keystate) ) 
		{ // "Jettison Fairing"
			if (oapiAcceptDelayedKey (OAPI_KEY_J, 1.0))
				JettisonFairing();
			return 1;
		}
		else if (KEYDOWN (keystate, OAPI_KEY_E) && KEYMOD_CONTROL(keystate) && !KEYMOD_SHIFT(keystate) ) 
		{ // "Jettison Stage"
			if (oapiAcceptDelayedKey (OAPI_KEY_E, 1.0))
			{
				JettisonFairing();
				depV = DeployPayload();
				hVessel=oapiGetVesselByName(depV->GetName());
				if (hVessel != 0)
					oapiSetFocusObject(hVessel);
				Refresh();
			}
		}
	return 0;
}
void SOYUZ::TimeStep(  double simt )
{
//	sprintf( oapiDebugString(), "%2.2f", GetMass() );

	if( fair_attached && GetAltitude() > 100000.0 ) {
		JettisonFairing();
	}

	if( stage == 0 ) {
		if( manual_separate || GetPropellantMass( ph_booster[0] ) < 1000.0 )
		{
			manual_separate=false;
			JettisonBoosters();
			stage = 1;
			Refresh();
			SetThrusterGroupLevel(THGROUP_MAIN,1.0);
		}
	}
	else if( stage == 1 ) {
		if( manual_separate || GetPropellantMass( ph_first ) < 1000.0 )
		{
			manual_separate=false;
			JettisonStg1();
			stage = 2;
			Refresh();
			SetThrusterGroupLevel(THGROUP_MAIN,1.0);
		}
	}
	else if( stage == 2 ) {
		if( manual_separate && !fair_attached ) {
			manual_separate = false;
			depV = DeployPayload();
			hVessel=oapiGetVesselByName(depV->GetName());
			if (hVessel != 0)
				oapiSetFocusObject(hVessel);
			Refresh();
		}
	}


}
void SOYUZ::SaveState( FILEHANDLE scn )
{
	SaveDefaultState (scn);
	oapiWriteScenario_int (scn, "CONFIGURATION", stage );
	if( fair_attached )
		oapiWriteScenario_string (scn, "FAIRING", "1" );
	if( manned_launch )
		oapiWriteScenario_string (scn, "MANNED", "1" );
	if( no_PAF )
		oapiWriteScenario_string (scn, "NO_PAF", "1" );
	SaveDefaultStateEx(scn);

}
void SOYUZ::LoadState(  FILEHANDLE scn, void *vs )
{
    char *line;

	ClearMeshesEx();
	while (oapiReadScenario_nextline (scn, line)) 
	{
		ParsePayloadString( line );

		if( !strnicmp( line, "FAIRING", 7 ) ) {
			fair_attached = true;
		}
		else if( !strnicmp( line, "MANNED", 6 ) ) {
			manned_launch = true;
		}
		else if( !strnicmp( line, "NO_PAF", 6 ) ) {
			no_PAF = true;
		}
		else if( !strnicmp( line, "CONFIGURATION", 13 ) ) {
			stage = atoi( line+13 );
		}
		else 
		{
			ParseScenarioLineEx (line, vs);
		}
	}

//	PayloadBias( _V(0,0,0) );

	Refresh();
}



void SOYUZ::SetBoostStage ()
{

	double lev;
	lev = GetThrusterGroupLevel( THGROUP_MAIN );

	stage = 0;

	SetSize (50);
	SetEmptyMass ( MASS_STG0 + MASS_STG1 + MASS_STG2 + CalculateMass() );
	
//	char temp[50];
//	sprintf( temp, "0: %2.2f 1: %2.2f 2: %2.2f T: %2.2f", MASS_STG0, MASS_STG1, MASS_STG2, MASS_STG0 + MASS_STG1 + MASS_STG2 + CalculateMass() );
//	MessageBox( NULL,"","Debug",MB_ICONINFORMATION);
	
	ShiftCentreOfMass (_V(0,0,-1.0*comshift));
	comshift = 0.0;
	ShiftCentreOfMass (_V(0,0,comshift));


	SetTouchdownPoints (_V(0,-1.0,-14), _V(-.7,.7,-14), _V(.7,.7,-14));
	SetPMI (_V(75,75,10));
	SetCrossSections (_V(105,105,25));
	SetCW (0.1, 0.3, 1.4, 1.4);
	SetRotDrag (_V(0.7,0.7,1.2));
	SetPitchMomentScale (1e-6);
	SetBankMomentScale (1e-6);
	SetLiftCoeffFunc (0); 

	ClearMeshesEx();	
	
	COMMON_MESH tmp;

	int i;
	for( i = 0 ; i < 4 ; i++ ) {
		tmp.MeshHandle( hbooster[i] );
		tmp.MeshPosition(  OFF_BOOSTER[i] );
		AddMeshEx( tmp );
	}

	tmp.MeshHandle( hstage1);
	tmp.MeshPosition( OFF_STG1 );

    AddMeshEx(tmp);

	if (no_PAF) tmp.MeshHandle( hstage2alt);
	else tmp.MeshHandle( hstage2);
	tmp.MeshPosition( OFF_STG2 );

    AddMeshEx(tmp);

		tmp.MeshHandle( histg[0] );
		tmp.MeshPosition( OFF_ISTG[0] );
		AddMeshEx(tmp);

		tmp.MeshHandle( histg[1] );
		tmp.MeshPosition( OFF_ISTG[1] );
		AddMeshEx(tmp);

		tmp.MeshHandle( histg[2] );
		tmp.MeshPosition( OFF_ISTG[2] );
		AddMeshEx(tmp);

	if(( !manned_launch ) && (!no_PAF)) {
		tmp.MeshHandle( hring );
		tmp.MeshPosition( OFF_RING );
	    AddMeshEx(tmp);
	}
	
	if( fair_attached ) {
		tmp.MeshHandle( hfair1 );
		tmp.MeshPosition( OFF_LHF );

		AddMeshEx(tmp);

		tmp.MeshHandle( hfair2 );
		tmp.MeshPosition( OFF_RHF );

		AddMeshEx(tmp);

		if( manned_launch ) {

			tmp.MeshHandle( hescape );
			tmp.MeshPosition( OFF_ESCAPE );

			AddMeshEx(tmp);
		}
	}

	Draw(_V(0,0,0-comshift));

	AddThrusters();

	SetDefaultPropellantResource (ph_first); 

	for( i = 0 ; i < 4 ; i++ )
		th_main[i] = th_booster[i];
	th_main[4] = th_first;

	CreateThrusterGroup (th_main, 5, THGROUP_MAIN);

	SetThrusterGroupLevel( THGROUP_MAIN, lev );


}

void SOYUZ::SetMainStage ()
{

	double lev;
	lev = GetThrusterGroupLevel( THGROUP_MAIN );

	stage = 1;

	SetSize (50);
	SetEmptyMass ( MASS_STG1 + MASS_STG2 + CalculateMass() );
	//sprintf( oapiDebugString(), "%2.2f", CalculateMass());
	
	ShiftCentreOfMass (_V(0,0,-1.0*comshift));
	comshift = 8.0;
	ShiftCentreOfMass (_V(0,0,comshift));


	SetTouchdownPoints (_V(0,-2,10),_V(2,-2,-10),_V(-2,-2,-10));
	SetPMI (_V(75,75,5));
	SetCrossSections (_V(105,105,20));
	SetCW (0.1, 0.3, 1.4, 1.4);
	SetRotDrag (_V(0.7,0.7,1.2));
	SetPitchMomentScale (1e-6);
	SetBankMomentScale (1e-6);
	SetLiftCoeffFunc (0); 

	ClearMeshesEx();	
	
	COMMON_MESH tmp;

	int i;

	tmp.MeshHandle( hstage1);
	tmp.MeshPosition( OFF_STG1 );

    AddMeshEx(tmp);

	if (no_PAF) tmp.MeshHandle( hstage2alt);
	else tmp.MeshHandle( hstage2);
	tmp.MeshPosition( OFF_STG2 );

    AddMeshEx(tmp);

		tmp.MeshHandle( histg[0] );
		tmp.MeshPosition( OFF_ISTG[0] );
	    AddMeshEx(tmp);

		tmp.MeshHandle( histg[1] );
		tmp.MeshPosition( OFF_ISTG[1] );
	    AddMeshEx(tmp);

		tmp.MeshHandle( histg[2] );
		tmp.MeshPosition( OFF_ISTG[2] );
	    AddMeshEx(tmp);
	
	if(( !manned_launch ) && (!no_PAF)) {
		tmp.MeshHandle( hring );
		tmp.MeshPosition( OFF_RING );
	    AddMeshEx(tmp);
	}

	if( fair_attached ) {
		tmp.MeshHandle( hfair1 );
		tmp.MeshPosition( OFF_LHF );

		AddMeshEx(tmp);

		tmp.MeshHandle( hfair2 );
		tmp.MeshPosition( OFF_RHF );

		AddMeshEx(tmp);
		if( manned_launch ) {

			tmp.MeshHandle( hescape );
			tmp.MeshPosition( OFF_ESCAPE );

			AddMeshEx(tmp);
		}
	}

	Draw(_V(0,0,0-comshift));

	AddThrusters();

	for( i = 0 ; i < 4 ; i++ ) {
		if (ph_booster[i]!=NULL) 
			DelPropellantResource (ph_booster[i]);
	}

	SetDefaultPropellantResource (ph_first); 

	th_main[0] = th_first;

	CreateThrusterGroup (th_main, 1, THGROUP_MAIN);

	SetThrusterGroupLevel( THGROUP_MAIN, lev );
}

void SOYUZ::SetSecondStage() {

	double lev;
	lev = GetThrusterGroupLevel( THGROUP_MAIN );

	stage = 2;

	SetSize (20);
	SetEmptyMass ( MASS_STG2 + CalculateMass() );
	//sprintf( oapiDebugString(), "%2.2f", CalculateMass());
	
	ShiftCentreOfMass (_V(0,0,-1.0*comshift));
	comshift = 18.0;
	ShiftCentreOfMass (_V(0,0,comshift));


	SetTouchdownPoints (_V(0,-2,10),_V(2,-2,-10),_V(-2,-2,-10));

	SetPMI (_V(23.75,23.75,2.25));
	SetCrossSections (_V(7.5,7.5,5));
	SetCW (0.1, 0.3, 1.4, 1.4);
	SetRotDrag (_V(0.7,0.7,1.2));
	SetPitchMomentScale (1e-6);
	SetBankMomentScale (1e-6);
	SetLiftCoeffFunc (0); 

	ClearMeshesEx();	
	
	COMMON_MESH tmp;

	if (no_PAF) tmp.MeshHandle( hstage2alt);
	else tmp.MeshHandle( hstage2);
	tmp.MeshPosition( OFF_STG2 );

    AddMeshEx(tmp);

		tmp.MeshHandle( histg[0] );
		tmp.MeshPosition( OFF_ISTG[0] );
	    AddMeshEx(tmp);

		tmp.MeshHandle( histg[1] );
		tmp.MeshPosition( OFF_ISTG[1] );
	    AddMeshEx(tmp);

		tmp.MeshHandle( histg[2] );
		tmp.MeshPosition( OFF_ISTG[2] );
	    AddMeshEx(tmp);

	if(( !manned_launch ) && (!no_PAF)) {
		tmp.MeshHandle( hring );
		tmp.MeshPosition( OFF_RING );
	    AddMeshEx(tmp);
	}


	if( fair_attached ) {
		tmp.MeshHandle( hfair1 );
		tmp.MeshPosition( OFF_LHF );

		AddMeshEx(tmp);

		tmp.MeshHandle( hfair2 );
		tmp.MeshPosition( OFF_RHF );

		AddMeshEx(tmp);
		if( manned_launch ) {

			tmp.MeshHandle( hescape );
			tmp.MeshPosition( OFF_ESCAPE );

			AddMeshEx(tmp);
		}
	}

	Draw(_V(0,0,0-comshift));

	AddThrusters();

	if (ph_first!=NULL) 
		DelPropellantResource (ph_first	);

	SetDefaultPropellantResource (ph_second); 

	th_main[0] = th_second;
	th_main[1] = th_vern[0];
	th_main[2] = th_vern[1];
	th_main[3] = th_vern[2];
	th_main[4] = th_vern[3];

	CreateThrusterGroup (th_main, 5, THGROUP_MAIN);

	SetThrusterGroupLevel( THGROUP_MAIN, lev );


}
void SOYUZ::AddThrusters() {

	int i;

	PARTICLESTREAMSPEC exhaust_main = {
		0, 1.5, 1000.0, 100.0, 0.01, 0.5, 5, 0.1, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.5,
		PARTICLESTREAMSPEC::ATM_PLOG, 0.0, 0.0
	};

	exhaust_main.tex = oapiRegisterParticleTexture ("Contrail2");

	PARTICLESTREAMSPEC exhaust_second = {
		0, 1.0, 1000.0, 50, 0.1, 0.2 , 5, 0.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.5,
		PARTICLESTREAMSPEC::ATM_PLOG, 0.0, 0.0
	};
	exhaust_second.tex = oapiRegisterParticleTexture ("Contrail2");

	PARTICLESTREAMSPEC rcs_exhaust = {
		0, 0.01, 1000, 2, 0, 0.05, 1, 0.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.5,
		PARTICLESTREAMSPEC::ATM_PLOG, 0.0, 0.0
	};
	rcs_exhaust.tex = oapiRegisterParticleTexture ("Contrail");
	PARTICLESTREAMSPEC oms_exhaust = {
		0, 0.1, 1000, 10, 0, 0.1, 1, 0.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.5,
		PARTICLESTREAMSPEC::ATM_PLOG, 0.0, 0.0
	};
	oms_exhaust.tex = oapiRegisterParticleTexture ("Contrail2");

	ClearExhaustRefs();
	ClearAttExhaustRefs();
  	ClearThrusterDefinitions();


	if (ph_second==NULL)  
		ph_second  = CreatePropellantResource (FUEL_STG2); 
	
	switch( stage ) {
	case(0):
		for( i = 0 ; i < 4 ; i++ ) {
			if (ph_booster[i]==NULL)   {
				ph_booster[i] = CreatePropellantResource (FUEL_STG0); 
			}
		}
		
		if (ph_first==NULL)  
			ph_first  = CreatePropellantResource (FUEL_STG1); 
		
		th_booster[0] = CreateThruster (_V(3.2, 0.0, -10.5-comshift), _V(0,0,1),  952174.0, ph_booster[0], 2815.0, 0.0);
		th_booster[1] = CreateThruster (_V(-3.2, 0.0, -10.5-comshift), _V(0,0,1), 952174.0, ph_booster[1], 2815.0, 0.0);
		th_booster[2] = CreateThruster (_V(0, 3.2, -10.5-comshift), _V(0,0,1), 952174.0, ph_booster[2], 2815.0, 0.0);
		th_booster[3] = CreateThruster (_V(0, -3.2, -10.5-comshift), _V(0,0,1), 952174.0, ph_booster[3], 2815.0, 0.0);
        th_booster[4] = CreateThruster (_V(0, -1.6, -10.5-comshift), _V(0,0,1), 952174.0, ph_booster[3], 2815.0, 0.0);
        th_booster[5] = CreateThruster (_V(0, 1.6, -10.5-comshift), _V(0,0,1), 952174.0, ph_booster[3], 2815.0, 0.0);
		AddExhaustStream (th_booster[0], &exhaust_main);
		AddExhaustStream (th_booster[1], &exhaust_main);
		AddExhaustStream (th_booster[2], &exhaust_main);
		AddExhaustStream (th_booster[3], &exhaust_main);
		AddExhaustStream (th_booster[4], &exhaust_main);
		AddExhaustStream (th_booster[5], &exhaust_main);
		

	case(1):		

		if (ph_first==NULL)  
			ph_first  = CreatePropellantResource (FUEL_STG1); 
		
		th_first = CreateThruster (_V(0.0, 0.0, -11-comshift), _V(0,0,1), 1000000.0, ph_first, 2903.0, 0.0);

//		exhaust_main.v0 = 0.0; //50.0/0.8;
		AddExhaustStream (th_first, &exhaust_main);
//		AddExhaustStream (th_first, &exhaust_main2);
//		AddExhaust( th_first, 3.0, 0.5 );

		th_rleft[0] = CreateThruster (_V(-2.0, 0.0, -14.5-comshift), _V(0,-1,0), 50000.0, ph_first, 2903.0, 0.0);
		th_rleft[1] = CreateThruster (_V(2.0, 0.0, -14.5-comshift), _V(0,1,0), 50000.0, ph_first, 2903.0, 0.0);

		th_rright[0] = CreateThruster (_V(-2.0, 0.0, -14.5-comshift), _V(0,1,0), 50000.0, ph_first, 2903.0, 0.0);
		th_rright[1] = CreateThruster (_V(2.0, 0.0, -14.5-comshift), _V(0,-1,0), 50000.0, ph_first, 2903.0, 0.0);

		th_pup = CreateThruster (_V(0.0, 0.0, -14.5-comshift), _V(0,-1,0), 50000.0, ph_first, 2903.0, 0.0);
		th_pdown = CreateThruster (_V(0.0, 0.0, -14.5-comshift), _V(0,1,0), 50000.0, ph_first, 2903.0, 0.0);
		th_yleft = CreateThruster (_V(0.0, 0.0, -14.5-comshift), _V(1,0,0), 50000.0, ph_first, 2903.0, 0.0);
		th_yright = CreateThruster (_V(0.0, 0.0, -14.5-comshift), _V(-1,0,0), 50000.0, ph_first, 2903.0, 0.0);

		CreateThrusterGroup( &th_pup, 1, THGROUP_ATT_PITCHUP );
		CreateThrusterGroup( &th_pdown, 1, THGROUP_ATT_PITCHDOWN );
		CreateThrusterGroup( &th_yleft, 1, THGROUP_ATT_YAWLEFT );
		CreateThrusterGroup( &th_yright, 1, THGROUP_ATT_YAWRIGHT );

		CreateThrusterGroup( th_rleft, 2, THGROUP_ATT_BANKLEFT );
		CreateThrusterGroup( th_rright, 2, THGROUP_ATT_BANKRIGHT );

		break;
	
	default:

		th_second = CreateThruster (_V(0.0, 0.0, 17.5-comshift), _V(0,0,1), 290300.0, ph_second, 3865.0, 0.0);
		AddExhaustStream (th_second, &exhaust_second);
//		AddExhaustStream (th_second, &oms_exhaust);

		VECTOR3 dir;
		dir = _V(0,-1,2); normalise(&dir);
		th_vern[0] = CreateThruster( _V(0, 1, 18-comshift), dir, 1000, ph_second, 3865.0, 0.0);
		dir = _V(-1,0,2); normalise(&dir);
		th_vern[1] = CreateThruster( _V(1, 0, 18-comshift), dir, 1000, ph_second, 3865.0, 0.0);
		dir = _V(0,1,2); normalise(&dir);
		th_vern[2] = CreateThruster( _V(0, -1, 18-comshift), dir, 1000, ph_second, 3865.0, 0.0);
		dir = _V(1,0,2); normalise(&dir);
		th_vern[3] = CreateThruster( _V(-1, 0, 18-comshift), dir, 1000, ph_second, 3865.0, 0.0);
		AddExhaustStream (th_vern[0], &oms_exhaust);
		AddExhaustStream (th_vern[1], &oms_exhaust);
		AddExhaustStream (th_vern[2], &oms_exhaust);
		AddExhaustStream (th_vern[3], &oms_exhaust);
		
		th_pup = CreateThruster (_V(0.0, 0.0, -5.0-comshift), _V(0,-1,0), 1000.0, ph_second, 2903.0, 0.0);
		th_pdown = CreateThruster (_V(0.0, 0.0, -5.0-comshift), _V(0,1,0), 1000.0, ph_second, 2903.0, 0.0);
		th_yleft = CreateThruster (_V(0.0, 0.0, -5.0-comshift), _V(1,0,0), 1000.0, ph_second, 2903.0, 0.0);
		th_yright = CreateThruster (_V(0.0, 0.0, -5.0-comshift), _V(-1,0,0), 1000.0, ph_second, 2903.0, 0.0);

		th_rleft[0] = CreateThruster (_V(-2.0, 0.0, -5.0-comshift), _V(0,-1,0), 1000.0, ph_second, 2903.0, 0.0);
		th_rleft[1] = CreateThruster (_V(2.0, 0.0, -5.0-comshift), _V(0,1,0), 1000.0, ph_second, 2903.0, 0.0);

		th_rright[0] = CreateThruster (_V(-2.0, 0.0, -5.0-comshift), _V(0,1,0), 1000.0, ph_second, 2903.0, 0.0);
		th_rright[1] = CreateThruster (_V(2.0, 0.0, -5.0-comshift), _V(0,-1,0), 1000.0, ph_second, 2903.0, 0.0);

		CreateThrusterGroup( &th_pup, 1, THGROUP_ATT_PITCHUP );
		CreateThrusterGroup( &th_pdown, 1, THGROUP_ATT_PITCHDOWN );
		CreateThrusterGroup( &th_yleft, 1, THGROUP_ATT_YAWLEFT );
		CreateThrusterGroup( &th_yright, 1, THGROUP_ATT_YAWRIGHT );

		CreateThrusterGroup( th_rleft, 2, THGROUP_ATT_BANKLEFT );
		CreateThrusterGroup( th_rright, 2, THGROUP_ATT_BANKRIGHT );

			
	}

}

void SOYUZ::JettisonBoosters()
{
	VESSELSTATUS vs[4];
	VECTOR3 rvel, tmp;

	int i;
	for( i = 0 ; i < 4 ; i++ ) {
		GetStatus (vs[i]);
		vs[i].eng_main = vs[i].eng_hovr = 0.0;
		Local2Rel (OFF_BOOSTER[i]-_V(0.0,0.0,comshift), vs[i].rpos);

		tmp = OFF_BOOSTER[i];
		tmp.z = 0.0;
		rvel.x = 10.5 * tmp.x / mod(tmp);
		rvel.y = 10.5 * tmp.y / mod(tmp);
		rvel.z = 0.0;
		GlobalRot( rvel, tmp );
		vs[i].rvel += tmp;
	}

	vs[0].vrot.y += -0.25;
   	vs[1].vrot.x += 0.18;
	vs[2].vrot.y += 0.21;		
	vs[3].vrot.x += -0.12;
    vs[4].vrot.x += 0.12;
	vs[5].vrot.x += -0.32;


	oapiCreateVessel("Strap-on Booster B", "r7blockb", vs[0]);
	oapiCreateVessel("Strap-on Booster W", "r7blockw", vs[1]);
	oapiCreateVessel("Strap-on Booster D", "r7blockd", vs[2]);
	oapiCreateVessel("Strap-on Booster G", "r7blockg", vs[3]);
	oapiCreateVessel("Strap-on Booster X", "r7blockx", vs[4]);
	oapiCreateVessel("Strap-on Booster Y", "r7blocky", vs[5]);

	

}
void SOYUZ::JettisonStg1()
{
	VESSELSTATUS vs;

	GetStatus (vs);
	vs.eng_main = vs.eng_hovr = 0.0;

	Local2Rel(OFF_STG1-_V(0.0,0.0,comshift), vs.rpos);
   
	oapiCreateVessel  ("soyuz-stg1", "r7blocka", vs);

}
void SOYUZ::JettisonFairing()
{
	VESSELSTATUS vs;

	VECTOR3 lvel;
	VECTOR3 rvel;
	VECTOR3 rot;


	PARTICLESTREAMSPEC escape_exhaust = {
		0, 1.5, 1000.0, 100.0, 0.01, 0.5, 5, 0.1, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 0.5,
		PARTICLESTREAMSPEC::ATM_PLOG, 0.0, 0.0
	};

	escape_exhaust.tex = oapiRegisterParticleTexture ("Contrail");
	
	
	if( !fair_attached )
		return;
	
	if( manned_launch ) {
		lvel = _V( 0, 10, 0 );
		rot = _V(  0.5, 0, 0 );
	}
	else {
		lvel = _V( -10, 0, 0 );
		rot = _V( 0, 0.5, 0 );
	}

	GlobalRot( lvel, rvel );

	GetStatus (vs);
	vs.eng_main = vs.eng_hovr = 0.0;
	vs.rvel.x += rvel.x;
	vs.rvel.y += rvel.y;
	vs.rvel.z += rvel.z;

	vs.vrot = rot;

	Local2Rel(OFF_LHF-_V(0.0,0.0,comshift), vs.rpos);
   
	if( manned_launch ) {
		oapiCreateVessel("SoyuzLShroud", "soyshrd1", vs);
	}
	else{
		oapiCreateVessel("SoyuzLShroud", "soyufair1", vs);
	}



	lvel.x *= -1;
	lvel.y *= -1;
	rot.x *= -1;
	rot.y *= -1;

	GlobalRot( lvel, rvel );

	GetStatus (vs);
	vs.eng_main = vs.eng_hovr = 0.0;
	vs.rvel.x += rvel.x;
	vs.rvel.y += rvel.y;
	vs.rvel.z += rvel.z;

	vs.vrot = rot;

	Local2Rel(OFF_RHF-_V(0.0,0.0,comshift), vs.rpos);
   
	if( manned_launch ) {
		oapiCreateVessel("SoyuzRShroud", "soyshrd2", vs);
	}
	else{
		oapiCreateVessel("SoyuzRShroud", "soyufair2", vs);
	}

	
	if( manned_launch ) {
		lvel = _V( 0, 0, 2.0 );
		rot = _V(  0, -0.1, 0 );

		GlobalRot( lvel, rvel );

		GetStatus (vs);
		vs.eng_main = vs.eng_hovr = 0.0;
		vs.rvel.x += rvel.x;
		vs.rvel.y += rvel.y;
		vs.rvel.z += rvel.z;

		vs.vrot = rot;

		Local2Rel(OFF_ESCAPE-_V(0.0,0.0,comshift), vs.rpos);
   
		OBJHANDLE htower;
		VESSEL *v;
		PROPELLANT_HANDLE ph_escape;
		THRUSTER_HANDLE th_escape;
		htower = oapiCreateVessel("SoyuzEscapeTower", "r7tmaer", vs);

		if( htower ) {
			v = oapiGetVesselInterface(htower);

			ph_escape = v->CreatePropellantResource( 1200 );
			th_escape = v->CreateThruster( _V( 0,0,-1 ), _V(0,0,1), 1e6, ph_escape, 2500, 0, 0 );
			v->AddExhaustStream( th_escape, &escape_exhaust );
			v->SetThrusterLevel( th_escape, 1.0 );

		}

	}




	fair_attached = false;

	Refresh();
	
}
void SOYUZ::Refresh() {

	if( manned_launch ) {
		hfair1 = hfairl;
		hfair2 = hfairr;
		OFF_LHF = _V(0,  0.8, 31.2);
		OFF_RHF = _V(0, -0.8, 31.2);
	}
	else {
		hfair1 = hfairf;
		hfair2 = hfairb;
		OFF_LHF = _V(0.0,  0, 27);
		OFF_RHF = _V(0.0,  0, 27);
	}

	switch( stage ) {
	case( 0 ):
		SetBoostStage();
		break;
	case( 1 ):
		SetMainStage();
		break;
	default:
		SetSecondStage();
		break;
	}

}
void SOYUZ::VisualCreated( VESSEL *vessel, VISHANDLE vis, int refcount ) {
	Refresh();
}

void SOYUZ::normalise( VECTOR3 *v ) {

	v->x /= mod(*v);
	v->y /= mod(*v);
	v->z /= mod(*v);
}
 

Graham2001

Well-known member
Joined
Mar 20, 2008
Messages
1,523
Reaction score
73
Points
48
Has anyone managed to compile this?

And if you have, can you please attach a picture showing where the boosters appear. Being unable to compile files of your own creation is a real hold up.
 
Top