Orbiter-Forum  

Go Back   Orbiter-Forum > Blogs > IgnoreThisBarrel
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Rate this Entry

Heisenberg DLL Development

Posted 11-13-2010 at 06:18 AM by IgnoreThisBarrel

SO I've decided to abandon Spacecraft3 and instead create a custom DLL module for the Heisenberg (it'll probably have UMMU and hopefully UCGO support). Now I'm terrible at C++ so if anyone could recommend any tutorials on writing things specifically for Orbiter it would be very much appreciated.

So the current Heisenberg code is a modified version of the ShuttlePB code. Don't worry, I plan to add more... complex... code to it.

I have some questions, but first, I can't seem to build the module correctly. It was working fine until I added everything after defining variables.

When I build or debug, I get the following
Code:
1>------ Build started: Project: Heisenberg, Configuration: Debug Win32 ------
1>Build started 11/12/2010 10:15:51 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\Heisenberg.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\Orbiter\Orbitersdk\samples\Heisenberg\Debug\Heisenberg.dll) does not match the Linker's OutputFile property value (C:\Orbiter\Modules\Heisenberg.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" ([email protected]@[email protected]@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" ([email protected]@[email protected]@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>     Creating library C:\Orbiter\Orbitersdk\samples\Heisenberg\Debug\Heisenberg.lib and object C:\Orbiter\Orbitersdk\samples\Heisenberg\Debug\Heisenberg.exp
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>..\..\..\Modules\Heisenberg.dll : fatal error LNK1169: one or more multiply defined symbols found
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.11
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
So I don't think it's a problem with a code. I set up the environment exactly as shown in the tutorial by Computerex, except when telling the project to ignore certain libraries, the layout was slightly different than in the video (he used 2008, I use 2010).

So I'm including the project files in the hope that someone can figure out my mistake. And here's the code if you're interested.
Code:
#define STRICT
#define ORBITER_MODULE

#include <orbitersdk.h>

// ==============================================================
// Some vessel parameters
// ==============================================================
const double  Heisenberg_SIZE       = 1595;             // mean radius [m]
const VECTOR3 Heisenberg_CS         = {401.5974,460.7434,59.8254}; // x,y,z cross sections [m^2]
const VECTOR3 Heisenberg_PMI        = {302.52637,303.01298,1.16386};// principal moments of inertia (mass-normalised) [m^2]
const VECTOR3 Heisenberg_RD         = {7.5,7.6,1.5};//{0.05,0.1,0.05};  // rotation drag coefficients
const double  Heisenberg_EMPTYMASS  = 125600;           // empty vessel mass [kg]
const double  Heisenberg_FUELMASS   = 1204750;           // max fuel mass [kg]
const double  Heisenberg_ISP        = 4e5;             // fuel-specific impulse [m/s]
const VECTOR3 Heisenberg_TDP[3]     = {{31.68693,-39.82578,-784.7108},{-31.68693,-39.82578,-784.7108},{0,-40.17707,657.3074}}; // touchdown points [m]
const VECTOR3 Heisenberg_COP        = {0,0,0};//{0,0,-0.1};      // centre of pressure for airfoils [m]
const double  Heisenberg_VLIFT_C    = 2.0;             // chord length [m]
const double  Heisenberg_VLIFT_S    = 2.0;             // wing area [m^2]
const double  Heisenberg_VLIFT_A    = 0.1;             // wing aspect ratio
const double  Heisenberg_HLIFT_C    = 2.0;             // chord length [m]
const double  Heisenberg_HLIFT_S    = 1.5;             // wing area [m^2]
const double  Heisenberg_HLIFT_A    = 2.0;             // wing aspect ratio

const double  Heisenberg_MAXMAINTH  = 5e7;             
const double  Heisenberg_MAXHOVERTH = 6e6;
const double  Heisenberg_MAXRCSTH   = 4e7;

const VECTOR3 Heisenberg_DOCK_POS   = {0,0,796.676};      // docking port location [m]
const VECTOR3 Heisenberg_DOCK_DIR   = {0,0,1};         // docking port approach direction
const VECTOR3 Heisenberg_DOCK_ROT   = {0,1,0};        // docking port alignment direction

// Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi
// Implemented here as a piecewise linear function
double LiftCoeff (double aoa)
{
    int i;
    const int nlift = 9;
    static const double AOA[nlift] = {-180*RAD,-60*RAD,-30*RAD,-1*RAD,15*RAD,20*RAD,25*RAD,60*RAD,180*RAD};
    static const double CL[nlift]  = {       0,      0,   -0.1,     0,   0.2,  0.25,   0.2,     0,      0};
    static const double SCL[nlift] = {(CL[1]-CL[0])/(AOA[1]-AOA[0]), (CL[2]-CL[1])/(AOA[2]-AOA[1]),
                                      (CL[3]-CL[2])/(AOA[3]-AOA[2]), (CL[4]-CL[3])/(AOA[4]-AOA[3]),
                                      (CL[5]-CL[4])/(AOA[5]-AOA[4]), (CL[6]-CL[5])/(AOA[6]-AOA[5]),
                                      (CL[7]-CL[6])/(AOA[7]-AOA[6]), (CL[8]-CL[7])/(AOA[8]-AOA[7])};
    for (i = 0; i < nlift-1 && AOA[i+1] < aoa; i++);
    return CL[i] + (aoa-AOA[i])*SCL[i];
}

// ==============================================================
// Heisenberg class interface
// ==============================================================

class Heisenberg: public VESSEL3 {
public:
    Heisenberg (OBJHANDLE hVessel, int flightmodel);
    ~Heisenberg ();
    void clbkSetClassCaps (FILEHANDLE cfg);

private:
    static void vlift (VESSEL *v, double aoa, double M, double Re,
        void *context, double *cl, double *cm, double *cd);
    static void hlift (VESSEL *v, double aoa, double M, double Re,
        void *context, double *cl, double *cm, double *cd);

    // transformations for control surface animations
    static MGROUP_ROTATE trans_Laileron, trans_Raileron;
    static MGROUP_ROTATE trans_Lelevator, trans_Relevator;
};

Heisenberg::Heisenberg (OBJHANDLE hVessel, int flightmodel)
: VESSEL3 (hVessel, flightmodel)
{
}

Heisenberg::~Heisenberg ()
{
}

// ==============================================================
// Overloaded callback functions
// ==============================================================

// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------
void Heisenberg::clbkSetClassCaps (FILEHANDLE cfg)
{
    THRUSTER_HANDLE th_main, th_hover, th_rcs[14], th_group[4];

    // physical vessel parameters
    SetSize (Heisenberg_SIZE);
    SetEmptyMass (Heisenberg_EMPTYMASS);
    SetPMI (Heisenberg_PMI);
    SetCrossSections (Heisenberg_CS);
    SetRotDrag (Heisenberg_RD);
    SetTouchdownPoints (Heisenberg_TDP[0], Heisenberg_TDP[1], Heisenberg_TDP[2]);

    // docking port definitions
    SetDockParams (Heisenberg_DOCK_POS, Heisenberg_DOCK_DIR, Heisenberg_DOCK_ROT);

    // airfoil definitions
    CreateAirfoil3 (LIFT_VERTICAL,   Heisenberg_COP, vlift, NULL, Heisenberg_VLIFT_C, Heisenberg_VLIFT_S, Heisenberg_VLIFT_A);
    CreateAirfoil3 (LIFT_HORIZONTAL, Heisenberg_COP, hlift, NULL, Heisenberg_HLIFT_C, Heisenberg_HLIFT_S, Heisenberg_HLIFT_A);

    // propellant resources
    PROPELLANT_HANDLE hpr = CreatePropellantResource (Heisenberg_FUELMASS);

    // main engine
    th_main = CreateThruster (_V(0,0,-772.565), _V(0,0,1), Heisenberg_MAXMAINTH, hpr, Heisenberg_ISP);
    CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
    AddExhaust (th_main, 8, 10, _V(0,0.3,-772.565), _V(0,0,-1));

    PARTICLESTREAMSPEC contrail_main = {
        0, 32, 16, 1500, 0.1, 0.1, 6, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
        PARTICLESTREAMSPEC::LVL_PSQRT, 0, 4,
        PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
    };
    PARTICLESTREAMSPEC exhaust_main = {
        0, 8.0, 10, 150, 0.1, 0.2, 16, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
        PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
        PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
    };
    AddExhaustStream (th_main, _V(0,0.3,-10), &contrail_main);
    AddExhaustStream (th_main, _V(0,0.3,-5), &exhaust_main);

    // hover engine
    th_hover = CreateThruster (_V(0,-5.197,-716.228), _V(0,1,0), Heisenberg_MAXHOVERTH, hpr, Heisenberg_ISP);
    CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);
    AddExhaust (th_hover, 8, 1, _V(0,-5.197,-716.228), _V(0,-1,0));
    AddExhaust (th_hover, 8, 1, _V(0,-5.197,-716.228), _V(0,-1,0));

    PARTICLESTREAMSPEC contrail_hover = {
        0, 8, 256, 8, 0.8, 12, 4, 24, PARTICLESTREAMSPEC::EMISSIVE,
        PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
        PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
    };
    PARTICLESTREAMSPEC exhaust_hover = {
        0, 8, 4, 12, 2, 2, 32, 16, PARTICLESTREAMSPEC::EMISSIVE,
        PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
        PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
    };

    AddExhaustStream (th_hover, _V(0,-3, 1), &contrail_hover);
    AddExhaustStream (th_hover, _V(0,-3,-1), &contrail_hover);
    AddExhaustStream (th_hover, _V(0,-2, 1), &exhaust_hover);
    AddExhaustStream (th_hover, _V(0,-2,-1), &exhaust_hover);

    // camera parameters
    SetCameraOffset (_V(0,10.628,769.547));

    // associate a mesh for the visual
    AddMesh ("Heisenberg\Heisenberg");
}

// ==============================================================
// Airfoil lift/drag functions
// ==============================================================

void Heisenberg::vlift (VESSEL *v, double aoa, double M, double Re,
    void *context, double *cl, double *cm, double *cd)
{
    static const double clp[] = {  // lift coefficient from -pi to pi in 10deg steps
        -0.1,-0.5,-0.4,-0.1,0,0,0,0,0,0,0,0,0,0,-0.2,-0.6,-0.6,-0.4,0.2,0.5,0.9,0.8,0.2,0,0,0,0,0,0,0,0,0,0.1,0.4,0.5,0.3,-0.1,-0.5
    };
    static const double aoa_step = 10.0*RAD;
    double a, fidx, saoa = sin(aoa);
    a = modf((aoa+PI)/aoa_step, &fidx);
    int idx = (int)(fidx+0.5);
    *cl = clp[idx]*(1.0-a) + clp[idx+1]*a;     // linear interpolation
    *cm = 0.0; //-0.03*sin(aoa-0.1);
    *cd = 0.03 + 0.4*saoa*saoa;                // profile drag
    *cd += oapiGetInducedDrag (*cl, 1.0, 0.5); // induced drag
    *cd += oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04);  // wave drag
}

void Heisenberg::hlift (VESSEL *v, double aoa, double M, double Re,
    void *context, double *cl, double *cm, double *cd)
{
    static const double clp[] = {  // lift coefficient from -pi to pi in 45deg steps
        0,0.4,0,-0.4,0,0.4,0,-0.4,0,0.4
    };
    static const double aoa_step = 45.0*RAD;
    double a, fidx;
    a = modf((aoa+PI)/aoa_step, &fidx);
    int idx = (int)(fidx+0.5);
    *cl = clp[idx]*(1.0-a) + clp[idx+1]*a;     // linear interpolation
    *cm = 0.0;
    *cd = 0.03;
    *cd += oapiGetInducedDrag (*cl, 1.5, 0.6); // induced drag
    *cd += oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04);  // wave drag
}

// ==============================================================
// API callback interface
// ==============================================================

// --------------------------------------------------------------
// Vessel initialisation
// --------------------------------------------------------------
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
    return new Heisenberg (hvessel, flightmodel);
}

// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
DLLCLBK void ovcExit (VESSEL *vessel)
{
    if (vessel) delete (Heisenberg*)vessel;
}
One last thing, is there a document or tutorial somewhere that shows me how to add features to the module, or do I have to learn by example? Specifically, how to add light sources, adjusting the position of docking ports (for extendable/retractable docking ports), and changing the landing points depending on the position of the landing gear.

Any help is, of course, very much appreciated.
Attached Files
File Type: zip HeisenbergDLL.zip (9.34 MB, 1 views)
Views 6197 Comments 8
« Prev     Main     Next »
Total Comments 8

Comments

  1. Old Comment
    orb's Avatar
    Try to add these libraries to ignore list and eventually to additional dependencies.

    I'm not advocate of the tutorial, which I've never used, but instead I'm advocate of using Inherited Property Sheets that were introduced in Orbiter 2010 (Orbitersdk/resources). They set all include/library/output paths for the project automatically, and you only need to add them to project and nothing else (after you changed the OrbiterDir macro). Look here and here.
    Posted 11-13-2010 at 03:48 PM by orb orb is offline
  2. Old Comment
    IgnoreThisBarrel's Avatar
    Thanks, but I'm afraid my knowledge of this stuff is extremely low. How does one use these properties sheets? Like how do you open them, if you open them at all?
    Posted 11-14-2010 at 12:11 AM by IgnoreThisBarrel IgnoreThisBarrel is offline
  3. Old Comment
    orb's Avatar
    Quote:
    Originally Posted by IgnoreThisBarrel View Comment
    Thanks, but I'm afraid my knowledge of this stuff is extremely low. How does one use these properties sheets? Like how do you open them, if you open them at all?
    You only need to edit "orbiterroot.vsprops" that is in "Orbitersdk/resources" subfolder of Orbiter. To edit it, you can open it by a text editor like Windows' Notepad, or something similar. You only need to change one value in that file - path to your Orbiter's folder. Here's the original, with red color marked what you need to change:
    Code:
    <?xml version="1.0" encoding="Windows-1252"?>
    <VisualStudioPropertySheet
    	ProjectType="Visual C++"
    	Version="8.00"
    	Name="orbiterroot"
    	>
    	<UserMacro
    		Name="OrbiterDir"
    		Value="c:\source\orbiter"
    		PerformEnvironmentSet="true"
    	/>
    </VisualStudioPropertySheet>
    Then you save the file and you can close it.

    Next in the project properties, for "Debug" configuration in "Configuration Properties -> General" you edit the list of "Inherited Project Property Sheets" and add "<path to Orbiter>/Orbitersdk/resources/Orbiter vessel.vsprops" file and "<path to Orbiter>/Orbitersdk/resources/Orbiter debug.vsprops" file.

    If your project is in the "samples" folder then you can add exactly these: "../../resources/Orbiter vessel.vsprops" and "../../resources/Orbiter debug.vsprops".

    You do the same for "Release" configuration, but without adding "Orbiter debug.vsprops" file to the list.

    And that's all you need in your project. If you haven't set paths, they will be set by property sheets. It's great for creating new projects.

    This is how it's configured in VS2005 and VS2008, but probably VS2010 has these settings in the same place.
    Posted 11-14-2010 at 01:11 AM by orb orb is offline
  4. Old Comment
    IgnoreThisBarrel's Avatar
    Thank you! It worked!
    Posted 11-14-2010 at 02:21 AM by IgnoreThisBarrel IgnoreThisBarrel is offline
  5. Old Comment
    IgnoreThisBarrel's Avatar
    Ugh, although for some reason whenever I build the project I don't get the module.
    Posted 11-14-2010 at 03:59 AM by IgnoreThisBarrel IgnoreThisBarrel is offline
  6. Old Comment
    orb's Avatar
    Quote:
    Originally Posted by IgnoreThisBarrel View Comment
    Ugh, although for some reason whenever I build the project I don't get the module.
    I don't know. Maybe those property sheets aren't fully compatible with VS2010. It's using changed format for project files (.vcxproj), which isn't backwards compatible with VS2005/2008 (.vcproj). In that case, you need to set output paths by yourself in the project properties.
    Posted 11-14-2010 at 10:48 AM by orb orb is offline
  7. Old Comment
    IgnoreThisBarrel's Avatar
    Ah, thank you, now it compiles. Although Orbiter can't read the module.

    If anyone is willing to take a look at the code, here it is:
    Code:
    #define STRICT
    #define ORBITER_MODULE
    
    #include <orbitersdk.h>
    
    // ==============================================================
    // Some vessel parameters
    // ==============================================================
    const double  Heisenberg_SIZE       = 1595;             // mean radius [m]
    const VECTOR3 Heisenberg_CS         = {401.5974,460.7434,59.8254}; // x,y,z cross sections [m^2]
    const VECTOR3 Heisenberg_PMI        = {302.52637,303.01298,1.16386};// principal moments of inertia (mass-normalised) [m^2]
    const VECTOR3 Heisenberg_RD         = {7.5,7.6,1.5};//{0.05,0.1,0.05};  // rotation drag coefficients
    const double  Heisenberg_EMPTYMASS  = 125600;           // empty vessel mass [kg]
    const double  Heisenberg_FUELMASS   = 1204750;           // max fuel mass [kg]
    const double  Heisenberg_ISP        = 4e5;             // fuel-specific impulse [m/s]
    const VECTOR3 Heisenberg_TDP[3]     = {{31.68693,-39.82578,-784.7108},{-31.68693,-39.82578,-784.7108},{0,-40.17707,657.3074}}; // touchdown points [m]
    const VECTOR3 Heisenberg_COP        = {0,0,0};//{0,0,-0.1};      // centre of pressure for airfoils [m]
    const double  Heisenberg_VLIFT_C    = 2.0;             // chord length [m]
    const double  Heisenberg_VLIFT_S    = 2.0;             // wing area [m^2]
    const double  Heisenberg_VLIFT_A    = 0.1;             // wing aspect ratio
    const double  Heisenberg_HLIFT_C    = 2.0;             // chord length [m]
    const double  Heisenberg_HLIFT_S    = 1.5;             // wing area [m^2]
    const double  Heisenberg_HLIFT_A    = 2.0;             // wing aspect ratio
    
    const double  Heisenberg_MAXMAINTH  = 5e7;             
    const double  Heisenberg_MAXHOVERTH = 6e6;
    const double  Heisenberg_MAXRCSTH   = 4e7;
    
    const VECTOR3 Heisenberg_DOCK_POS   = {0,0,796.676};      // docking port location [m]
    const VECTOR3 Heisenberg_DOCK_DIR   = {0,0,1};         // docking port approach direction
    const VECTOR3 Heisenberg_DOCK_ROT   = {0,1,0};        // docking port alignment direction
    
    // Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi
    // Implemented here as a piecewise linear function
    double LiftCoeff (double aoa)
    {
    	int i;
    	const int nlift = 9;
    	static const double AOA[nlift] = {-180*RAD,-60*RAD,-30*RAD,-1*RAD,15*RAD,20*RAD,25*RAD,60*RAD,180*RAD};
    	static const double CL[nlift]  = {       0,      0,   -0.1,     0,   0.2,  0.25,   0.2,     0,      0};
    	static const double SCL[nlift] = {(CL[1]-CL[0])/(AOA[1]-AOA[0]), (CL[2]-CL[1])/(AOA[2]-AOA[1]),
    		                              (CL[3]-CL[2])/(AOA[3]-AOA[2]), (CL[4]-CL[3])/(AOA[4]-AOA[3]),
    									  (CL[5]-CL[4])/(AOA[5]-AOA[4]), (CL[6]-CL[5])/(AOA[6]-AOA[5]),
    									  (CL[7]-CL[6])/(AOA[7]-AOA[6]), (CL[8]-CL[7])/(AOA[8]-AOA[7])};
    	for (i = 0; i < nlift-1 && AOA[i+1] < aoa; i++);
    	return CL[i] + (aoa-AOA[i])*SCL[i];
    }
    
    // ==============================================================
    // Heisenberg class interface
    // ==============================================================
    
    class Heisenberg: public VESSEL3 {
    public:
    	Heisenberg (OBJHANDLE hVessel, int flightmodel);
    	~Heisenberg ();
    	void clbkSetClassCaps (FILEHANDLE cfg);
    
    private:
    	static void vlift (VESSEL *v, double aoa, double M, double Re,
    		void *context, double *cl, double *cm, double *cd);
    	static void hlift (VESSEL *v, double aoa, double M, double Re,
    		void *context, double *cl, double *cm, double *cd);
    
    	// transformations for control surface animations
    	static MGROUP_ROTATE trans_Laileron, trans_Raileron;
    	static MGROUP_ROTATE trans_Lelevator, trans_Relevator;
    };
    
    Heisenberg::Heisenberg (OBJHANDLE hVessel, int flightmodel)
    : VESSEL3 (hVessel, flightmodel)
    {
    }
    
    Heisenberg::~Heisenberg ()
    {
    }
    
    // ==============================================================
    // Overloaded callback functions
    // ==============================================================
    
    // --------------------------------------------------------------
    // Set the capabilities of the vessel class
    // --------------------------------------------------------------
    void Heisenberg::clbkSetClassCaps (FILEHANDLE cfg)
    {
    	THRUSTER_HANDLE th_main, th_hover, th_rcs[14], th_group[4];
    
    	// physical vessel parameters
    	SetSize (Heisenberg_SIZE);
    	SetEmptyMass (Heisenberg_EMPTYMASS);
    	SetPMI (Heisenberg_PMI);
    	SetCrossSections (Heisenberg_CS);
    	SetRotDrag (Heisenberg_RD);
    	SetTouchdownPoints (Heisenberg_TDP[0], Heisenberg_TDP[1], Heisenberg_TDP[2]);
    
    	// docking port definitions
    	SetDockParams (Heisenberg_DOCK_POS, Heisenberg_DOCK_DIR, Heisenberg_DOCK_ROT);
    
    	// airfoil definitions
    	CreateAirfoil3 (LIFT_VERTICAL,   Heisenberg_COP, vlift, NULL, Heisenberg_VLIFT_C, Heisenberg_VLIFT_S, Heisenberg_VLIFT_A);
    	CreateAirfoil3 (LIFT_HORIZONTAL, Heisenberg_COP, hlift, NULL, Heisenberg_HLIFT_C, Heisenberg_HLIFT_S, Heisenberg_HLIFT_A);
    
    	// propellant resources
    	PROPELLANT_HANDLE hpr = CreatePropellantResource (Heisenberg_FUELMASS);
    
    	// main engine
    	th_main = CreateThruster (_V(0,0,-772.565), _V(0,0,1), Heisenberg_MAXMAINTH, hpr, Heisenberg_ISP);
    	CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
    	AddExhaust (th_main, 8, 10, _V(0,0.3,-772.565), _V(0,0,-1));
    
    	PARTICLESTREAMSPEC contrail_main = {
    		0, 32, 16, 1500, 0.1, 0.1, 6, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
    		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 4,
    		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
    	};
    	PARTICLESTREAMSPEC exhaust_main = {
    		0, 8.0, 10, 150, 0.1, 0.2, 16, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
    		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
    		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
    	};
    	AddExhaustStream (th_main, _V(0,0.3,-10), &contrail_main);
    	AddExhaustStream (th_main, _V(0,0.3,-5), &exhaust_main);
    
    	// hover engine
    	th_hover = CreateThruster (_V(0,-5.197,-716.228), _V(0,1,0), Heisenberg_MAXHOVERTH, hpr, Heisenberg_ISP);
    	CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);
    	AddExhaust (th_hover, 8, 1, _V(0,-5.197,-716.228), _V(0,-1,0));
    	AddExhaust (th_hover, 8, 1, _V(0,-5.197,-716.228), _V(0,-1,0));
    
    	PARTICLESTREAMSPEC contrail_hover = {
    		0, 8, 256, 8, 0.8, 12, 4, 24, PARTICLESTREAMSPEC::EMISSIVE,
    		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
    		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
    	};
    	PARTICLESTREAMSPEC exhaust_hover = {
    		0, 8, 4, 12, 2, 2, 32, 16, PARTICLESTREAMSPEC::EMISSIVE,
    		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
    		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
    	};
    
    	AddExhaustStream (th_hover, _V(0,-3, 1), &contrail_hover);
    	AddExhaustStream (th_hover, _V(0,-3,-1), &contrail_hover);
    	AddExhaustStream (th_hover, _V(0,-2, 1), &exhaust_hover);
    	AddExhaustStream (th_hover, _V(0,-2,-1), &exhaust_hover);
    
    	// camera parameters
    	SetCameraOffset (_V(0,10.628,769.547));
    
    	// associate a mesh for the visual
    	AddMesh ("Heisenberg\Heisenberg");
    }
    
    // ==============================================================
    // Airfoil lift/drag functions
    // ==============================================================
    
    void Heisenberg::vlift (VESSEL *v, double aoa, double M, double Re,
    	void *context, double *cl, double *cm, double *cd)
    {
    	static const double clp[] = {  // lift coefficient from -pi to pi in 10deg steps
    		-0.1,-0.5,-0.4,-0.1,0,0,0,0,0,0,0,0,0,0,-0.2,-0.6,-0.6,-0.4,0.2,0.5,0.9,0.8,0.2,0,0,0,0,0,0,0,0,0,0.1,0.4,0.5,0.3,-0.1,-0.5
    	};
    	static const double aoa_step = 10.0*RAD;
    	double a, fidx, saoa = sin(aoa);
    	a = modf((aoa+PI)/aoa_step, &fidx);
    	int idx = (int)(fidx+0.5);
    	*cl = clp[idx]*(1.0-a) + clp[idx+1]*a;     // linear interpolation
    	*cm = 0.0; //-0.03*sin(aoa-0.1);
    	*cd = 0.03 + 0.4*saoa*saoa;                // profile drag
    	*cd += oapiGetInducedDrag (*cl, 1.0, 0.5); // induced drag
    	*cd += oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04);  // wave drag
    }
    
    void Heisenberg::hlift (VESSEL *v, double aoa, double M, double Re,
    	void *context, double *cl, double *cm, double *cd)
    {
    	static const double clp[] = {  // lift coefficient from -pi to pi in 45deg steps
    		0,0.4,0,-0.4,0,0.4,0,-0.4,0,0.4
    	};
    	static const double aoa_step = 45.0*RAD;
    	double a, fidx;
    	a = modf((aoa+PI)/aoa_step, &fidx);
    	int idx = (int)(fidx+0.5);
    	*cl = clp[idx]*(1.0-a) + clp[idx+1]*a;     // linear interpolation
    	*cm = 0.0;
    	*cd = 0.03;
    	*cd += oapiGetInducedDrag (*cl, 1.5, 0.6); // induced drag
    	*cd += oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04);  // wave drag
    }
    
    // ==============================================================
    // API callback interface
    // ==============================================================
    
    // --------------------------------------------------------------
    // Vessel initialisation
    // --------------------------------------------------------------
    DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
    {
    	return new Heisenberg (hvessel, flightmodel);
    }
    
    // --------------------------------------------------------------
    // Vessel cleanup
    // --------------------------------------------------------------
    DLLCLBK void ovcExit (VESSEL *vessel)
    {
    	if (vessel) delete (Heisenberg*)vessel;
    }
    Posted 11-14-2010 at 07:19 PM by IgnoreThisBarrel IgnoreThisBarrel is offline
  8. Old Comment
    I dont think its being placd in the modules folder...I faced this problem with the new Orbiter samples...all the paths are setup to point to C:\source\Oribiter.......look inside this to see if you can find your project module....also check in your orbiter installation folder to see if your module is present
    Posted 11-16-2010 at 01:24 AM by dumbo2007 dumbo2007 is offline
 

All times are GMT. The time now is 06:27 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.