- Joined
- Jun 26, 2009
- Messages
- 1,045
- Reaction score
- 0
- Points
- 36
Hi all,
I have a request for any C++ coders here:
I have this Soyuz TMA addon:
[ame="http://www.orbithangar.com/searchid.php?ID=3784"]Soyuz TMA spacecraft[/ame]
but the descent module has no RCS thrusters. Could anyone please add an RCS to the descent module (another state of the main TMA, so you need to edit the code for that)? The source code is included in the download, so no need to decompile.
I have asked for this in other threads, and have received 'download this instead' or 'this is just old - why do you want ot do it'. If you can do it, I would be very pleased.
Here is the source code:
This would be massively appreciated.
I have a request for any C++ coders here:
I have this Soyuz TMA addon:
[ame="http://www.orbithangar.com/searchid.php?ID=3784"]Soyuz TMA spacecraft[/ame]
but the descent module has no RCS thrusters. Could anyone please add an RCS to the descent module (another state of the main TMA, so you need to edit the code for that)? The source code is included in the download, so no need to decompile.
I have asked for this in other threads, and have received 'download this instead' or 'this is just old - why do you want ot do it'. If you can do it, I would be very pleased.
Here is the source code:
Code:
// ==============================================================
// $Id: soyuztma.cpp,v 1.11 2006/03/18 21:06:20 dh219 Exp $
// Soyuz TMA 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
*/
// ==============================================================
#include "soyuztma.h"
PARTICLESTREAMSPEC rcs_exhaust = {
0, 0.05, 3000, 5, 0.1, 0.1, 1, 0.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_PLIN, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 0.0, 0.0
};
PARTICLESTREAMSPEC oms_exhaust = {
0, 0.4, 3000, 150, 0.05, 0.5, 5, 0.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_PLIN, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 0.0, 0.0
};
PARTICLESTREAMSPEC oms_exhaust2 = {
0, 0.4, 3000, 50, 0.05, 0.1, 5.0/3.0, 0.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_PLIN, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 0.0, 0.0
};
TMA::TMA (OBJHANDLE hObj, int fmodel)
: COMMON_VESSEL_EX (hObj)
{
ph_first = NULL;
ph_second = NULL;
ph_srm = NULL;
htma = oapiLoadMesh("soyuz");
hentry = oapiLoadMesh("soyuz-descent");
hpara = oapiLoadMesh("soychute");
hdrogue = oapiLoadMesh("soydrogue");
VZERO = _V(0,0,0);
status = 0;
targetstatus = 0;
comshift = _V(0,0,0);
// anim1 = CreateAnimation (0.5);
// anim2 = CreateAnimation (0.5);
anim3 = CreateAnimation(0);
animcomp1 = NULL;
animcomp2 = NULL;
int i;
for( i = 0 ; i < 20 ; i++ ) {
animcomp3[i] = NULL;
}
xproc = 0.0;
chute = NULL;
reenteractive = false;
reentercoasting = false;
target = 6445000.0;
animstate = 0;
animlevel = 0.0;
refresh = 0;
animactive = 0;
dh=NULL;
}
void TMA::TimeStep( double simt )
{
/* CVE-lite function ! */
/* IMPORTANT */
/* This function loops through the pending GPDS requests and returns a bool (true/false)
/* if any GPDS requests have been implemented.
/* If any have (eg adding a new payload), you will need to re-draw your ship, hence the
/* call to the (repeatable) SetMainStage(); */
if( CheckCentralMessage() ) {
while( CheckCentralMessage() ) ;
// SetMainStage();
}
if( animactive ) {
if( animactive == 1 ) {
animlevel += oapiGetSimStep() / 10.0;
if( animlevel > 1.0 ) {
animlevel = 1.0;
animactive = 0;
}
}
else {
animlevel -= oapiGetSimStep() / 10.0;
if( animlevel < 0.0 ) {
animlevel = 0.0;
animactive = 0;
}
}
SetAnimation( anim3, animlevel );
}
if( refresh > 0 ) {
refresh++;
if( refresh == 2 )
SetAnimation( anim3, 0.0 );
if( refresh == 3 )
if( status == 0 )
SetMainStage();
else if( status == 1 )
SetEntryStage();
else if( status == 2 )
SetDrogueStage();
else if( status == 3 )
SetParaStage();
else if( status == 4 )
SetEntryStage();
if( refresh == 4 ) {
SetAnimation( anim3, animlevel );
refresh = 0;
}
}
if( status == 2 || status == 3 ) {
if( oapiGetTimeAcceleration() > 10.0 ) {
oapiSetTimeAcceleration(10.0);
}
CalcParaAngles();
if( status == 3 && GetAltitude() < 2.0 && th_srm != NULL ) {
chute = JettisonComponent("SoyuzChute", "soychute", (VZERO-comshift)+_V(0,0,72) , _V(0,0,0), _V(0,0,0));
status = 4;
refresh = 1;
}
else if( status == 2 && ( ( GetAltitude() < 2000.0 && GetAirspeed() < 80.0 ) || GetAltitude() < 600.0 ) ) {
status = 3;
refresh = 1;
}
}
else if( status == 1 ) {
if( GetAltitude() < 12000 && GetAirspeed() < 300 ) {
status = 2;
refresh = 1;
return;
}
}
if( status == 4 && chute ) {
if( chute->GroundContact() ){
oapiDeleteVessel(chute->GetHandle());
chute = NULL;
}
}
}
void TMA::VisualCreated ( VESSEL *vessel, VISHANDLE vis, int refcount) {
SetMainStage(); // this is a good place to ask for the initial setup.
refresh = 1;
}
void TMA::SetClassCaps( FILEHANDLE cfg )
{
}
void TMA::SaveState( FILEHANDLE scn )
{
SaveDefaultState (scn);
oapiWriteScenario_int (scn, "CONFIGURATION", status );
oapiWriteScenario_float( scn, "PANELS", animlevel );
SaveDefaultStateEx(scn);
}
void TMA::LoadState( FILEHANDLE scn, void *vs )
{
char *line;
while (oapiReadScenario_nextline (scn, line))
{
if( !strnicmp( line, "CONFIGURATION", 13 ) ) {
status = atoi( line+13 );
}
else if( !strnicmp( line, "PANELS", 6 ) ) {
animlevel = atof( line+6 );
}
/* CVE-lite function ! */
/* IMPORTANT */
/* Call this for every line in the scenario file. It will automatically
/* deduce which lines are for it, and load the payloads from the file. */
/* load payload lines */
ParsePayloadString(line);
ParseScenarioLineEx (line, vs);
}
/* always set the stage whenever something may have changed */
SetMainStage();
refresh = 1;
}
/* IMPORTANT */
/* Always have a function that you can call as many times as you like that will re-draw
/* all you meshes, reset all your thrusters and check to make sure the propellent is
/* there. This should be called after any configuration change, or any GDPS line (see
/* TimeStep(), above) */
void TMA::SetMainStage( )
{
SetAnimation( anim3, 0.0 );
VECTOR3 VECTOR_ZERO = _V(0,0,0);
/* CVE-lite function ! */
/* ClearMeshesEx() will get rid of all the normal meshes, plus anything you've defined
/* with the COMMON_MESH class (not used here) */
/* erase all meshes and thrusters so we can start afresh */
ClearMeshesEx();
SetSize (15);
/* CVE-lite function ! */
/* IMPORTANT */
/* double CalculateMass() will return the all-up mass of the combined payloads and
/* upper stages. Simply add this to your normal dry mass. */
/* always add payload mass [CalculateMass()] to the vessel's empty mass */
SetEmptyMass ( MASS + CalculateMass() );
ShiftCentreOfMass(VZERO-comshift);
comshift = _V(0,0,0);
ShiftCentreOfMass(comshift);
SetTouchdownPoints (_V(0,-2,4)-comshift,_V(2,-2,-4)-comshift,_V(-2,-2,-4)-comshift);
SetPMI (_V(5,5,0.85));
SetCrossSections (_V(15,32,6));
SetCW (1.1, 2.2, 3.5, 3.5);
SetRotDrag (_V(0.1,0.1,0.01));
SetPitchMomentScale (-3e-6);
SetBankMomentScale (3e-6);
SetLiftCoeffFunc(0);
SetSurfaceFrictionCoeff (0.05, 0.5);
SetCameraOffset( _V( 0.0, -1.50, 1.5)-comshift );
VECTOR_ZERO = (comshift*-1.0);
/* we're not using COMMON_MESH today, so draw our own */
UINT mshid = AddMesh("soyuz", &VECTOR_ZERO );
SetMeshVisibilityMode( mshid, MESHVIS_ALWAYS );
Animations(mshid);
MeshVisibilityPreference(MESHVIS_ALWAYS);
/* CVE-lite function ! */
/* IMPORTANT */
/* Draw() should be called to render all the loaded payloads, plus anything you've
/* added with the COMMON_MESH class (not used here) */
/* call draw to render the payloads, plus anything you've added from COMMON_MESH */
Draw(comshift*-1.0);
/* CVE-lite variable ! */
/* IMPORTANT */
/* Use the keyword double InitFuelLevel multipled by the maximum mass to have the
/* fuel levels automatically set from the GPDS payload string */
/* verify that the propellent hasn't been created before making it */
if( ph_first == NULL ) {
ph_first = CreatePropellantResource(FUEL);
}
if( !dh )
dh = CreateDock(_V(0,0,4.615),_V(0,0,1),_V(0,1,0));
SetDefaultPropellantResource (ph_first);
AddThrusters();
EnableTransponder(true);
}
void TMA::SetEntryStage() {
ShiftCentreOfMass(VZERO-comshift);
comshift = _V(0,-0.1,-0.5);
ShiftCentreOfMass(comshift);
SetCameraOffset( _V( 0.0, -1.65, -0.1)-comshift );
int i;
for( i = 0 ; i < 20 ; i++ ) {
if( animcomp3[i] != NULL ) {
DelAnimationComponent(anim3, animcomp3[i] );
animcomp3[i] = NULL;
}
}
/*
if( animcomp1 != NULL )
DelAnimationComponent(anim1, animcomp1 );
if( animcomp2 != NULL )
DelAnimationComponent(anim2, animcomp2 );
*/
ClearExhaustRefs();
ClearAttExhaustRefs();
ClearThrusterDefinitions();
ClearMeshesEx();
SetSize (5);
SetEmptyMass ( MASSENTRY + CalculateMass() );
SetTouchdownPoints (_V(-1,-1,-1.5)-comshift,_V(0,1,-1.5)-comshift,_V(1,-1,-1.5)-comshift);
SetPMI (_V(2,2,0.55));
SetCrossSections (_V(5,5,5));
SetCW (1.1, 2.2, 2.5, 2.5);
SetRotDrag (_V(0.05,0.05,0.05));
SetPitchMomentScale (-1e-6);
SetBankMomentScale (-1e-6);
SetLiftCoeffFunc(0);
if( ph_first ) {
DelPropellantResource(ph_first);
ph_first = NULL;
}
if( ph_second && GetPropellantMass(ph_second) > 40.0 )
SetPropellantMass(ph_second, 40.0);
if( status == 4 ) {
if( ph_srm == NULL ) {
ph_srm = CreatePropellantResource(FUELSRM);
}
th_srm = CreateThruster (_V(0, 0, -1), _V(0,0,1), 60000.0, ph_srm, 200.0, 0.0);
AddExhaustStream(th_srm, _V(0,1,-0.7), &oms_exhaust);
AddExhaustStream(th_srm, _V(-0.7,-0.7,-0.7), &oms_exhaust);
AddExhaustStream(th_srm, _V(0.7,-0.7,-0.7), &oms_exhaust);
SetThrusterLevel(th_srm,1.0);
}
VECTOR3 off;
UINT msh;
off = (VZERO-comshift);
msh = AddMesh(hentry,&off);
SetMeshVisibilityMode(msh,MESHVIS_ALWAYS);
Draw(VZERO-comshift);
th_yleft[0] = CreateThruster (_V(0, 0, 1)-comshift, _V(-1,0,0), 50.0, ph_second, 2903.0, 0.0);
th_yright[0] = CreateThruster (_V(0, 0, 1)-comshift, _V(1,0,0), 50.0, ph_second, 2903.0, 0.0);
th_pup[0] = CreateThruster (_V(0, 0, 1)-comshift, _V(0,1,0), 50.0, ph_second, 2903.0, 0.0);
th_pdown[0] = CreateThruster (_V(0, 0, 1)-comshift, _V(0,-1,0), 50.0, ph_second, 2903.0, 0.0);
th_rleft[0] = CreateThruster (_V(0, 1, 1)-comshift, _V(-1,0,0), 50.0, ph_second, 2903.0, 0.0);
th_rright[0] = CreateThruster (_V(0, 1, 1)-comshift, _V(1,0,0), 50.0, ph_second, 2903.0, 0.0);
CreateThrusterGroup( th_yleft, 1, THGROUP_ATT_YAWLEFT );
CreateThrusterGroup( th_yright, 1, THGROUP_ATT_YAWRIGHT );
CreateThrusterGroup( th_pup, 1, THGROUP_ATT_PITCHUP );
CreateThrusterGroup( th_pdown, 1, THGROUP_ATT_PITCHDOWN );
CreateThrusterGroup( th_rleft, 1, THGROUP_ATT_BANKLEFT );
CreateThrusterGroup( th_rright, 1, THGROUP_ATT_BANKRIGHT );
}
/** Handle buffered key events sent to the vessel by orbiter.
* @param dwKey The scan code of the key
* @param fPressed true if pressed, false if depressed
* @param keystate the current state of the keyboard
*
* modified switch routine by dave rowbotham.
*/
int TMA::ConsumeBufferedKey(DWORD dwKey, bool fPressed, const char *keystate)
{
VESSELSTATUS vs;
GetStatus(vs);
if (KEYMOD_SHIFT (keystate)) {
// reserved for MFDs
}
else if (KEYMOD_CONTROL (keystate))
{
if (KEYDOWN (keystate, OAPI_KEY_J) && KEYMOD_CONTROL(keystate) && !KEYMOD_SHIFT(keystate) )
{
if (oapiAcceptDelayedKey (OAPI_KEY_J, 1.0)) {
if( status == 0 ) {
BlowOrbiter();
}
else if( status < 4 ) {
status++;
refresh=1;
}
return 1;
}
}
}
else
{ // unmodified keys
if (KEYDOWN (keystate, OAPI_KEY_K)) { // "Jettison Stage"
if(oapiAcceptDelayedKey (OAPI_KEY_K, 0.5)) {
if( animlevel > 0.5 )
animactive = 2;
else
animactive = 1;
return 1;
}
}
if (KEYDOWN (keystate, OAPI_KEY_J) && !KEYMOD_CONTROL(keystate) && !KEYMOD_SHIFT(keystate) )
{
if (oapiAcceptDelayedKey (OAPI_KEY_J, 1.0)) {
DeployPayload();
refresh=1;
return 1;
}
}
}
return 0;
}
void TMA::AddThrusters()
{
th_first = CreateThruster (_V(0,0,-2.64)-comshift, _V(0,0,1), 3924.0, ph_first, 2992.0);
AddExhaustStream(th_first, &oms_exhaust);
AddExhaustStream(th_first, &oms_exhaust2);
th_pup[0] = CreateThruster (_V(-0.1, 1.38, -2.515)-comshift, _V(0,-1,0), 140.0, ph_first, 2903.0, 0.0);
th_pup[1] = CreateThruster (_V(0.1, 1.38, -2.515)-comshift, _V(0,-1,0), 140.0, ph_first, 2903.0, 0.0);
th_pup[2] = CreateThruster (_V(-1.12, -0.25, 0)-comshift, _V(0,1,0), 140.0, ph_first, 2903.0, 0.0);
th_pup[3] = CreateThruster (_V(1.12, -0.25, 0)-comshift, _V(0,1,0), 140.0, ph_first, 2903.0, 0.0);
AddExhaustStream(th_pup[0], &rcs_exhaust);
AddExhaustStream(th_pup[1], &rcs_exhaust);
AddExhaustStream(th_pup[2], &rcs_exhaust);
AddExhaustStream(th_pup[3], &rcs_exhaust);
th_pdown[0] = CreateThruster (_V(-0.1, -1.38, -2.515)-comshift, _V(0,1,0), 140.0, ph_first, 2903.0, 0.0);
th_pdown[1] = CreateThruster (_V(0.1, -1.38, -2.515)-comshift, _V(0,1,0), 140.0, ph_first, 2903.0, 0.0);
th_pdown[2] = CreateThruster (_V(-1.12, 0.25, 0)-comshift, _V(0,-1,0), 140.0, ph_first, 2903.0, 0.0);
th_pdown[3] = CreateThruster (_V(1.12, 0.25, 0)-comshift, _V(0,-1,0), 140.0, ph_first, 2903.0, 0.0);
AddExhaustStream(th_pdown[0], &rcs_exhaust);
AddExhaustStream(th_pdown[1], &rcs_exhaust);
AddExhaustStream(th_pdown[2], &rcs_exhaust);
AddExhaustStream(th_pdown[3], &rcs_exhaust);
th_rleft[0] = th_pup[3];
th_rleft[1] = th_pdown[2];
th_rright[0] = th_pup[2];
th_rright[1] = th_pdown[3];
th_yleft[0] = CreateThruster (_V(-1.38, -0.1, -2.515)-comshift, _V(1,0,0), 140.0, ph_first, 2903.0, 0.0);
th_yleft[1] = CreateThruster (_V(-1.38, 0.1, -2.515)-comshift, _V(1,0,0), 140.0, ph_first, 2903.0, 0.0);
th_yleft[2] = CreateThruster (_V(1.2, -0.1, 0)-comshift, _V(-1,0,0), 140.0, ph_first, 2903.0, 0.0);
th_yleft[3] = CreateThruster (_V(1.2, 0.1, 0)-comshift, _V(-1,0,0), 140.0, ph_first, 2903.0, 0.0);
AddExhaustStream(th_yleft[0], &rcs_exhaust);
AddExhaustStream(th_yleft[1], &rcs_exhaust);
AddExhaustStream(th_yleft[2], &rcs_exhaust);
AddExhaustStream(th_yleft[3], &rcs_exhaust);
th_yright[0] = CreateThruster (_V(1.38, -0.1, -2.515)-comshift, _V(-1,0,0), 140.0, ph_first, 2903.0, 0.0);
th_yright[1] = CreateThruster (_V(1.38, 0.1, -2.515)-comshift, _V(-1,0,0), 140.0, ph_first, 2903.0, 0.0);
th_yright[2] = CreateThruster (_V(-1.2, -0.1, 0)-comshift, _V(1,0,0), 140.0, ph_first, 2903.0, 0.0);
th_yright[3] = CreateThruster (_V(-1.2, 0.1, 0)-comshift, _V(1,0,0), 140.0, ph_first, 2903.0, 0.0);
AddExhaustStream(th_yright[0], &rcs_exhaust);
AddExhaustStream(th_yright[1], &rcs_exhaust);
AddExhaustStream(th_yright[2], &rcs_exhaust);
AddExhaustStream(th_yright[3], &rcs_exhaust);
th_left[0] = th_yleft[2];
th_left[1] = th_yleft[3];
th_right[0] = th_yright[2];
th_right[1] = th_yright[3];
th_up[0] = th_pup[2];
th_up[1] = th_pup[3];
th_down[0] = th_pdown[2];
th_down[1] = th_pdown[3];
th_fore[0] = CreateThruster (_V(-1.1, 0, -2.64)-comshift, _V(0,0,1), 140.0, ph_first, 2903.0, 0.0);
th_fore[1] = CreateThruster (_V(1.1, 0, -2.64)-comshift, _V(0,0,1), 140.0, ph_first, 2903.0, 0.0);
th_fore[2] = CreateThruster (_V(0, 1.1, -2.64)-comshift, _V(0,0,1), 140.0, ph_first, 2903.0, 0.0);
th_fore[3] = CreateThruster (_V(0, -1.1, -2.64)-comshift, _V(0,0,1), 140.0, ph_first, 2903.0, 0.0);
AddExhaustStream(th_fore[0], &rcs_exhaust);
AddExhaustStream(th_fore[1], &rcs_exhaust);
AddExhaustStream(th_fore[2], &rcs_exhaust);
AddExhaustStream(th_fore[3], &rcs_exhaust);
th_aft[0] = CreateThruster (_V(-1.15, 0, 0.15)-comshift, _V(0.141,0,-0.99), 140.0, ph_first, 2903.0, 0.0);
th_aft[1] = CreateThruster (_V(1.15, 0, 0.15)-comshift, _V(-0.141,0,-0.99), 140.0, ph_first, 2903.0, 0.0);
AddExhaustStream(th_aft[0], &rcs_exhaust);
AddExhaustStream(th_aft[1], &rcs_exhaust);
CreateThrusterGroup( th_pup, 4, THGROUP_ATT_PITCHUP );
CreateThrusterGroup( th_pdown, 4, THGROUP_ATT_PITCHDOWN );
CreateThrusterGroup( th_yleft, 4, THGROUP_ATT_YAWLEFT );
CreateThrusterGroup( th_yright, 4, THGROUP_ATT_YAWRIGHT );
CreateThrusterGroup( th_rleft, 2, THGROUP_ATT_BANKLEFT );
CreateThrusterGroup( th_rright, 2, THGROUP_ATT_BANKRIGHT );
CreateThrusterGroup( th_left, 2, THGROUP_ATT_LEFT );
CreateThrusterGroup( th_right, 2, THGROUP_ATT_RIGHT );
CreateThrusterGroup( th_down, 2, THGROUP_ATT_DOWN );
CreateThrusterGroup( th_up, 2, THGROUP_ATT_UP );
CreateThrusterGroup( th_fore, 4, THGROUP_ATT_FORWARD );
CreateThrusterGroup( th_aft, 2, THGROUP_ATT_BACK );
CreateThrusterGroup( &th_first, 1, THGROUP_MAIN );
CreateThrusterGroup( th_aft, 2, THGROUP_RETRO );
}
void TMA::SetDrogueStage() {
int i;
for( i = 0 ; i < 20 ; i++ ) {
if( animcomp3[i] != NULL ) {
DelAnimationComponent(anim3, animcomp3[i] );
animcomp3[i] = NULL;
}
}
ShiftCentreOfMass(VZERO-comshift);
comshift = _V(0,-0.1,0);
ShiftCentreOfMass(comshift);
SetCameraOffset( _V( 0.0, -1.65, -0.1)-comshift );
ClearExhaustRefs();
ClearAttExhaustRefs();
ClearThrusterDefinitions();
ClearMeshesEx();
SetSize (80);
SetEmptyMass ( MASSENTRY + CalculateMass() );
SetTouchdownPoints (_V(-1,-1,-1.5)-comshift,_V(0,1,-1.5)-comshift,_V(1,-1,-1.5)-comshift);
SetPMI (_V(2,2,0.55));
SetCrossSections (_V(5,5,40));
SetCW (1.1, 2.2, 3.5, 3.5);
SetRotDrag (_V(0.05,0.05,0.05));
SetPitchMomentScale (-5e-4);
SetBankMomentScale (-5e-4);
SetLiftCoeffFunc(0);
if( ph_first ) {
DelPropellantResource(ph_first);
ph_first = NULL;
}
if( ph_second ) {
DelPropellantResource(ph_second);
ph_second = NULL;
}
if( ph_srm == NULL ) {
ph_srm = CreatePropellantResource(FUELSRM);
}
VECTOR3 off, off2;
UINT msh, msh2;
off = (VZERO-comshift);
msh = AddMesh(hentry,&off);
SetMeshVisibilityMode(msh,MESHVIS_ALWAYS);
off2 = (VZERO-comshift)+_V(0,0,72);
msh2 = AddMesh(hdrogue,&off2);
SetMeshVisibilityMode(msh2,MESHVIS_ALWAYS);
Draw(VZERO-comshift);
/*
if( animcomp1 != NULL )
DelAnimationComponent(anim1, animcomp1 );
if( animcomp2 != NULL )
DelAnimationComponent(anim2, animcomp2 );
*/
/* static UINT groups0[5] = { 0, 1, 2, 3, 4 };
animcomp1 = AddAnimationComponent( anim1, 0, 1,
new MGROUP_ROTATE (
msh2,
groups0, 5,
_V(0,0,1)-off2,
_V(1,0,0),
30*RAD
)
);
animcomp2 = AddAnimationComponent( anim2, 0, 1,
new MGROUP_ROTATE (
msh2,
groups0, 5,
_V(0,0,1)-off2,
_V(0,1,0),
30*RAD
)
);
*/
}
void TMA::SetParaStage() {
int i;
for( i = 0 ; i < 20 ; i++ ) {
if( animcomp3[i] != NULL ) {
DelAnimationComponent(anim3, animcomp3[i] );
animcomp3[i] = NULL;
}
}
/* if( animcomp1 != NULL )
DelAnimationComponent(anim1, animcomp1 );
if( animcomp2 != NULL )
DelAnimationComponent(anim2, animcomp2 );
*/
ShiftCentreOfMass(VZERO-comshift);
// comshift = _V(0,-0.18,-1.265);
comshift = _V(0,-0.1,0);
ShiftCentreOfMass(comshift);
SetCameraOffset( _V( 0.0, -1.65, -0.1)-comshift );
ClearExhaustRefs();
ClearAttExhaustRefs();
ClearThrusterDefinitions();
ClearMeshesEx();
SetSize (80);
SetEmptyMass ( MASSENTRY + CalculateMass() );
SetTouchdownPoints (_V(-1,-1,-1.5)-comshift,_V(0,1,-1.5)-comshift,_V(1,-1,-1.5)-comshift);
SetPMI (_V(2,2,0.55));
SetCrossSections (_V(5,5,1000));
SetCW (1.1, 2.2, 3.5, 3.5);
SetRotDrag (_V(0.05,0.05,0.05));
SetPitchMomentScale (-5e-5);
SetBankMomentScale (-5e-5);
SetLiftCoeffFunc(0);
if( ph_first ) {
DelPropellantResource(ph_first);
ph_first = NULL;
}
if( ph_second ) {
DelPropellantResource(ph_second);
ph_second = NULL;
}
if( ph_srm == NULL ) {
ph_srm = CreatePropellantResource(FUELSRM);
}
th_srm = CreateThruster (_V(0, 0, -0.5)-comshift, _V(0,0,1), 150000.0, ph_srm, 2000.0, 0.0);
AddExhaustStream(th_srm, &oms_exhaust);
VECTOR3 off, off2;
UINT msh, msh2;
off2 = (VZERO-comshift)+_V(0,0,72);
if( status == 3 ) {
msh2 = AddMesh(hpara,&off2);
SetMeshVisibilityMode(msh2,MESHVIS_ALWAYS);
}
off = (VZERO-comshift);
msh = AddMesh(hentry,&off);
SetMeshVisibilityMode(msh,MESHVIS_ALWAYS);
Draw(VZERO-comshift);
/*
if( status == 4 ) {
static UINT groups0[5] = { 0, 1, 2, 3, 4 };
animcomp1 = AddAnimationComponent( anim1, 0, 1,
new MGROUP_ROTATE (
msh2,
groups0, 5,
_V(0,0,1)-off2,
_V(1,0,0),
30*RAD
)
);
animcomp2 = AddAnimationComponent( anim2, 0, 1,
new MGROUP_ROTATE (
msh2,
groups0, 5,
_V(0,0,1)-off2,
_V(0,1,0),
30*RAD
)
);
}
*/
}
void TMA::Animations(UINT mshid) {
int i;
for( i = 0 ; i < 20 ; i++ ) {
DelAnimationComponent(anim3, animcomp3[i] );
}
MGROUP_ROTATE *mgroup;
MGROUP_TRANSLATE *mgroupt;
/*** left panel */
static UINT groups0[1] = { 16 };
mgroup = new MGROUP_ROTATE (
mshid,
groups0, 1,
_V(-1.1,0,0),
_V(0,0,1),
90*RAD
);
animcomp3[0] = AddAnimationComponent( anim3, 0.1, 0.9, mgroup);
static UINT groups1[1] = { 17 };
mgroup = new MGROUP_ROTATE (
mshid,
groups1, 1,
_V(-1.12,0.63,0),
_V(0,0,1),
-178*RAD
);
animcomp3[1] = AddAnimationComponent( anim3, 0.1, 0.9, mgroup, animcomp3[0]);
static UINT groups2[1] = { 20 };
mgroup = new MGROUP_ROTATE (
mshid,
groups2, 1,
_V(-1.15,-0.63,0),
_V(0,0,1),
178*RAD
);
animcomp3[2] = AddAnimationComponent( anim3, 0.1, 0.9, mgroup, animcomp3[1]);
static UINT groups3[2] = { 19, 18 };
mgroup = new MGROUP_ROTATE (
mshid,
groups3, 2,
_V(-1.18,0.63,0),
_V(0,0,1),
-178*RAD
);
animcomp3[3] = AddAnimationComponent( anim3, 0.1, 0.9, mgroup, animcomp3[2]);
/*** right panel */
static UINT groups4[1] = { 21 };
mgroup = new MGROUP_ROTATE (
mshid,
groups4, 1,
_V(1.1,0,0),
_V(0,0,1),
-90*RAD
);
animcomp3[4] = AddAnimationComponent( anim3, 0.1, 0.9, mgroup);
static UINT groups5[1] = { 22 };
mgroup = new MGROUP_ROTATE (
mshid,
groups5, 1,
_V(1.12,0.63,0),
_V(0,0,1),
178*RAD
);
animcomp3[5] = AddAnimationComponent( anim3, 0.1, 0.9, mgroup, animcomp3[4]);
static UINT groups6[1] = { 25 };
mgroup = new MGROUP_ROTATE (
mshid,
groups6, 1,
_V(1.15,-0.63,0),
_V(0,0,1),
-178*RAD
);
animcomp3[6] = AddAnimationComponent( anim3, 0.1, 0.9, mgroup, animcomp3[5]);
static UINT groups7[2] = { 23,24 };
mgroup = new MGROUP_ROTATE (
mshid,
groups7, 2,
_V(1.18,0.63,0),
_V(0,0,1),
178*RAD
);
animcomp3[7] = AddAnimationComponent( anim3, 0.1, 0.9, mgroup, animcomp3[6]);
/* antennae */
static UINT groups8[1] = { 12 };
mgroup = new MGROUP_ROTATE (
mshid,
groups8, 1,
_V(-0.722,0.891,-2.6),
_V(0.239796,0.97082,0),
178*RAD
);
animcomp3[8] = AddAnimationComponent( anim3, 0.05, 0.3, mgroup);
static UINT groups9[1] = { 15 };
mgroup = new MGROUP_ROTATE (
mshid,
groups9, 1,
_V(0,0.94,4.11),
_V(1,0,0),
-140*RAD
);
animcomp3[9] = AddAnimationComponent( anim3, 0.31, 0.85, mgroup);
static UINT groups10[1] = { 15 };
mgroup = new MGROUP_ROTATE (
mshid,
groups10, 1,
_V(0,0.94,4.11),
_V(1,0,0),
-10*RAD
);
animcomp3[10] = AddAnimationComponent( anim3, 0.27, 0.3, mgroup);
static UINT groups11[1] = { 14 };
mgroup = new MGROUP_ROTATE (
mshid,
groups11, 1,
_V(-0.94,0,4.11),
_V(0,1,0),
-130*RAD
);
animcomp3[11] = AddAnimationComponent( anim3, 0.3, 0.9, mgroup);
static UINT groups12[1] = { 14 };
mgroup = new MGROUP_ROTATE (
mshid,
groups12, 1,
_V(-0.94,0,4.11),
_V(0,1,0),
-20*RAD
);
animcomp3[12] = AddAnimationComponent( anim3, 0.3, 0.35, mgroup);
static UINT groups13[2] = { 0,4 };
mgroupt = new MGROUP_TRANSLATE (
mshid,
groups13, 2,
_V(0,-0.4,0.07)
);
animcomp3[13] = AddAnimationComponent( anim3, 0.8, 1.0, mgroupt);
/* thingie */
static UINT groups14[1] = { 27 };
mgroup = new MGROUP_ROTATE (
mshid,
groups14, 1,
_V(0.565,-0.35,4.36),
_V(0.574,1,0),
-50*RAD
);
animcomp3[14] = AddAnimationComponent( anim3, 0.02, 0.1, mgroup);
static UINT groups15[1] = { 26 };
mgroup = new MGROUP_ROTATE (
mshid,
groups15, 1,
_V(0.794,-0.484,4.093),
_V(0.574,1,0),
50*RAD
);
animcomp3[15] = AddAnimationComponent( anim3, 0.02, 0.1, mgroup, animcomp3[14]);
}
void TMA::makeanimation( int i, UINT groups[], int n, VECTOR3 ref, VECTOR3 axis, double range , double start = 0, double end = 1, UINT mid = 0) {
if( animlevel > 0.5 ) {
animlevel = 1.0;
}
else {
animlevel = 0.0;
}
rot[i] = new MGROUP_ROTATE (
mid, // mesh index
groups, n, // group list and # groups
ref, // rotation reference point
axis, // rotation axis
(float) range // angular rotation range
);
animcomp3[i] = AddAnimationComponent (anim3, start, end, rot[i]);
}
void TMA::BlowOrbiter() {
JettisonComponent("SoyuzOrbitMod", "soyorbit", (VZERO-comshift)+_V(0.45,0.60,2.75) , _V(0,0,0.5), _V(0,0,0));
JettisonComponent("SoyuzServiceMod", "soyservice", (VZERO-comshift)+_V(0,0.2,-2.2) , _V(0,0,-0.5), _V(0,0,0));
status = 1;
refresh = 1;
}
void TMA::CalcParaAngles() {
double aoa;
double slip;
aoa = GetAOA() - PI;
if( aoa < -PI )
aoa+=2.0*PI;
slip = GetSlipAngle() - PI;
if( slip < -PI )
slip += 2.0*PI;
if( aoa > 30*RAD )
aoa = 30*RAD;
else if( aoa < -30*RAD )
aoa = -30*RAD;
if( slip > 30*RAD )
slip = 30*RAD;
else if( slip < -30*RAD )
slip = -30*RAD;
aoa /= 30*RAD;
slip /= 30*RAD; // -1 to 1
aoa /= 2.0;
slip /= 2.0; // -0.5 to 0.5
aoa += 0.5; // 0 to 1
slip += 0.5;
slip = 1.0-slip; // correct for opposite sign
/*
if( animcomp1 != NULL ) {
SetAnimation( anim1, aoa );
}
if( animcomp2 != NULL ) {
SetAnimation( anim2, slip );
}
*/
}
This would be massively appreciated.