Basic Image AlgorithmS Library 2.8.0

SceneGlutPrimitives.cpp

00001 #include "SceneGlutPrimitives.hh"
00002 
00003 #include <Gui/biasgl.h> 
00004 #include <Base/Math/Vector3.hh>
00005 #include <Utils/GlutInitWrapper.hh>
00006 
00007 using namespace BIAS;
00008 using namespace std;
00009 
00010 SceneGlutPrimitives::
00011 SceneGlutPrimitives(){
00012      bTeapot_ = true;       
00013      bCube_ = false;
00014      bIcosahedron_ = false;
00015      bTetrahedron_ = false;
00016      fCubeSize_ =0.3;
00017      fTeapotSize_=0.3;
00018 }
00019 
00020 void SceneGlutPrimitives::
00021 GetBoundingBox(BIAS::Vector3<double> & themin,
00022                BIAS::Vector3<double> & themax)
00023 {
00024   themin = BIAS::Vector3<double>(-fTeapotSize_, -fTeapotSize_, -fTeapotSize_);
00025   themax = BIAS::Vector3<double>(fTeapotSize_, fTeapotSize_, fTeapotSize_);
00026 }
00027 
00028 
00029 void SceneGlutPrimitives::Draw() 
00030 {
00031     BIAS::GlutInitWrapper::GetInstance()->Init();
00032     
00033     float colorBronzeDiff[4] = { 0.8, 0.6, 0.0, 1.0 };
00034     float colorBronzeSpec[4] = { 1.0, 1.0, 0.4, 1.0 };
00035     float colorBlue[4]       = { 0.0, 0.2, 1.0, 1.0 };
00036     float colorBlueSpec[4]   = { 1.0, 1.0, 0.2, 1.0 };
00037     float colorNone[4]       = { 0.0, 0.0, 0.0, 0.0 };
00038   glMatrixMode(GL_MODELVIEW);
00039   glPushMatrix();
00040   
00041   if(bCube_){
00042     glMaterialfv(GL_FRONT, GL_DIFFUSE, colorBlue);
00043     glMaterialfv(GL_FRONT, GL_SPECULAR, colorNone);
00044     glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
00045     glColor4fv(colorBlue);
00046     
00047     glFrontFace(GL_CW);
00048     glutSolidCube(fCubeSize_);
00049     glFrontFace(GL_CCW);
00050   }
00051   if(bTeapot_){  
00052     glMaterialfv(GL_FRONT, GL_DIFFUSE, colorBronzeDiff);
00053     glMaterialfv(GL_FRONT, GL_SPECULAR, colorBronzeSpec);
00054     glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
00055     glColor4fv(colorBronzeDiff);    
00056 
00057     glFrontFace(GL_CW);
00058     glutSolidTeapot(fTeapotSize_);
00059     glFrontFace(GL_CCW);
00060   }
00061  
00062   if(bIcosahedron_){
00063     glMaterialfv(GL_FRONT, GL_DIFFUSE, colorBronzeDiff);
00064     glMaterialfv(GL_FRONT, GL_SPECULAR, colorBronzeSpec);
00065     glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
00066     glColor4fv(colorBronzeSpec);    
00067     glFrontFace(GL_CW);
00068     glutSolidIcosahedron();
00069     glFrontFace(GL_CCW);
00070   }
00071   if(bTetrahedron_){
00072     glMaterialfv(GL_FRONT, GL_DIFFUSE, colorBronzeDiff);
00073     glMaterialfv(GL_FRONT, GL_SPECULAR, colorBronzeSpec);
00074     glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
00075     glColor4fv(colorBlueSpec);  
00076     glFrontFace(GL_CW);
00077     glutSolidTetrahedron();
00078     glFrontFace(GL_CCW);
00079   }
00080   
00081   glPopMatrix();
00082 }
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends