I am at the very beginning of C++ and programming in Orbiter. I'm making a dll for a spacecraft and the dll is very basic. I have some questions and problems. Could someone help me?
____________________
1. I want to place lightsources at the thrusters. How do I do this? I have looked in the DeltaGlider.cpp file and found this:
I have tried the same thing, but it wouldn't work. I searched the forum, and found this thread: http://www.orbiter-forum.com/showthread.php?t=30358
However, it seems like that I need a header file for this. As I have a very basic knowledge of C++, is it possible to get local lights without a header file?
____________________
2. I have added particlestreams, but this only activates at altitudes below approximatly 80 km.
I want the particlestreams to work at any altitudes, but I don't know how to do that (it is used on the ATV and CTV add ons by Well & NoMatter). I looked in the API_Reference.pdf, but couldn't get any answers ther. How do I do that?
____________________
3. When I build my module, the file size of the dll is very large (a basic plugin on 12 lines has a size of 190 kB).
I guess that it's my Visual C++ Express setup which causes this. I followed the steps in the "Setting up the development enviroment" video by computerex, and am in Debug mode.
Will the filesize get small when I change to "Release"?
____________________
Finally, here is my source code. Feel free to correct if you see something wrong there:
I will appreciate any help I can get!
____________________
1. I want to place lightsources at the thrusters. How do I do this? I have looked in the DeltaGlider.cpp file and found this:
PHP:
COLOUR4 col_d = {0.9,0.8,1,0};
COLOUR4 col_s = {1.9,0.8,1,0};
COLOUR4 col_a = {0,0,0,0};
COLOUR4 col_white = {1,1,1,0};
LightEmitter *le = AddPointLight (_V(0,0,-10), 200, 1e-3, 0, 2e-3, col_d, col_s, col_a);
le->SetIntensityRef (&th_main_level);
...
th_main_level = GetThrusterGroupLevel (THGROUP_MAIN);
However, it seems like that I need a header file for this. As I have a very basic knowledge of C++, is it possible to get local lights without a header file?
____________________
2. I have added particlestreams, but this only activates at altitudes below approximatly 80 km.
I want the particlestreams to work at any altitudes, but I don't know how to do that (it is used on the ATV and CTV add ons by Well & NoMatter). I looked in the API_Reference.pdf, but couldn't get any answers ther. How do I do that?
____________________
3. When I build my module, the file size of the dll is very large (a basic plugin on 12 lines has a size of 190 kB).
I guess that it's my Visual C++ Express setup which causes this. I followed the steps in the "Setting up the development enviroment" video by computerex, and am in Debug mode.
____________________
Finally, here is my source code. Feel free to correct if you see something wrong there:
PHP:
#define STRICT
#define ORBITER_MODULE
#include "orbitersdk.h"
class ChapmanInner1: public VESSEL3
{
public:
ChapmanInner1 (OBJHANDLE hVessel, int flightmodel)
: VESSEL3 (hVessel, flightmodel) {}
void clbkSetClassCaps (FILEHANDLE cfg);
void clbkFocusChanged (bool getfocus, OBJHANDLE newv, OBJHANDLE oldv);
};
void ChapmanInner1::clbkSetClassCaps (FILEHANDLE cfg)
{
SetSize (4);
SetEmptyMass (679);
SetCW (0.3, 0.3, 1.5, 1.5);
SetCrossSections (_V(5.73, 4.37, 4.08));
SetRotDrag (_V(2,2,2));
SetPMI (_V(0.5, 0.5, 0.5));
SetCameraOffset (_V(-0.449269, 0.126477, 1.24));
SetTouchdownPoints (_V(0, -1, 0), _V(1, -1, 0), _V(-1, -1, 0));
InitNavRadios (3);
const double MAINFUELMASS = 980;
const double RCSFUELMASS = 50;
const double ISPMAINVAC = 3500;
const double ISPMAINATM = 35;
const double ISPRCSVAC = 1300;
const double ISPRCSATM = 13;
const double MAINTHRUST = 2500;
const double RCSTHRUST = 2;
PROPELLANT_HANDLE MainTank;
MainTank = CreatePropellantResource (MAINFUELMASS);
PROPELLANT_HANDLE RCSTank;
RCSTank = CreatePropellantResource (RCSFUELMASS);
THRUSTER_HANDLE main, rcs[24], rcsgroup[4];
PARTICLESTREAMSPEC contrail_main =
{
0, 0.2, 5, 4, 0.3, 4.0, 4, 2.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC exhaust_main =
{
0, 2.0, 20, 150, 0.1, 0.2, 16, 2.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
PARTICLESTREAMSPEC contrail_RCS =
{
0, 0.2, 5, 4, 0.3, 4.0, 4, 2.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};
PARTICLESTREAMSPEC exhaust_RCS =
{
0, 2.0, 20, 150, 0.1, 0.2, 16, 2.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_FLAT, 1, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
main = CreateThruster (_V( 0, 0, -2.0), _V(0, 0, 1), MAINTHRUST, MainTank, ISPMAINVAC, ISPMAINATM);
CreateThrusterGroup (&main, 1, THGROUP_MAIN);
AddExhaust (main, 2.0, 0.125, _V(0.0123, -0.0261, -2.0), _V(0, 0, -1));
AddExhaustStream (main, _V( 0.012311, -0.026071, -2.0), &contrail_main);
AddExhaustStream (main, _V( 0.012311, -0.026071, -2.0), &exhaust_main);
rcs[ 0] = CreateThruster (_V( 0.512689,-0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[ 1] = CreateThruster (_V( 0.512689, 0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[ 2] = CreateThruster (_V(-0.512689, 0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[ 3] = CreateThruster (_V(-0.512689,-0.261586,-1.622), _V( 0, 0, 1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[ 4] = CreateThruster (_V( 0.880899,-0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[ 5] = CreateThruster (_V(-0.880899,-0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[ 6] = CreateThruster (_V( 0.880899, 0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[ 7] = CreateThruster (_V(-0.880899, 0.261586, 1.217578), _V( 0, 0,-1), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[ 8] = CreateThruster (_V( 0.618274,-0.261586,-1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[ 9] = CreateThruster (_V( 0.618274, 0.261586,-1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[10] = CreateThruster (_V( 0.618274,-0.261586, 1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[11] = CreateThruster (_V( 0.618274, 0.261586, 1.114589), _V(-1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[12] = CreateThruster (_V(-0.618274,-0.261586,-1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[13] = CreateThruster (_V(-0.618274, 0.261586,-1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[14] = CreateThruster (_V(-0.618274,-0.261586, 1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[15] = CreateThruster (_V(-0.618274, 0.261586, 1.114589), _V( 1, 0, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[16] = CreateThruster (_V( 0.512689,-0.5586355,-1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[17] = CreateThruster (_V(-0.512689,-0.5586355,-1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[18] = CreateThruster (_V(-0.512689,-0.5586355, 1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[19] = CreateThruster (_V( 0.512689,-0.5586355, 1.114589), _V( 0, 1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[20] = CreateThruster (_V( 0.512689, 0.3651495,-1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[21] = CreateThruster (_V(-0.512689, 0.3651495,-1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[22] = CreateThruster (_V( 0.512689, 0.3651495, 1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
rcs[23] = CreateThruster (_V(-0.512689, 0.3651495, 1.114589), _V( 0,-1, 0), RCSTHRUST, RCSTank, ISPRCSVAC, ISPRCSATM);
AddExhaust (rcs[ 0], 0.30, 0.02, _V( 0.537311,-0.455072,-1.622), _V( 0, 0,-1));
AddExhaust (rcs[ 1], 0.30, 0.02, _V( 0.537311, 0.261586,-1.622), _V( 0, 0,-1));
AddExhaust (rcs[ 2], 0.30, 0.02, _V(-0.512689, 0.261586,-1.622), _V( 0, 0,-1));
AddExhaust (rcs[ 3], 0.30, 0.02, _V(-0.512689,-0.455072,-1.622), _V( 0, 0,-1));
AddExhaust (rcs[ 4], 0.30, 0.02, _V( 0.905521,-0.455062, 1.217578), _V( 0, 0, 1));
AddExhaust (rcs[ 5], 0.30, 0.02, _V(-0.880899,-0.455062, 1.217578), _V( 0, 0, 1));
AddExhaust (rcs[ 6], 0.30, 0.02, _V( 0.905521, 0.2633565, 1.217578), _V( 0, 0, 1));
AddExhaust (rcs[ 7], 0.30, 0.02, _V(-0.880899, 0.2633565, 1.217578), _V( 0, 0, 1));
AddExhaust (rcs[ 8], 0.30, 0.02, _V( 0.642896,-0.455348,-1.519011), _V( 1, 0, 0));
AddExhaust (rcs[ 9], 0.30, 0.02, _V( 0.642896, 0.261862,-1.519011), _V( 1, 0, 0));
AddExhaust (rcs[10], 0.30, 0.02, _V( 1.011106,-0.455338, 1.114589), _V( 1, 0, 0));
AddExhaust (rcs[11], 0.30, 0.02, _V( 1.011106, 0.263632, 1.114589), _V( 1, 0, 0));
AddExhaust (rcs[12], 0.30, 0.02, _V(-0.618274,-0.455348,-1.519011), _V(-1, 0, 0));
AddExhaust (rcs[13], 0.30, 0.02, _V(-0.618274, 0.261862,-1.519011), _V(-1, 0, 0));
AddExhaust (rcs[14], 0.30, 0.02, _V(-0.9864841,-0.455338, 1.114589), _V(-1, 0, 0));
AddExhaust (rcs[15], 0.30, 0.02, _V(-0.9864841, 0.263632, 1.114589), _V(-1, 0, 0));
AddExhaust (rcs[16], 0.30, 0.02, _V( 0.5368665,-0.5586355,-1.519011), _V( 0,-1, 0));
AddExhaust (rcs[17], 0.30, 0.02, _V(-0.5122445,-0.5586355,-1.519011), _V( 0,-1, 0));
AddExhaust (rcs[18], 0.30, 0.02, _V(-0.8804545,-0.5586355, 1.114589), _V( 0,-1, 0));
AddExhaust (rcs[19], 0.30, 0.02, _V( 0.9050765,-0.5586355, 1.114589), _V( 0,-1, 0));
AddExhaust (rcs[20], 0.30, 0.02, _V( 0.5368665, 0.3651495,-1.519011), _V( 0, 1, 0));
AddExhaust (rcs[21], 0.30, 0.02, _V(-0.5122445, 0.3651495,-1.519011), _V( 0, 1, 0));
AddExhaust (rcs[22], 0.30, 0.02, _V( 0.9050765, 0.3669295, 1.114589), _V( 0, 1, 0));
AddExhaust (rcs[23], 0.30, 0.02, _V(-0.8804545, 0.3669295, 1.114589), _V( 0, 1, 0));
rcsgroup[0] = rcs[ 0];
rcsgroup[1] = rcs[ 1];
rcsgroup[2] = rcs[ 2];
rcsgroup[3] = rcs[ 3];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_FORWARD);
rcsgroup[0] = rcs[ 4];
rcsgroup[1] = rcs[ 5];
rcsgroup[2] = rcs[ 6];
rcsgroup[3] = rcs[ 7];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BACK);
rcsgroup[0] = rcs[ 8];
rcsgroup[1] = rcs[ 9];
rcsgroup[2] = rcs[10];
rcsgroup[3] = rcs[11];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_LEFT);
rcsgroup[0] = rcs[12];
rcsgroup[1] = rcs[13];
rcsgroup[2] = rcs[14];
rcsgroup[3] = rcs[15];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_RIGHT);
rcsgroup[0] = rcs[16];
rcsgroup[1] = rcs[17];
rcsgroup[2] = rcs[18];
rcsgroup[3] = rcs[19];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_UP);
rcsgroup[0] = rcs[20];
rcsgroup[1] = rcs[21];
rcsgroup[2] = rcs[22];
rcsgroup[3] = rcs[23];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_DOWN);
rcsgroup[0] = rcs[18];
rcsgroup[1] = rcs[19];
rcsgroup[2] = rcs[20];
rcsgroup[3] = rcs[21];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_PITCHUP);
rcsgroup[0] = rcs[16];
rcsgroup[1] = rcs[17];
rcsgroup[2] = rcs[22];
rcsgroup[3] = rcs[23];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_PITCHDOWN);
rcsgroup[0] = rcs[10];
rcsgroup[1] = rcs[11];
rcsgroup[2] = rcs[12];
rcsgroup[3] = rcs[13];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_YAWLEFT);
rcsgroup[0] = rcs[8];
rcsgroup[1] = rcs[9];
rcsgroup[2] = rcs[14];
rcsgroup[3] = rcs[15];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_YAWRIGHT);
rcsgroup[0] = rcs[16];
rcsgroup[1] = rcs[19];
rcsgroup[2] = rcs[21];
rcsgroup[3] = rcs[23];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BANKLEFT);
rcsgroup[0] = rcs[17];
rcsgroup[1] = rcs[18];
rcsgroup[2] = rcs[20];
rcsgroup[3] = rcs[22];
CreateThrusterGroup (rcsgroup, 4, THGROUP_ATT_BANKRIGHT);
AddExhaustStream (rcs[ 0], _V( 0.537311,-0.455072,-1.622), &contrail_RCS);
AddExhaustStream (rcs[ 1], _V( 0.537311, 0.261586,-1.622), &contrail_RCS);
AddExhaustStream (rcs[ 2], _V(-0.512689, 0.261586,-1.622), &contrail_RCS);
AddExhaustStream (rcs[ 3], _V(-0.512689,-0.455072,-1.622), &contrail_RCS);
AddExhaustStream (rcs[ 4], _V( 0.905521,-0.455062, 1.217578), &contrail_RCS);
AddExhaustStream (rcs[ 5], _V(-0.880899,-0.455062, 1.217578), &contrail_RCS);
AddExhaustStream (rcs[ 6], _V( 0.905521, 0.2633565, 1.217578), &contrail_RCS);
AddExhaustStream (rcs[ 7], _V(-0.880899, 0.2633565, 1.217578), &contrail_RCS);
AddExhaustStream (rcs[ 8], _V( 0.642896,-0.455348,-1.519011), &contrail_RCS);
AddExhaustStream (rcs[ 9], _V( 0.642896, 0.261862,-1.519011), &contrail_RCS);
AddExhaustStream (rcs[10], _V( 1.011106,-0.455338, 1.114589), &contrail_RCS);
AddExhaustStream (rcs[11], _V( 1.011106, 0.263632, 1.114589), &contrail_RCS);
AddExhaustStream (rcs[12], _V(-0.618274,-0.455348,-1.519011), &contrail_RCS);
AddExhaustStream (rcs[13], _V(-0.618274, 0.261862,-1.519011), &contrail_RCS);
AddExhaustStream (rcs[14], _V(-0.9864841,-0.455338, 1.114589), &contrail_RCS);
AddExhaustStream (rcs[15], _V(-0.9864841, 0.263632, 1.114589), &contrail_RCS);
AddExhaustStream (rcs[16], _V( 0.5368665,-0.5586355,-1.519011), &contrail_RCS);
AddExhaustStream (rcs[17], _V(-0.5122445,-0.5586355,-1.519011), &contrail_RCS);
AddExhaustStream (rcs[18], _V(-0.8804545,-0.5586355, 1.114589), &contrail_RCS);
AddExhaustStream (rcs[19], _V( 0.9050765,-0.5586355, 1.114589), &contrail_RCS);
AddExhaustStream (rcs[20], _V( 0.5368665, 0.3651495,-1.519011), &contrail_RCS);
AddExhaustStream (rcs[21], _V(-0.5122445, 0.3651495,-1.519011), &contrail_RCS);
AddExhaustStream (rcs[22], _V( 0.9050765, 0.3669295, 1.114589), &contrail_RCS);
AddExhaustStream (rcs[23], _V(-0.8804545, 0.3669295, 1.114589), &contrail_RCS);
AddExhaustStream (rcs[ 0], _V( 0.537311,-0.455072,-1.622), &exhaust_RCS);
AddExhaustStream (rcs[ 1], _V( 0.537311, 0.261586,-1.622), &exhaust_RCS);
AddExhaustStream (rcs[ 2], _V(-0.512689, 0.261586,-1.622), &exhaust_RCS);
AddExhaustStream (rcs[ 3], _V(-0.512689,-0.455072,-1.622), &exhaust_RCS);
AddExhaustStream (rcs[ 4], _V( 0.905521,-0.455062, 1.217578), &exhaust_RCS);
AddExhaustStream (rcs[ 5], _V(-0.880899,-0.455062, 1.217578), &exhaust_RCS);
AddExhaustStream (rcs[ 6], _V( 0.905521, 0.2633565, 1.217578), &exhaust_RCS);
AddExhaustStream (rcs[ 7], _V(-0.880899, 0.2633565, 1.217578), &exhaust_RCS);
AddExhaustStream (rcs[ 8], _V( 0.642896,-0.455348,-1.519011), &exhaust_RCS);
AddExhaustStream (rcs[ 9], _V( 0.642896, 0.261862,-1.519011), &exhaust_RCS);
AddExhaustStream (rcs[10], _V( 1.011106,-0.455338, 1.114589), &exhaust_RCS);
AddExhaustStream (rcs[11], _V( 1.011106, 0.263632, 1.114589), &exhaust_RCS);
AddExhaustStream (rcs[12], _V(-0.618274,-0.455348,-1.519011), &exhaust_RCS);
AddExhaustStream (rcs[13], _V(-0.618274, 0.261862,-1.519011), &exhaust_RCS);
AddExhaustStream (rcs[14], _V(-0.9864841,-0.455338, 1.114589), &exhaust_RCS);
AddExhaustStream (rcs[15], _V(-0.9864841, 0.263632, 1.114589), &exhaust_RCS);
AddExhaustStream (rcs[16], _V( 0.5368665,-0.5586355,-1.519011), &exhaust_RCS);
AddExhaustStream (rcs[17], _V(-0.5122445,-0.5586355,-1.519011), &exhaust_RCS);
AddExhaustStream (rcs[18], _V(-0.8804545,-0.5586355, 1.114589), &exhaust_RCS);
AddExhaustStream (rcs[19], _V( 0.9050765,-0.5586355, 1.114589), &exhaust_RCS);
AddExhaustStream (rcs[20], _V( 0.5368665, 0.3651495,-1.519011), &exhaust_RCS);
AddExhaustStream (rcs[21], _V(-0.5122445, 0.3651495,-1.519011), &exhaust_RCS);
AddExhaustStream (rcs[22], _V( 0.9050765, 0.3669295, 1.114589), &exhaust_RCS);
AddExhaustStream (rcs[23], _V(-0.8804545, 0.3669295, 1.114589), &exhaust_RCS);
// Mesh
AddMesh("ChapmanInner1");
}
void ChapmanInner1::clbkFocusChanged (bool getfocus, OBJHANDLE newv, OBJHANDLE oldv)
{
if (getfocus)
{
oapiDisableMFDMode (MFD_LANDING);
oapiDisableMFDMode (MFD_HSI);
}
}
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
return new ChapmanInner1 (hvessel, flightmodel);
}
DLLCLBK void ovcExit (VESSEL *vessel)
{
if (vessel) delete (ChapmanInner1*)vessel;
}
I will appreciate any help I can get!
Last edited: