dumbo2007
Crazy about real time sims
More perturbations that I am hoping to fix soon 
So with reference to the older thread here :
http://orbiter-forum.com/showthread.php?t=20201
What I am trying to do is set a vessel's position in every simulation step, from another vessel. So here is the code
and here is what happens :
The numbers are present here in the sheet "DefSetState"
https://docs.google.com/spreadsheet/ccc?key=0AhSyPNGmuyAqdGJsc1NfeFZDOHJXRURNVC1WdkJKMVE
and graph looks like :

So with reference to the older thread here :
http://orbiter-forum.com/showthread.php?t=20201
What I am trying to do is set a vessel's position in every simulation step, from another vessel. So here is the code
Code:
//Update position using DefSetStateEx()
VESSELSTATUS2 mystat;
VECTOR3 moonpos, correct_ecliptic_orientation, diff;
memset(&mystat,0,sizeof(VESSELSTATUS2));
mystat.version = 2;
VESSEL* v = oapiGetVesselInterface(oapiGetObjectByName("Dummy"));
v->GetStatusEx(&mystat);
//GetStatusEx(&mystat);
matrixPrintD(pkt->m);
Local2Global( _V(pkt->m[12], pkt->m[13], pkt->m[14]), correct_ecliptic_orientation);
//oapiGetRotationMatrix(mystat.rbody, &mat);
//mystat.rpos = mul(mat, position_wrt_moon_frame);
oapiGetGlobalPos(oapiGetObjectByName("Moon"), &moonpos);
//mystat.status = 1;
diff = relpos - mystat.rpos;
relpos = correct_ecliptic_orientation - moonpos;
mystat.rpos = relpos;
v->DefSetStateEx(&mystat);
and here is what happens :
The numbers are present here in the sheet "DefSetState"
https://docs.google.com/spreadsheet/ccc?key=0AhSyPNGmuyAqdGJsc1NfeFZDOHJXRURNVC1WdkJKMVE
and graph looks like :

Last edited: