Sorry, if I messed up with the title, don't know how to say correct this in English. (edited, thanks 2 Keatah)
What I need:
I need to put my Vessel on a line "Earth - Sun" but at the opposite (to Earth) side of Sun.
Vessel ---- SUN ---- Earth
I've tried to do it in such a way:
I try my code with Camera Tool from Orbiter Main Menu.
In the second tab, I choose "Target from ... Sun" and then "Target from ... Earth"
and I got some little changing between these two states. But if I'm on a line Earth-Sun, I shouldn't get changes in these views, but I get.
Why this approach doesn't work? Where is my mistake?
Thank you in advance.
P.S. I've made some corrections in code, and it works now fine. Views "Target from Sun" and "Target from Earth" haven't any error (no difference at all).
But then I'm feeling misunderstanding in theory of Vessel positioning.
Such code works good:
But both earthpos and sunpos are global coordinates. rpos field of state - is local coordinate, isn't it? So setting global coordinates in rpos is fine. But why?
What I need:
I need to put my Vessel on a line "Earth - Sun" but at the opposite (to Earth) side of Sun.
Vessel ---- SUN ---- Earth
I've tried to do it in such a way:
Code:
// Getting handles of Sun and Earth
OBJHANDLE Sun = oapiGetGbodyByName("Sun");
OBJHANDLE Earth = oapiGetGbodyByName("Earth");
// Getting Earth Global position
VECTOR3 earthpos;
oapiGetGlobalPos(Earth, &earthpos);
// Getting handle, instance and status instance of Vessel
VESSELSTATUS vs;
VESSEL2 *pVessel;
OBJHANDLE hVessel = oapiGetVesselByName("UAV");
pVessel = (VESSEL2*)oapiGetVesselInterface ( hVessel );
pVessel->GetStatus(vs);
// Vessel is on Sun's orbit
vs.rbody = Sun;
// Getting Local coordinates of Earth
VECTOR3 local_earthpos;
pVessel->Global2Local(earthpos, local_earthpos);
// If we put our vessel in point '-local_earthpos'
// it should be opposite to Sun, isn't it?
vs.rpos = -local_eartpos;
// Saving Vessel state
pVessel->DefSetState(&vs);
I try my code with Camera Tool from Orbiter Main Menu.
In the second tab, I choose "Target from ... Sun" and then "Target from ... Earth"
and I got some little changing between these two states. But if I'm on a line Earth-Sun, I shouldn't get changes in these views, but I get.
Why this approach doesn't work? Where is my mistake?
Thank you in advance.
P.S. I've made some corrections in code, and it works now fine. Views "Target from Sun" and "Target from Earth" haven't any error (no difference at all).
But then I'm feeling misunderstanding in theory of Vessel positioning.
Such code works good:
Code:
// Getting Sun Global Position
VECTOR3 sunpos;
oapiGetGlobalPos(Sun, &sunpos);
vs.rpos = -earthpos+sunpos;
But both earthpos and sunpos are global coordinates. rpos field of state - is local coordinate, isn't it? So setting global coordinates in rpos is fine. But why?
Last edited: