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

GLUpdaterGLShapeVisitor.cpp

Go to the documentation of this file.
00001 #include "GLUpdaterGLShapeVisitor.h"
00002 #include "GLFillProperties.h"
00003 #include "GLLineProperties.h"
00004 #include "GLMaterial.h"
00005 #include "FillProperties.h"
00006 #include "LineProperties.h"
00007 #include "Material.h"
00008 #include <iostream>
00009 
00010 using namespace X3DTK;
00011 using namespace std;
00012 
00013 GLUpdaterGLShapeVisitor::GLUpdaterGLShapeVisitor()
00014 : GLShapeVisitor()
00015 {
00016   // Enter functions.
00017   defineNewEnterFunction<GLUpdaterGLShapeVisitor, GLFillProperties>(&GLUpdaterGLShapeVisitor::enterGLFillProperties);
00018   defineNewEnterFunction<GLUpdaterGLShapeVisitor, GLLineProperties>(&GLUpdaterGLShapeVisitor::enterGLLineProperties);
00019   defineNewEnterFunction<GLUpdaterGLShapeVisitor, GLMaterial>(&GLUpdaterGLShapeVisitor::enterGLMaterial);
00020 
00021 
00022   // GlobalVariables assignation.
00023   globalVariables = GVManager::getInstanceOf<GLUpdaterGlobalVariables>();
00024 }
00025 
00026 GLUpdaterGLShapeVisitor::~GLUpdaterGLShapeVisitor()
00027 {
00028 }
00029 
00030 void GLUpdaterGLShapeVisitor::enterGLFillProperties(GLFillProperties *G) const
00031 {
00032 }
00033 
00034 void GLUpdaterGLShapeVisitor::enterGLLineProperties(GLLineProperties *G) const
00035 {
00036 }
00037 
00038 void GLUpdaterGLShapeVisitor::enterGLMaterial(GLMaterial *G) const
00039 {
00040   Material *M = static_cast<Material *>(G->getLink());
00041 
00042   SFColor C;
00043   float t = 1.0f - M->getTransparency();
00044   float f = 1.0f - M->getAmbientIntensity();
00045 
00046   C = M->getDiffuseColor();
00047   
00048   G->getDiffuseColor()[0] = C.r;
00049   G->getDiffuseColor()[1] = C.g;
00050   G->getDiffuseColor()[2] = C.b;
00051   G->getDiffuseColor()[3] = t;
00052 
00053   G->getAmbientColor()[0] = f*C.r;
00054   G->getAmbientColor()[1] = f*C.g;
00055   G->getAmbientColor()[2] = f*C.b;
00056   G->getAmbientColor()[3] = t;
00057 
00058   C = M->getEmissiveColor();
00059   
00060   G->getEmissiveColor()[0] = C.r;
00061   G->getEmissiveColor()[1] = C.g;
00062   G->getEmissiveColor()[2] = C.b;
00063   G->getEmissiveColor()[3] = t;
00064 
00065   G->getShininess() = 128.0f*M->getShininess();  
00066 
00067   C = M->getSpecularColor();
00068   
00069   G->getSpecularColor()[0] = C.r;
00070   G->getSpecularColor()[1] = C.g;
00071   G->getSpecularColor()[2] = C.b;
00072   G->getSpecularColor()[3] = t;
00073  
00074 }
00075 

Generated on Wed May 14 10:03:09 2003 for X3DToolKit by doxygen1.3