Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

DrawPoint.H

Go to the documentation of this file.
00001 
00010 #ifndef DRAWPOINT_H
00011 #define DRAWPOINT_H
00012 
00013 #include "DrawObj.H"
00014 #include "Color.H"
00015 
00016 #include "glwrap.H"
00017 
00018 // gluebase includes
00019 #define OUTSIDE_GLUE_CORE
00020 #include <config/config.H>
00021 
00022 namespace InSpace {
00023 
00024 #define SPHERE_RAD 0.1
00025 
00026 class DrawPoint : public DrawObj
00027 {
00028  public:
00029   DrawPoint(Wpt loc=Wpt(0,0,0), Color col=Color::red) : 
00030     DrawObj("DrawPoint_drawobj") 
00031   {
00032     _shininess = CONFIGval("DEFAULT_SHININESS",100,false);
00033     _specular  = Color(CONFIGval("DEFAULT_SPECULAR",
00034                  str_ptr("1.0 1.0 1.0 1.0"),false));
00035     _emission  = Color(CONFIGval("DEFAULT_EMISSION",
00036                  str_ptr("0.2 0.2 0.2 1.0"),false));
00037     _loc = loc;
00038     _color = col;
00039     setSelectable(false);
00040     _sphereRad=SPHERE_RAD;
00041   }
00042   
00043   virtual ~DrawPoint() {}
00044   
00045   void setLoc(Wpt p) { _loc = p; }
00046   void setColor(Color c) { _color = c; }
00047   void reColor(Color c) { _color = c; }
00048 
00049   void drawSphere(Wpt &loc, Color c) {
00050     glColor4fv(c.array());
00051     glPushMatrix();
00052     glMultMatrixd((Wtransf::translation(loc - Origin)).matrix());
00053     // draw a gluSphere
00054     GLUquadricObj *qobj;
00055     qobj = gluNewQuadric();
00056     gluQuadricDrawStyle(qobj, GLU_FILL);
00057     gluQuadricNormals(qobj, GLU_SMOOTH);
00058     gluSphere(qobj,_sphereRad ,10,10);
00059     glPopMatrix();
00060   }
00061 
00062   void setSphereRadius(double rad){
00063     _sphereRad=rad;
00064   }
00065 
00066   void draw() {
00067     // TODO: put this all in a display list
00068     // setup proper rendering states
00069     //glEnable(GL_LIGHTING);
00070     //glEnable(GL_LIGHT0);
00071     //Disable(GL_LIGHTING);
00072     //glShadeModel(GL_SMOOTH);
00073     //glEnable(GL_COLOR_MATERIAL);
00074 
00075     glMaterialf(GL_FRONT_AND_BACK,  GL_SHININESS, _shininess);  
00076     
00077     glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
00078     glColor4fv(_specular.array());
00079     
00080     glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
00081     glColor4fv(_emission.array());
00082 
00083 
00084     glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
00085     
00086     drawSphere(_loc,_color);
00087 
00088     //glDisable(GL_COLOR_MATERIAL);
00089 
00090   }
00091 
00092  protected:
00093   double _sphereRad;
00094   Wpt _loc;
00095   float _shininess;
00096   Color _specular;
00097   Color _emission;
00098   Color _color;
00099 
00100 };
00101 
00102 }
00103 
00104 #endif

Generated on Thu Jul 8 15:19:28 2004 for inspace by doxygen 1.3.4