[Kstars-devel] OpenGL: the beginning
Jason Harris
kstars at 30doradus.org
Thu Nov 27 19:58:10 CET 2003
Hello,
I have started an OpenGL framework that I plan to evolve into a
replacement for our SkyMap widget. Actually, my plan is to include
both SkyMap and SkyMapGL, and let configure determine which should be
used.
I'm just getting started, but I thought I'd share with you what I have
so far. Get the tarball here:
http://www.30doradus.org/kstars/kglbasic-0.1.tar.gz
Do './configure' and 'make'; there's no need to do 'make install'. The
class KGLWidget is what will eventually be SkyMapGL; KGLWindow is just
a KMainWindow container.
Right now, it just displays the coordinate grid, and you can scroll with
the arrow keys and zoom in/out with the +/- keys. It seems really
smooth on my system, but I have hardware acceleration, so I don't know
how software openGL compares yet.
OpenGL will require some fundamental changes in how we represent objects
in the sky. The paradigm is that you create objects in a cartesian 3D
volume (with X,Y,Z coordinates) and then define a "camera" for
projecting those objects into the 2D window.
For KStars, this means that each object's RA/Dec coordinates will be
converted to X,Y,Z such that each lies on the surface of a "celestial
sphere" in the 3D volume. Once this is done, everything gets much
simpler compared to our current setup. For example, rather than
recalculating every object's pixel coordinates whenever the Focus
position is changed, we simply tell OpenGL that the camera has moved,
and it computes a matrix transformation internally and re-renders the
scene. Also, things like Precession and Nutation can be simplified as
rotational matrix transformations of the fundamental J2000 Celestial
sphere. We don't even need to determine if each object is visible on
the screen; we just define a "clipping volume", and OpenGL takes care
of it (say goodbye to checkVisibility()!). The only calculations we'll
need to do as a function of time are updating the (X,Y,Z) coordinates
of solar system bodies, and of nearby stars (if/when we include proper
motions). Pretty cool.
The KGLWidget::makeObject() function will eventually be where we define
the XYZ coordinates of our objects and how to render them. This
function was copied frm the Qt OpenGL "box" example, but it is not
currently used in kglbasic. Instead, the coordinate grid is defined
with the glutWireSphere() function.
Anyway, let me know what you think.
regards, and Happy Thanksgiving
Jason
--
KStars: A KDE Planetarium
http://edu.kde.org/kstars
More information about the Kstars-devel
mailing list