|
From: Samuel C. <sam...@gm...> - 2020-09-03 14:40:29
|
ere is my final goal: Render the earth terrain using OpenGL 2.1 or (ES) and be able to roam through it from GPS coordinates. Here is my current "subgoal": Being able to render to follow GPS data fed by a running flightgear. That is showing what the pilot would see. My problem: I can't get how to render the mesh according to roll/pitch/heading + alt reliably. What I have done so far: --Coordinates I've converted some C++ code to plain C from fg to load btg files and meshes. In these files The documentation (http://wiki.flightgear.org/BTG_file_format) states that all vertices coordinates uses the ECEF. I've choosen to completly ignore the fact that ECEF and OpenGL seems to use a different coordinates system during the loading. My rationale was that there is no need to invert/change vertices coordinates if I rotate everything to get the correct "camera" position. Don't know how wrong I am here. *Up to that point, I'm able to render the terrain and move it with direct OpenGL (x,y,z) rotations/translations mapped to keyboard keys.* The next step was to make it so that given a GPS (lat, lon) position + altitude I could render the terrain as if I was at given alt with heading/pitch/roll equal to 0. I did a lot of trial and error on this and ended up using DSTO–TN–0640 from Don Koks to do that, plus a couple of inital rotations (eyeballed them...) to account from the differences between of XYZ between ECEF and OpenGL. Is that what I am supposed to do? My goal here is to be able to render a terrain mesh as if it was viewed from a plane that have a given heading/pitch/roll, at a lat,lon,alt position. It somehow worked on the location I was testing with (South of France) but was completly off when I tried to replay a flight in KSFO. I couldn't make it work so I went back to France by using a flight someone had recorded and then I ran in my second problem. --Shaking I play a the flight on computer1 telling FlightGear to send gps, speed, alt, etc over the network. Computer2 runs the code I wrote, receives that data and renders from it. While on the ground the rendering is perfect on FlightGear while on compter2 it's like the runway is shaking randomly be the plane static or rolling to take off. The effect stops as the plane starts climbing. I've read that could be caused by the large numbers used as coordinates. I've tried to apply multiple factors on them with no difference. I have a feeling that might be linked to the fact that my whole approach with coordinates is wrong in the first place and result in unwanted micro-rotations while I'm near the mesh. Video of the shaking: https://vimeo.com/454398408 On flightgear (not 100% sync but you get the idea): https://vimeo.com/454399263 Code is there: https://github.com/sam-itt/fg-roam Best, Samuel |