GLIrradCacheRender.cc

Go to the documentation of this file.
00001 #include <gra/camera/CameraGL.h>
00002 #include <esg/energy/PhotonMapEnergy.h>
00003 #include <esg/explorer/ObjsExplorer.h>
00004 #include <gra/render/GLIrradCacheRender.h>
00005 
00006 using namespace gra;
00007 
00008 void GLIrradCacheRender::_render(Shader& shader,
00009                                  FrameBuffer& fb,
00010                                  Camera& camera,
00011                                  Scene& scene)
00012 {
00013   if (_useDisplayList && _displayList) {
00014     glCallList(_displayList);
00015     return;
00016   }
00017 
00018   if (_useDisplayList) {
00019     _displayList = glGenLists(1);
00020     glNewList(_displayList, GL_COMPILE_AND_EXECUTE);
00021   }
00022   
00023   CameraGL cameraGL(camera);
00024 
00025   // perform photon mapping which computes irradiance caches
00026   if (rtrRender) rtrRender->renderScene(shader, fb, camera, scene);
00027 
00028   fb.clearColor(Color3f(0,0,0));
00029 
00030   if (scene.root()) {
00031     ObjsExplorer explorer;
00032     explorer.explore(*(scene.root()));
00033 
00034     SceneGraphObject        * pObj;
00035     Matrix4                   trMat;
00036     bool                      tr;
00037     AutoPtr<EnergyCoat>     * pACoat;
00038     EnergyCoat              * pCoat;
00039     PhotonMapEnergy         * pMap = NULL;
00040     IrradianceCache         * pIrradianceCache;
00041     const IrradianceCache::Value  * pValue;
00042 
00043     while ((pObj = explorer.result(trMat, tr)))
00044     {
00045       if (!(pACoat = pObj->getEnergyState()))              continue;
00046       if (!(pCoat = pACoat->origObject()))                 continue;
00047       if (!(pMap = dynamic_cast<PhotonMapEnergy*>(pCoat))) continue;
00048     }
00049 
00050     if ((pIrradianceCache = pMap->getIrradianceCache())) {
00051         pIrradianceCache->resetValuePointer();
00052 
00053         // vyrenderuje všechny hodnoty z irradiance cache
00054         glColor3f(0.0f, 1.0f, 0.0f);
00055         glBegin(GL_POINTS);
00056         {      
00057             while ((pValue = pIrradianceCache->getNextValuePointer()) != NULL)
00058             {
00059                 glVertex3f( pValue->getPosition().x,
00060                             pValue->getPosition().y,
00061                             pValue->getPosition().z );
00062             }
00063             
00064         } glEnd();
00065     }
00066   }
00067 
00068   if (_useDisplayList) glEndList();
00069   
00070   
00071   glFlush();
00072   glFinish();
00073 }
00074 

Generated on Tue Nov 21 15:11:42 2006 for gra by  doxygen 1.4.6