Many newcomers to Orbiter 2016 have issue keeping vessels landed on the ground, especially when using time warp and designing addons. It was seen as a bug, as the "infamous bouncing dance", and probably kept a lot of people away from O2016. Those days are over. Jarmonik and Face have recently discovered what was an "hidden feature", an undocumented trick used by Martins to keep vessels landed. Being myself and addon developer I think this is quite a breakthrough so that I want to share this.
It requires using a custom .dll module, but could certainly be implemented as "Parking Brake MFD" or something like that. That would be quite an useful addon.
The major difficulty is to understand how Orbiter deals with coordinates on a Planet (any celestial body in fact) surface. In the scenarios, you can enter longitude/latitude coordinates in decimal degrees ; any decent real-life map app, navigation or GPS system features that. Easy. Now this is a simplification Martins did for us, because Orbiter's core deals with Polar Coordinates. Accurate Polar Coordinates are more difficult to get because they involve Earth's rotation. But, luckily for us, Orbiter can compute celestial mechanics very well (that's the point of it !). So we'll use Orbiter to get those coordinates.
Note : those Polar Coordinates are expressed in RADIANS ; remember that Orbiter's core defines all angles in RADIANS (RAD).
So here's a little walkthrough :
1) Use a scenario file (or the Scenario Editor) to spawn a vessel exactly where you want to go. Here you enter coordinates in Decimal Degrees (DEG). Careful about the +/-, it means East/West North/South.
2) Pause, so that you'll sure the vessel won't move at all.
3) Open the Scenario Editor.
4) Select your vessel, click "Edit"
5) Click "State Vectors"
6) Switch "Frame" to "ref. equator (rotating)" (remember we have to consider Earth's rotation).
7) Switch "Coordinates" to "Polar"
8) Note the "longitude" and "latitude" values, with all the digits, this is important for something like a launchpad.
9) Convert those values from DEG to RAD. You can use a site like Wolfram Alpha (https://www.wolframalpha.com/) for that. Or a good ol' SI calculator if you have one.
10) Enter those values in RAD in the "v.surf_lng" (longitude) and "v.surf_lat" (latitude) fields of the code sample below and compile, of course.
11) Done ! Your Vessel won't move at all even at max time warp.
12) Be creative, now you can do cool stuff like complex animated surface bases made of .dll modules !
It requires using a custom .dll module, but could certainly be implemented as "Parking Brake MFD" or something like that. That would be quite an useful addon.
The major difficulty is to understand how Orbiter deals with coordinates on a Planet (any celestial body in fact) surface. In the scenarios, you can enter longitude/latitude coordinates in decimal degrees ; any decent real-life map app, navigation or GPS system features that. Easy. Now this is a simplification Martins did for us, because Orbiter's core deals with Polar Coordinates. Accurate Polar Coordinates are more difficult to get because they involve Earth's rotation. But, luckily for us, Orbiter can compute celestial mechanics very well (that's the point of it !). So we'll use Orbiter to get those coordinates.
Note : those Polar Coordinates are expressed in RADIANS ; remember that Orbiter's core defines all angles in RADIANS (RAD).
So here's a little walkthrough :
1) Use a scenario file (or the Scenario Editor) to spawn a vessel exactly where you want to go. Here you enter coordinates in Decimal Degrees (DEG). Careful about the +/-, it means East/West North/South.
2) Pause, so that you'll sure the vessel won't move at all.
3) Open the Scenario Editor.
4) Select your vessel, click "Edit"
5) Click "State Vectors"
6) Switch "Frame" to "ref. equator (rotating)" (remember we have to consider Earth's rotation).
7) Switch "Coordinates" to "Polar"
8) Note the "longitude" and "latitude" values, with all the digits, this is important for something like a launchpad.
9) Convert those values from DEG to RAD. You can use a site like Wolfram Alpha (https://www.wolframalpha.com/) for that. Or a good ol' SI calculator if you have one.
10) Enter those values in RAD in the "v.surf_lng" (longitude) and "v.surf_lat" (latitude) fields of the code sample below and compile, of course.
11) Done ! Your Vessel won't move at all even at max time warp.
12) Be creative, now you can do cool stuff like complex animated surface bases made of .dll modules !
C++:
// Original code by Jarmonik
void YOURVESSEL::clbkPreStep(double simt, double simdt, double mjd)
{
OBJHANDLE h_Planet;
h_Planet = oapiGetGbodyByName("Earth"); // enter the name of the planet/moon you want
OBJHANDLE h_yourvessel = GetHandle();
VESSEL *v_yourvessel = oapiGetVesselInterface(h_yourvessel);
VESSELSTATUS2 vs;
memset(&vs, 0, sizeof(vs));
vs.version = 2;
vs.rbody = h_Planet;
vs.status = 1; // Landed
vs.arot.x = 10; // <----- Undocumented feature "magic value" to land on touchdown points !! IMPORTANT !! It has to be 10, no more, no less !
vs.surf_lng = 1.9364618; // example : Wenchang Satellite Center, PRC
vs.surf_lat = 0.3423356;
vs.surf_hdg = 0.0;
v_yourvessel->DefSetStateEx(&vs);
}
Last edited: