Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Mapping 3D Earth texture on gluSphere to form ECEF frame

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    26

    Using gluSphere to simulate Earth, problems with radius and rendering

    Greetings all.
    I am a beginner with OpenGL, so I will very much appreciate some help

    I am using this project as a basis for the work I am trying to do. I suppose pasting all that code in the thread is not the best idea, but if needed I can do it.

    I have a set of coordinates of satellites (in kilometers) that I will draw around the gluSphere (Earth). I have problems with rendering when I want to make the radius of the sphere equal to that of Earth in kilometers (6371 km), which I need to do if I want to use the satellite coordinates that I have. I don't see the "Earth" being drawn on the scene even when I try various translations with "glTranslatef(0.0f, 0.0f, -X)".
    What do I need to change in code in order to be able to use "real" kilometeres for distance units in the simulation and see the Earth rendered properly ?

    Thank you very much and kind regards,
    T
    Last edited by thor36; 11-28-2014 at 07:24 PM.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,526
    Quote Originally Posted by thor36 View Post
    What do I need to change in code in order to be able to use "real" kilometeres for distance units in the simulation and see the Earth rendered properly ?
    My first guess is that your far plane is too close. That example uses

    Code :
      gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);

    So if your units are km, anything more than 200 km from the viewpoint will be clipped.

    As well as increasing the far distance, you'll also need to increase the near distance if you don't want the depth resolution to be very coarse for almost the entire scene. Make the near distance as high as you can get away with. If you need to support extreme variations in distance (e.g. having a satellite ten metres in front of the viewpoint, with the earth in the background), you'll need to use multiple passes.

  3. #3
    Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    388
    I have a set of coordinates of satellites (in kilometers) that I will draw around the gluSphere (Earth). I have problems with rendering when I want to make the radius of the sphere equal to that of Earth in kilometers (6371 km), which I need to do if I want to use the satellite coordinates that I have.
    I do a lot of orbital graphics. I strongly suggest you start with a sphere of radius = 1.0 (they use 2.0 in the example). Then scale the satellite cords down by r = 1/6371. An easy way to do this would be to call glScalef (r, r, r) just after the earth sphere is drawn. Put your Draw_Satellites routine after the glScalef call.

    This way you don't have to fuss with the clipping planes. Also, it will be very easy to change the program to adapt to any system of units (nm, ft, etc). All you'd have to do is change the value of r.

    Good luck.
    Last edited by Carmine; 11-29-2014 at 09:12 PM.

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    26
    Thank you both for answers, your suggestion worked GClements.

    Carmine, the scaling idea sounds good but I wonder, will there be no loss of quality and accuracy on image for using such small units ? I somehow imagine that OpenGL will have a harder time drawing with such small numbers and keeping the orbit "lines" nice and in proper ratios. But I don't understand OpenGL too well so of course I may be off course.

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,526
    Quote Originally Posted by thor36 View Post
    will there be no loss of quality and accuracy on image for using such small units ? I somehow imagine that OpenGL will have a harder time drawing with such small numbers and keeping the orbit "lines" nice and in proper ratios. But I don't understand OpenGL too well so of course I may be off course.
    If you're specifying coordinates using floating-point, the magnitude doesn't matter unless you start approaching the range of a single-precision floating-point value (roughly 1.2e-38 to 3.4e+38)

    If you're using fixed-point, the coordinates should be scaled and translated such that the bounds just fit into the fixed-point range, then the inverse transformation applied to convert them back to the original values.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •