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

RAS_BucketManager.cpp

Go to the documentation of this file.
00001 
00002 #ifdef WIN32
00003 // don't show these anoying STL warnings
00004 #pragma warning (disable:4786)
00005 #endif
00006 
00007 #include "GEN_Map.h"
00008 #include "RAS_MaterialBucket.h"
00009 #include "KX_HashedString.h"
00010 #include "ListValue.h"
00011 #include "RAS_MeshObject.h"
00012 #define KX_NUM_MATERIALBUCKETS 100
00013 #include "RAS_IRasterizer.h"
00014 
00015 
00016 GEN_Map<RAS_IPolyMaterial,RAS_MaterialBucket*> gMaterialBuckets;
00017 
00018 
00019 
00020 
00021 void KX_Renderbuckets(const MT_Transform & cameratrans,RAS_IRasterizer* rasty  ,float viewdist,
00022                                           RAS_IRenderTools* rendertools)

00023 {
00024         float fov = 1.2f;//1.2;//1.1;
00025 
00026         int coneheight = int(viewdist);
00027         int coneradius = int(fov*coneheight);
00028 
00029         int numbuckets = gMaterialBuckets.size();
00030                 
00031         //default_gl_light();
00032 
00033         int i;
00034         
00035         rasty->EnableTextures(false);
00036         rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
00037         
00038         // beginning each frame, clear (texture/material) caching information
00039         RAS_IPolyMaterial::ClearCachingInfo();
00040 
00041         RAS_MaterialBucket::StartFrame();
00042 
00043         for (i=0;i<numbuckets;i++)
00044         {
00045                 RAS_MaterialBucket** bucketptr = gMaterialBuckets.at(i);
00046                 if (bucketptr)
00047                 {
00048                         (*bucketptr)->ClearScheduledPolygons();
00049                 }
00050         }
00051 
00052         vector<RAS_MaterialBucket*> alphabuckets;
00053 
00054         // if no visibility method is define, everything is drawn
00055         
00056         for (i=0;i<numbuckets;i++)
00057         {
00058                 RAS_MaterialBucket** bucketptr = gMaterialBuckets.at(i);
00059                 if (bucketptr)
00060                 {
00061                         if (!(*bucketptr)->IsTransparant())
00062                         {
00063                                 (*bucketptr)->Render(cameratrans,rasty,rendertools);
00064                         } else
00065                         {
00066                                 alphabuckets.push_back(*bucketptr);
00067                         }
00068                 }
00069         }
00070         
00071         rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_DISABLED);
00072         
00073         int numalphabuckets = alphabuckets.size();
00074         for (vector<RAS_MaterialBucket*>::const_iterator it=alphabuckets.begin();
00075         !(it==alphabuckets.end());it++)
00076         {
00077                 (*it)->Render(cameratrans,rasty,rendertools);
00078         }
00079 
00080         alphabuckets.clear();   
00081 
00082         RAS_MaterialBucket::EndFrame();
00083         rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
00084 
00085 }
00086 
00087 RAS_MaterialBucket* RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material)

00088 {
00089 
00090         RAS_MaterialBucket** bucketptr =        gMaterialBuckets[*material];
00091         RAS_MaterialBucket* bucket=NULL;
00092         if (!bucketptr)
00093         {
00094                 bucket = new RAS_MaterialBucket(material);
00095                 gMaterialBuckets.insert(*material,bucket);
00096 
00097         } else
00098         {
00099                 bucket = *bucketptr;
00100         }
00101 
00102         return bucket;
00103 }
00104 
00105 void RAS_BucketManagerClearAll()

00106 {
00107 
00108         int numbuckets = gMaterialBuckets.size();
00109         for (int i=0;i<numbuckets;i++)
00110         {
00111                 RAS_MaterialBucket** bucketptr = gMaterialBuckets.at(i);
00112                 if (bucketptr)
00113                 {
00114                         delete (*bucketptr);
00115                         *bucketptr=NULL;
00116 
00117                 }
00118         }
00119         gMaterialBuckets.clear();
00120         
00121 }

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