Hello,
Still on the Tianwen Mars project, I'm trying to spawn the parts jettisoned by the lander during the descent (shell and parachute, heatshield...). So I searched for a code sample doing this and I came with the below piece of code. It sort of works, but it seems it isn't accurate enough. The discarded vessel is created like 10 meters above my lander, and it seems tilted at a 90° angle. I'd expect it to spawn exactly where my vessel is, and oriented the same way. Right now, it looks crappy. So, what am I missing there ? ? My lander is oriented like a capsule, -Z axis is towards the heatshield +Z axis is towards the parachute. It is a rather small vessel so I don't see where that 10 meters (or more) offset is coming from...
Still on the Tianwen Mars project, I'm trying to spawn the parts jettisoned by the lander during the descent (shell and parachute, heatshield...). So I searched for a code sample doing this and I came with the below piece of code. It sort of works, but it seems it isn't accurate enough. The discarded vessel is created like 10 meters above my lander, and it seems tilted at a 90° angle. I'd expect it to spawn exactly where my vessel is, and oriented the same way. Right now, it looks crappy. So, what am I missing there ? ? My lander is oriented like a capsule, -Z axis is towards the heatshield +Z axis is towards the parachute. It is a rather small vessel so I don't see where that 10 meters (or more) offset is coming from...
C++:
void TIANWEN_LANDER::SpawnObject(void)
{
VESSELSTATUS2 vs;
vs.flag = 0;
vs.version = 2;
char name[256];
VECTOR3 sofs = { 0, 0, 0 }; // Seperation offset
VECTOR3 sdir = { 0, 0, 1 }; // Seperation direction
double svel = 0; // Separation velocity[/COLOR]
// Get vessel status structure
VECTOR3 rofs;
GetStatusEx(&vs);
Local2Rel(sofs, vs.rpos);
GlobalRot(sdir, rofs);
vs.rvel += rofs * svel;
// Create descent stage as seperate vessel
strcpy(name, GetName());
strcat(name, "-Shell");
oapiCreateVesselEx(name, "Tianwen_shell", &vs);
}