API Question Retrieving distance between CELBODYs

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
10,002
Reaction score
4,418
Points
203
Location
Toulouse
Hello, I fear I'm lost again in the void of virtual space :facepalm:

I'm trying to retrieve from the simulation the distance between :

- The Sun and the Earth
- The Sun and the Moon
- The Earth and the Moon

... and, why not, between two any bodies...

This is of course possible since MFDs do it constantly.

I tried to get the Global vectors of the bodies to get started, but CELBODYs are a special family of objects, so it doesn't work (I have a "no possible conversion between CELBODY and OBJHANDLE error)...

Code:
VECTOR3 Earthpos;
Earth = oapiGetGbodyByName("Earth");
CELBODY * EA = oapiGetCelbodyInterface(Earth);
EA->GetGlobalPos(Earthpos);

I'm trying to determine Earth and Moon shadow cones, and this is going to be a very complex problem I fear... :shifty:

So any help welcome... It's annoying to have a ship coded to overheat because of the Sun heat flux in the shadow of a planet... :dry: :facepalm:

Thanks, :tiphat:
 
The CELBODY class doesn't include the GetGlobalPos function AFAIK.

Why not do this:
Code:
VECTOR3 earthPos;
OBJHANDLE hEarth = oapiGetGbodyByName("Earth");
oapiGetGlobalPos(hEarth, &earthPos);
 
oh so GetGbodyByName returns an OBJHANDLE and not a CELBODY :P

I didn't knew that a planet could be both in the OBJHANDLE and the CELBODY classes

Thanks, it worked ! :thumbup:
 
I didn't knew that a planet could be both in the OBJHANDLE and the CELBODY classes
Every object like GBody, vessel, surface base have defined OBJHANDLE, but they also have their classes (public VESSEL[1|2|3], CELBODY, and private class for surface bases). OBJHANDLE itself isn't a CELBODY nor VESSEL class. They are referenced in the OBJHANDLE, which is a pointer to "object" class.
 
Back
Top