Discussion Flight Visualization in Google Earth

astrosammy

Dash!
Addon Developer
Donator
Joined
Apr 27, 2008
Messages
2,124
Reaction score
0
Points
36
Location
ICAO ID: EDFB
If you look at some of Igels and Thortons add-ons, you'll see how cool it is to see your launches in Google Earth.

I thought that there needs to be a way to do it with all vessels, so I wrote a little Plugin that does this. Currently it is very simple, all trajectories are simple white paths, and vessels on ground are invisible.

I'm sure that there are still many bugs to find, but with my limited C++ skills I didn't find another way.

Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#define[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] STRICT[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#define[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] ORBITER_MODULE[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#define[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] _USE_MATH_DEFINES[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]<orbitersdk.h>[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]<math.h>[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]<stdio.h>[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]FILE *Tdebug;[/SIZE]
[SIZE=2]FILE *TELM;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] vc_written[100];[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PN=0;[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] lon[100][5000];[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] lat[100][5000];[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] speed[100][5000];[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] londeg[100][5000];[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] latdeg[100][5000];[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] alt[100][5000];[/COLOR][/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] bbb = 5;[/COLOR][/SIZE]
[SIZE=2]DLLCLBK [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] InitModule (HINSTANCE hModule)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]Tdebug = fopen([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Tdebug.txt"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"w"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]TELM = fopen([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"TELM.kml"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"w"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]DLLCLBK [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] opcPreStep([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] simt, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] simdt, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] mjd)[/SIZE]
[SIZE=2]{[/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VC;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Vi;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] vname[100][20];[/SIZE]
[SIZE=2]OBJHANDLE OH;[/SIZE]
[SIZE=2]VESSEL * vh;[/SIZE]
 
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//FLIGHT LOOP[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](oapiGetSimTime()>bbb)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]bbb = bbb+1;[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Go through vessel list[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]VC=oapiGetVesselCount();[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](Vi=0;Vi<VC;Vi++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]OH=oapiGetVesselByIndex(Vi);[/SIZE]
[SIZE=2]oapiGetObjectName(OH,vname[Vi],20);[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (vc_written[Vi]!=1)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Vessel name to file, for debug[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]fprintf(Tdebug,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],vname[Vi][0],vname[Vi][1],vname[Vi][2],vname[Vi][3],vname[Vi][4],vname[Vi][5],vname[Vi][6],vname[Vi][7],vname[Vi][8],vname[Vi][9],vname[Vi][10],vname[Vi][11],vname[Vi][12],vname[Vi][13],vname[Vi][14],vname[Vi][15],vname[Vi][16],vname[Vi][17],vname[Vi][18],vname[Vi][19]);[/SIZE]
[SIZE=2]vc_written[Vi]=1; [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//mark vessel read[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]}[/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//Obtain vessel Telemetry[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]vh=oapiGetVesselInterface(OH);[/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](vh->GetGravityRef()==oapiGetObjectByName([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Earth"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]))[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//POSTITON[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]vh->GetEquPos(lon[Vi][PN],lat[Vi][PN],voiddouble);[/SIZE]
[SIZE=2]londeg[Vi][PN]=(lon[Vi][PN]*360)/(2*M_PI);[/SIZE]
[SIZE=2]latdeg[Vi][PN]=(lat[Vi][PN]*360)/(2*M_PI);[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//ALTITUDE[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]alt[Vi][PN]=vh->GetAltitude();[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//SPEED[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]speed[Vi][PN]=vh->GetAirspeed();[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//}[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]}[/SIZE]
[SIZE=2]PN=PN+1;[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]DLLCLBK [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ExitModule (HINSTANCE hModule) [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//use to write file[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] VC,i,j;[/SIZE]
[SIZE=2]VC=oapiGetVesselCount();[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//general GE file creation[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"<Folder>\n\t<name>TEL</name>\n\t<open>1</open>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]); [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//shortened head, only placemarks are required[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]//write placemark, loop[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](i=0;i<VC;i++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\t<Placemark>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\t\t<name>%i</name>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],i);[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\t\t<styleUrl>#msn_ylw-pushpin</styleUrl>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\t\t<LineString>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\t\t\t<tessellate>1</tessellate>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\t\t\t<altitudeMode>relativeToGround</altitudeMode>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\t\t\t<coordinates>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]for[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](j=1;j<PN;j++)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](londeg[i][j]!=0 && latdeg[i][j]!=0)[/SIZE]
[SIZE=2]{[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"%f,%f,%f "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],londeg[i][j],latdeg[i][j],alt[i][j]);[/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"</coordinates>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\t\t</LineString>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"\t</Placemark>\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]fprintf(TELM,[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"</Folder>"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);[/SIZE]
[SIZE=2]}[/SIZE]
[/COLOR][/SIZE][/COLOR][/SIZE]

In the picture you can see a destructive DG-IV entry, with the ISS flying above it.

Place the dll file in your Modules/Plugin folder and activate it in the launch pad.
In the extra tab, you need to change Debugging Options/Orbiter shutdown options to "Terminate Orbiter process".

A txt and a kml file are created inside your Orbiter folder. Once you close Orbiter, open the kml file with Google Earth. Roughly 5000 seconds are recorded, you should close Orbiter before that time is reached and keep time acceleration at a maximum of 10x.
 

Attachments

  • GE_tracker.zip
    102.4 KB · Views: 72
  • IMG.jpg
    IMG.jpg
    259.5 KB · Views: 143
Top