SDK Question New to addon creation, looking for a good place to start

Tiny_Bob

Addon Developer
Addon Developer
Joined
Sep 21, 2023
Messages
141
Reaction score
107
Points
58
Location
The Valley of Taurus-Littrow
This might be a heavy repeat from another place on the forum, but I am looking to create a custom vessel in orbiter, starting with something simple, just a vessel with attitude control and some simple animations for now. I've worked with with NASSP development (on the mesh-making side), but I've never fully setup a Visual Studio project from scratch to build for Orbiter, so that would be the best starting point. Thanks in advance.
 
Visual Studio 2022 Community Edition is working for me.

From my recent experience what is intimidating are the shiploads of installation options available. For Orbiter 2024 you only need the bare minimum.

You need 'Desktop Development for C++' with the MSVC v143 toolkit. And you should be good to go.

Oh and you need the Debug libraries (orbiter.lib, orbitersdk.lib...) that are available on the Orbiter Github. They are from Feb 2025.
 
i remember having to include directories and such to get it to build, how does that work and what all do i need to include?
 
i remember having to include directories and such to get it to build, how does that work and what all do i need to include?
You need to include the "Orbitersdk/include" folder, and then link to "orbiter.lib" and "Orbitersdk.lib", located in "Orbitersdk/lib".
 
Oh, and set the "Output Directory" to the Modules folder, so you don't have to copy the dll when you build it.
 
I still find this one useful, it covers the essentials. Would be great if someone made an updated version.

 
For actually programming an addon, it's really helpful to understand the callback functions and how the they're called in the Orbiter internal update loop. The addon/API documentation is super helpful.
 
This might be a heavy repeat from another place on the forum, but I am looking to create a custom vessel in orbiter, starting with something simple, just a vessel with attitude control and some simple animations for now. I've worked with with NASSP development (on the mesh-making side), but I've never fully setup a Visual Studio project from scratch to build for Orbiter, so that would be the best starting point. Thanks in advance.
My experience was as follows:

- Studying simple examples
I started by modifying the ShuttlePB code, making small changes and recompiling. You can find the ShuttlePB code at Orbiter/Orbitersdk/samples/ShuttlePB/ShuttlePB.cpp

C++:
// Copyright (c) Martin Schweiger
// Licensed under the MIT License

// ==============================================================
//                 ORBITER MODULE: ShuttlePB
//                  Part of the ORBITER SDK
//
// ShuttlePB.cpp
// Control module for ShuttlePB vessel class
//
// Notes:
// This is an example for a "minimal" vessel implementation which
// only overloads the clbkSetClassCaps method to define vessel
// capabilities and otherwise uses the default VESSEL class
// behaviour.
// ==============================================================

#define STRICT
#define ORBITER_MODULE

#include "orbitersdk.h"

// ==============================================================
// Some vessel parameters
// ==============================================================
const double  PB_SIZE       = 3.5;             // mean radius [m]
const VECTOR3 PB_CS         = {10.5,15.0,5.8}; // x,y,z cross sections [m^2]
const VECTOR3 PB_PMI        = {2.28,2.31,0.79};// principal moments of inertia (mass-normalised) [m^2]
const VECTOR3 PB_RD         = {0.025,0.025,0.02};//{0.05,0.1,0.05};  // rotation drag coefficients
const double  PB_EMPTYMASS  = 500.0;           // empty vessel mass [kg]
const double  PB_FUELMASS   = 750.0;           // max fuel mass [kg]

...

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

    // physical vessel parameters
    SetSize (PB_SIZE);
    SetEmptyMass (PB_EMPTYMASS);
    SetPMI (PB_PMI);
    SetCrossSections (PB_CS);
    SetRotDrag (PB_RD);
    SetTouchdownPoints (tdvtx, ntdvtx);

    // docking port definitions
    SetDockParams (PB_DOCK_POS, PB_DOCK_DIR, PB_DOCK_ROT);

    // airfoil definitions
    CreateAirfoil3 (LIFT_VERTICAL,   PB_COP, vlift, NULL, PB_VLIFT_C, PB_VLIFT_S, PB_VLIFT_A);
    CreateAirfoil3 (LIFT_HORIZONTAL, PB_COP, hlift, NULL, PB_HLIFT_C, PB_HLIFT_S, PB_HLIFT_A);

    // control surface animations
    UINT anim_Laileron = CreateAnimation (0.5);
    UINT anim_Raileron = CreateAnimation (0.5);
    UINT anim_elevator = CreateAnimation (0.5);
    AddAnimationComponent (anim_Laileron, 0, 1, &trans_Laileron);
    AddAnimationComponent (anim_Raileron, 0, 1, &trans_Raileron);
    AddAnimationComponent (anim_elevator, 0, 1, &trans_Lelevator);
    AddAnimationComponent (anim_elevator, 0, 1, &trans_Relevator);

    // aerodynamic control surface defintions
    CreateControlSurface (AIRCTRL_ELEVATOR, 1.5, 0.7, _V( 0,0,-2.5), AIRCTRL_AXIS_XPOS, anim_elevator);
    CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, _V( 1,0,-2.5), AIRCTRL_AXIS_XPOS, anim_Laileron);
    CreateControlSurface (AIRCTRL_AILERON, 1.5, 0.25, _V(-1,0,-2.5), AIRCTRL_AXIS_XNEG, anim_Raileron);

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

    // main engine
    th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, PB_ISP);
    CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);
    AddExhaust (th_main, 8, 1, _V(0,0.3,-4.35), _V(0,0,-1));

    PARTICLESTREAMSPEC contrail_main = {
        0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
        PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
        PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
    };
    PARTICLESTREAMSPEC exhaust_main = {
        0, 2.0, 20, 200, 0.05, 0.1, 8, 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,-1.5,0), _V(0,1,0), PB_MAXHOVERTH, hpr, PB_ISP);
    CreateThrusterGroup (&th_hover, 1, THGROUP_HOVER);
    AddExhaust (th_hover, 8, 1, _V(0,-1.5,1), _V(0,-1,0));
    AddExhaust (th_hover, 8, 1, _V(0,-1.5,-1), _V(0,-1,0));

    PARTICLESTREAMSPEC contrail_hover = {
        0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
        PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
        PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
    };
    PARTICLESTREAMSPEC exhaust_hover = {
        0, 2.0, 10, 200, 0.05, 0.05, 8, 1.0, 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,0.8,0));

    // associate a mesh for the visual
    AddMesh ("ShuttlePB");
}
The three dots (...) were added by me to indicate that there is more code, but since this is a short example I will omit them.

Then I thought about what I would like to add, remove, or change to play with the variables. For example, a ShuttlePB so lightweight that the wind could carry it away, barely using any fuel.
Next, I started studying animation examples like the Hubble Space Telescope. You can find the HST source code at Orbitersdk/samples/hst/HST.cpp
Finally, I decided that my first add-on would be a 3D model of the Luna3 Probe :probe:with a simple camera lens opening animation.

In my case, I started with Orbiter Linux for convenience, but the process is just as simple on Windows, and the code is easily portable from Windows to Linux and vice versa.
I'm not, nor do I consider myself to be, a good programmer; I just do it for fun and out of curiosity. And I can assure you that learning C++ programming is a wonderful journey.

The Orbiter-Forum community is excellent and has helped me solve many problems. Don't hesitate to ask questions. It's a wonderful community.
And there are also online resources like LearnCpp that can be incredibly helpful.
https://www.learncpp.com/

Note on using AI chatbots: it's a double-edged sword, I'm telling you from experience. Don't ask it to program for you; instead, it's better to read and ask questions in the Orbiter Forum. And only use AI to resolve minor doubts.
AI is a machine, and as such, it fails, especially in this world of corporate greed that prioritizes quick results over quality. Sometimes it invents things out of thin air that don't correspond to the Orbiter SDK or reality.

To be honest, I use it, but in the following way, for example:

Me: "I need a variable-sized array, what C++ library can I use?"
ChatGPT: "You can use std::vector. For example..."

Then I look for information on LearnCpp or CPlusPlus.com.

For example:
https://cplusplus.com/reference/vector/vector/
https://www.learncpp.com/cpp-tutorial/introduction-to-stdvector-and-list-constructors/

Regarding compilation, I use CMake on Linux and Windows. I find it easier, and it even generates a Visual Studio .sln file that you can open and use for debugging (if you have VS Community installed).
You can find more information here:
https://www.orbiter-forum.com/threa...-compile-orbiter-add-ons-my-experience.41842/
 
yeah we have started to transition to CMake for NASSP stuff. it that easy to setup? i made some lists files for the few things i contribute that are actually code related, but again never from scratch
 
yeah we have started to transition to CMake for NASSP stuff. it that easy to setup? i made some lists files for the few things i contribute that are actually code related, but again never from scratch
I think so, yes, CMake is easy to use. IMHO.
You have to follow a few rules to write a CMakeLists.txt file and then run the build command. Most of the mistakes I've made in CMake have been due to not paying enough attention and being a bit clumsy. But once you have a basic CMakeLists.txt file, filling it in is easy.
 
Back
Top