|
From: James T. <ja...@fl...> - 2020-09-03 19:49:03
|
> On 3 Sep 2020, at 17:49, Samuel CUELLA <sam...@gm...> wrote: > > Now how could I render a terrain tile like if I was flying over it at > say the center, a given altitude with 0 roll (parallel to the earth), 0 > pitch (parallel to the earth) and heading north ? I couldn't find how > FlightGear is doing it. > > The code I have to translate lat,lon alt to X,Y,Z (ECEF) seems to work > (I get the right tile) but then I'm struggling with how position the > "camera" to render the tile as if I was flying as said earlier. Look at places that use SGQuat::fromLonLatRad, SGQuat::fromYawPitchRollDeg and so on in the code, this should help. It does assume you are familiar with quaternions to express rotations, unfortunately. As noted elsewhere, you absolutely have to work in doubles in the intermediate matrices for sufficient precision, and you need to build a view matrix with the camera+world offset combined, so that your final view transformation (which becomes your uniform) does not push the floats into unstable territory. Once you have your combined view matrix as doubles in the CPU, you can work in floats on the GPU side, at least for standard rendering. (You might still need more than floats for various lighting / depth techniques, depending on the view range you want, but that’s a problem for later) Kind regards, James |