glpoint.h

Go to the documentation of this file.
00001 #ifndef GLPOINT_H
00002 #define GLPOINT_H
00003 /* ============================================================================
00004 'glpoint.h' defines a class used to maintain vertices and associated texture
00005 coordinates.
00006 
00007 Written by Nicholas Phillips.
00008 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007.
00009 ============================================================================ */
00010 /*
00011                         Fetch header files.
00012 */
00013 #include <vector>
00014 #include <QGLViewer/qglviewer.h>
00015 
00016 using namespace std;
00017 /* ============================================================================
00018 'GLPoint' maintains the an OpenGL vertex and its associated texture coordinates.
00019 Note:  it is defined entirely inline.
00020 ============================================================================ */
00021 class GLPoint 
00022 {
00023 public:
00024         float x,y,z;
00025         float s,t;
00026 public:
00027         GLPoint(void);
00028         void setVertC(double x_, double y_, double z_);
00029         void setVertS(double theta, double phi, double rad = 1.);
00030         void setTex(double s_, double t_);
00031         void glSet();
00032 };
00033 /* ----------------------------------------------------------------------------
00034 'GLPoint' defines an empty instance.
00035 
00036 Arguments:
00037         None.
00038 
00039 Returned:
00040         Nothing.
00041 
00042 Written by Nicholas Phillips.
00043 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007.
00044 ---------------------------------------------------------------------------- */
00045 inline GLPoint::GLPoint() : x(0.), y(0.), z(0.), s(0.), t(0.)
00046 { 
00047 }
00048 /* ----------------------------------------------------------------------------
00049 'setVertC' defines a vertex's 3D coordinates.
00050 
00051 Arguments:
00052         x,y,z - Its 3D world cartesian coordinates.
00053 
00054 Returned:
00055         Nothing.
00056 
00057 Written by Nicholas Phillips.
00058 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007.
00059 ---------------------------------------------------------------------------- */
00060 inline void GLPoint::setVertC(double x_, double y_, double z_) 
00061 { 
00062         x = x_; 
00063         y = y_; 
00064         z = z_;
00065 }
00066 /* ----------------------------------------------------------------------------
00067 'setVertS' defines a vertex's 3D coordinates.
00068 
00069 Arguments:
00070         theta - The colatitude, measured from the North Pole in radians.
00071         phi   - The longitude in radians.
00072         rad   - The radius of the sphere.  Defaults to 1.
00073 
00074 Returned:
00075         Nothing.
00076 
00077 Written by Nicholas Phillips.
00078 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007.
00079 ---------------------------------------------------------------------------- */
00080 inline void GLPoint::setVertS(double theta, double phi, double rad) 
00081 { 
00082         x = rad * cos(phi) * sin(theta); 
00083         y = rad * sin(phi) * sin(theta); 
00084         z = rad * cos(theta);
00085 }
00086 /* ----------------------------------------------------------------------------
00087 'setTex' defines a vertex's texture coordinates.
00088 
00089 Arguments:
00090         s,t - The texture coordinates.
00091 
00092 Returned:
00093         Nothing.
00094 
00095 Written by Nicholas Phillips.
00096 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007.
00097 ---------------------------------------------------------------------------- */
00098 inline void GLPoint::setTex(double s_, double t_) 
00099 { 
00100         s = s_; 
00101         t = t_; 
00102 }
00103 /* ----------------------------------------------------------------------------
00104 'glSet' inserts the vertex into the OpenGL system.
00105 
00106 Arguments:
00107         None.
00108 
00109 Returned:
00110         Nothing.
00111 
00112 Written by Nicholas Phillips.
00113 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007.
00114 ---------------------------------------------------------------------------- */
00115 inline void GLPoint::glSet()
00116 { 
00117         glTexCoord2f( s,t); 
00118         glVertex3f( x, y, z); 
00119 }
00120 /* ============================================================================
00121 Associated typedefs.
00122 ============================================================================ */
00123 typedef std::vector<GLPoint> GLVertices;
00124 typedef GLVertices::iterator GLVertI;
00125 
00126 typedef std::vector<GLVertices> GLVertVec;
00127 typedef GLVertVec::iterator GLVertVI;
00128 
00129 typedef GLVertVec GLVertList;
00130 typedef GLVertVI GLVertLI;
00131 #endif

Generated on Fri Feb 6 15:32:42 2009 for Skyviewer by  doxygen 1.4.7