Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound 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 #define SPHERE_RAD 0.1
00023 
00024 class DrawPoint : public DrawObj
00025 {
00026  public:
00027   DrawPoint(Wpt loc=Wpt(0,0,0), Color col=Color::red) : 
00028     DrawObj("DrawPoint_drawobj") 
00029   {
00030     _shininess = CONFIGval("DEFAULT_SHININESS",100,false);
00031     _specular  = Color(CONFIGval("DEFAULT_SPECULAR",
00032                  str_ptr("1.0 1.0 1.0 1.0"),false));
00033     _emission  = Color(CONFIGval("DEFAULT_EMISSION",
00034                  str_ptr("0.2 0.2 0.2 1.0"),false));
00035     _loc = loc;
00036     _color = col;
00037     setSelectable(false);
00038     _sphereRad=SPHERE_RAD;
00039   }
00040   
00041   virtual ~DrawPoint() {}
00042   
00043   void setLoc(Wpt p) { _loc = p; }
00044   void setColor(Color c) { _color = c; }
00045   void reColor(Color c) { _color = c; }
00046 
00047   void drawSphere(Wpt &loc, Color c) {
00048     glColor4fv(c.array());
00049     glPushMatrix();
00050     glMultMatrixd((Wtransf::translation(loc - Origin)).matrix());
00051     // draw a gluSphere
00052     GLUquadricObj *qobj;
00053     qobj = gluNewQuadric();
00054     gluQuadricDrawStyle(qobj, GLU_FILL);
00055     gluQuadricNormals(qobj, GLU_SMOOTH);
00056     gluSphere(qobj,_sphereRad ,10,10);
00057     glPopMatrix();
00058   }
00059 
00060   void setSphereRadius(double rad){
00061     _sphereRad=rad;
00062   }
00063 
00064   void draw() {
00065     // TODO: put this all in a display list
00066     // setup proper rendering states
00067     //glEnable(GL_LIGHTING);
00068     //glEnable(GL_LIGHT0);
00069     //Disable(GL_LIGHTING);
00070     //glShadeModel(GL_SMOOTH);
00071     //glEnable(GL_COLOR_MATERIAL);
00072 
00073     glMaterialf(GL_FRONT_AND_BACK,  GL_SHININESS, _shininess);  
00074     
00075     glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
00076     glColor4fv(_specular.array());
00077     
00078     glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
00079     glColor4fv(_emission.array());
00080 
00081 
00082     glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
00083     
00084     drawSphere(_loc,_color);
00085 
00086     //glDisable(GL_COLOR_MATERIAL);
00087 
00088   }
00089 
00090  protected:
00091   double _sphereRad;
00092   Wpt _loc;
00093   float _shininess;
00094   Color _specular;
00095   Color _emission;
00096   Color _color;
00097 
00098 };
00099 
00100 #endif

Generated on Mon Sep 15 16:27:55 2003 for inspace by doxygen1.2.18