...another vessel. looks like I breached the allowed number of characters for the title :shifty:
I need to spawn a vessel at a position relative to an already existing vessel. I figured this should be fairly trivial (at least the position, we'll see about the orientation later... :shifty given Orbiter provides the frame conversions, but since my results aren't even close to what I expected, I must assume that I have a fundamental misunderstanding somewhere.
Here's my current code to create the VESSELSTATUS2 struct (pos is the position relative to the vessel at which the new vessel should spawn, vessel is obviously a pointer to the vessel itself):
It seems like the most obvious use of the provided conversions, but the newly spawned vessel ends up nowhere near where I intended it to.
I have checked in clbkSetStateEx that the status received is the same as what's being sent, and yes, I am calling the method on the subclass, so that's the two most obvious problems I could think of out of the way.
I need to spawn a vessel at a position relative to an already existing vessel. I figured this should be fairly trivial (at least the position, we'll see about the orientation later... :shifty given Orbiter provides the frame conversions, but since my results aren't even close to what I expected, I must assume that I have a fundamental misunderstanding somewhere.
Here's my current code to create the VESSELSTATUS2 struct (pos is the position relative to the vessel at which the new vessel should spawn, vessel is obviously a pointer to the vessel itself):
Code:
VESSELSTATUS2 vs;
memset(&vs, 0, sizeof(vs));
vs.version = 2;
vessel->GetStatusEx(&vs);
//transform relative position to global coordinates
VECTOR3 globalpos;
oapiLocalToGlobal(vessel->GetHandle(), &pos, &globalpos);
//transform them back to coordinates relative to the reference body
VECTOR3 equpos;
oapiGlobalToLocal(vs.rbody, &globalpos, &equpos);
vs.rpos = equpos;
oapiCreateVesselEx("testsplit", _orbiter_data->getClassName().data(), &vs);
It seems like the most obvious use of the provided conversions, but the newly spawned vessel ends up nowhere near where I intended it to.
I have checked in clbkSetStateEx that the status received is the same as what's being sent, and yes, I am calling the method on the subclass, so that's the two most obvious problems I could think of out of the way.
Last edited: