Difference between revisions of "Vessel code"
Line 20: | Line 20: | ||
===Example Code=== | ===Example Code=== | ||
+ | <pre><nowiki> | ||
#define ORBITER_MODULE | #define ORBITER_MODULE | ||
Line 85: | Line 86: | ||
{ | { | ||
} | } | ||
+ | </nowiki> | ||
+ | </pre> | ||
==Functions in your *.h file== | ==Functions in your *.h file== |
Revision as of 16:12, 25 July 2005
Introduction
--- THIS IS WORK IN PROGRESS ---
This is a quick guide to create your own vessel dll with VC++. It's not suited for newbees to c++. If you are new to orbiter, make a config based vessel first, or one based on vinkas spacecraft.dll or spacecraft2.dll. You will find here wich API functions are necessary to get a project running. This is basically just a very cut down version from one of the sample ships included in Orbiter SDK.
Adding Files to your Project
After you have set up the compiler, it's time to start setting up the actual code.
Try to settle on a name for your vessel class first. Dont choose "testship" or "spacecraft". Try a unique name, like "ProtonLV", "HeavyCruiserHC" or whatever suits you. Save the project under that name and add the following two files (with your vessels name)
- Source *.cpp file
- Header *.h file
Example: "ProtonLV.cpp" and "ProtonLV.h"
Functions in your *.cpp file
The following text is a template for a *.cpp file. If you replace all the "Template" with your Vessel Class name (caution: use find and replace with case sensitive selected).
Example Code
#define ORBITER_MODULE #include "Template.h" void VLiftCoeff (double aoa, double M, double Re, double *cl, double *cm, double *cd) { } void HLiftCoeff (double beta, double M, double Re, double *cl, double *cm, double *cd) { } Template::Template (OBJHANDLE hObj, int fmodel) : VESSEL2 (hObj, fmodel) { } Template::~Template () { } void Template::clbkSetClassCaps (FILEHANDLE cfg) { } void Template::clbkLoadStateEx (FILEHANDLE scn, void *vs) { } void Template::clbkSaveState (FILEHANDLE scn) { } void Template::clbkPreStep (double simt, double simdt, double mjd) { } void Template::clbkPostStep (double simt, double simdt, double mjd) { } int Template::clbkConsumeBufferedKey (DWORD key, bool down, char *kstate) { } DLLCLBK void InitModule (HINSTANCE hModule) { } DLLCLBK void ExitModule (HINSTANCE hModule) { } DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel) { } DLLCLBK void ovcExit (VESSEL *vessel) { }
Functions in your *.h file
The following text is a template for a *.h file. If you replace all the "Template" with your Vessel Class name (caution: use find and replace with case sensitive selected)
Example Code
- ifndef __TEMPLATE_H
- define __TEMPLATE_H
- define STRICT
- include "orbitersdk.h"
class Template: public VESSEL2 { public: Template (OBJHANDLE hObj, int fmodel); ~Template (); void clbkLoadStateEx (FILEHANDLE scn, void *vs); void clbkSaveState (FILEHANDLE scn); int clbkConsumeBufferedKey (DWORD key, bool down, char *kstate); void clbkSetClassCaps (FILEHANDLE cfg); void clbkPreStep (double simt, double simdt, double mjd); void clbkPostStep (double simt, double simdt, double mjd);
};
- endif