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

RAS_MaterialBucket.cpp

Go to the documentation of this file.
00001 #pragma warning (disable:4786)
00002 
00003 #include "RAS_MaterialBucket.h"
00004 
00005 #ifdef WIN32
00006 #include <windows.h>
00007 #endif // __WIN32
00008 
00009 #include <GL/gl.h>
00010 
00011 #include "RAS_Polygon.h"
00012 #include "RAS_TexVert.h"
00013 #include "RAS_IRasterizer.h"
00014 #include "RAS_IRenderTools.h"
00015 #include "RAS_MeshObject.h"
00016 
00017 
00018 void * RAS_IPolyMaterial::m_sCachingInfo =NULL;
00019 
00020 
00021 bool RAS_MaterialBucket::IsTransparant()

00022 {       
00023         return (m_material->IsTransparant());
00024 }
00025 
00026 
00027 // some static caching variables, to minimize OpenGL state-switches
00028 static int lastusedlights = -1;
00029 static bool lastdolights;
00030 static int UseLights=0;
00031 static bool vertexcoordson = false;
00032 
00033 
00034 
00035 
00036 void RAS_MaterialBucket::StartFrame()

00037 {
00038 
00039 
00040         lastusedlights = -1;
00041         lastdolights = false;
00042         UseLights = 0;
00043         glPushMatrix();
00044         vertexcoordson=false;
00045         
00046 
00047 
00048 }
00049 void RAS_MaterialBucket::EndFrame()

00050 {
00051         glPopMatrix();
00052 
00053 }
00054 
00055 
00056 
00057 //extern void BL_RenderText(int mode,const char* textstr,int textlen,struct TFace* tface,
00058 //                                 float v1[3],float v2[3],float v3[3],float v4[3]);
00059 
00060 void RAS_MaterialBucket::Render(const MT_Transform & cameratrans,RAS_IRasterizer* rasty,RAS_IRenderTools* rendertools)

00061 {
00062 
00063         //if (!m_bScheduled)
00064         //      return;
00065         
00066         // blender function to set OpenGL material
00067         
00068         if (m_meshSlots.begin()== m_meshSlots.end())
00069                 return;
00070                 
00071         rendertools->SetViewMat(cameratrans);
00072         m_material->ActivateMaterial(rasty);
00073         
00074         if (m_meshSlots.size() >0)
00075         {
00076                 
00077                 rendertools->SetClientObject((*m_meshSlots.begin()).m_clientObj);
00078         }
00079                         
00080         if ((rasty->GetDrawingMode() <= RAS_IRasterizer::KX_SOLID) || !m_dolights)
00081         {
00082                 glDisable(GL_LIGHTING);
00083                 glDisable(GL_COLOR_MATERIAL);
00084                 glDisableClientState(GL_NORMAL_ARRAY);
00085         } else
00086         {
00087                 
00088                 bool bUseLights = rendertools->ProcessLighting(m_material->GetLightLayer());
00089         }
00090 
00091         int drawmode = (rasty->GetDrawingMode()  < RAS_IRasterizer::KX_SOLID ?  1:      (m_bUseTriangles ? 0 : 2));
00092         
00093         
00094         
00095         for (set<KX_MeshSlot>::const_iterator it = m_meshSlots.begin();
00096         ! (it == m_meshSlots.end());it++)
00097         {
00098                 if ((*it).m_bVisible)
00099                 {
00100 
00101                         rendertools->SetClientObject((*it).m_clientObj);
00102                                                 
00103                         rendertools->applyTransform(rasty,(*it).m_OpenGLMatrix,m_material->GetDrawingMode());
00104                         rasty->IndexPrimitives(
00105                                         (*it).m_mesh->GetVertexCache(m_material), 
00106                                         (*it).m_mesh->GetIndexCache(m_material), 
00107                                         drawmode,
00108                                         m_material,
00109                                         rendertools // needed for textprinting on polys
00110                                         );
00111                 
00112                 }
00113                 
00114         }
00115         
00116 }
00117 
00118 

Generated at Thu Feb 1 13:03:08 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000