00001 00002 #ifndef __RAS_MATERIALBUCKET 00003 #define __RAS_MATERIALBUCKET 00004 00005 #include "GEN_MinMax.h" 00006 #include "RAS_TexVert.h" 00007 #include "GEN_Map.h" 00008 #include "KX_HashedString.h" 00009 #include "MT_Transform.h" 00010 //#include "KX_OverlapManager.h" 00011 #include "RAS_IPolygonMaterial.h" 00012 #include <vector> 00013 #include <map> 00014 #include <set> 00015 using namespace std; 00016 00017 typedef vector< vector<class RAS_TexVert>* > vecVertexArray; 00018 typedef vector<unsigned int> KX_IndexArray; 00019 typedef vector< KX_IndexArray* > vecIndexArrays; 00020 00021 typedef vector<RAS_TexVert> KX_VertexArray; 00022 00023 00024 00025 struct KX_VertexIndex { 00026 public: 00027 KX_VertexIndex(int size) 00028 { 00029 m_size=size; 00030 } 00031 void SetIndex(short loc,short index) 00032 { 00033 m_indexarray[loc]=index; 00034 } 00035 short m_vtxarray; 00036 short m_indexarray[4]; 00037 short m_size; 00038 00039 }; 00040 00041 00042 00043 class KX_MeshSlot 00044 { 00045 public: 00046 void* m_clientObj; 00047 double* m_OpenGLMatrix; 00048 class RAS_MeshObject* m_mesh; 00049 mutable bool m_bVisible; // for visibility 00050 KX_MeshSlot() :m_bVisible(true) {} 00051 00052 inline bool Less(const KX_MeshSlot& lhs) const { 00053 bool result = ((m_mesh < lhs.m_mesh )|| 00054 ((m_mesh == lhs.m_mesh)&& 00055 (m_OpenGLMatrix < lhs.m_OpenGLMatrix))); 00056 return result; 00057 00058 } 00059 00060 00061 }; 00062 inline bool operator <( const KX_MeshSlot& rhs,const KX_MeshSlot& lhs) 00063 { 00064 return ( rhs.Less(lhs)); 00065 } 00066 00067 00068 class RAS_MaterialBucket 00069 { 00070 00071 set<KX_MeshSlot> m_meshSlots; 00072 bool m_bScheduled; 00073 bool m_bModified; 00074 bool m_dolights; 00075 bool m_bUseTriangles; 00076 RAS_IPolyMaterial* m_material; 00077 double* m_pOGLMatrix; 00078 00079 public: 00080 RAS_MaterialBucket(RAS_IPolyMaterial* mat) 00081 :m_bModified(true), 00082 m_dolights(true) 00083 00084 { 00085 00086 m_bScheduled=true; 00087 m_material = mat; 00088 }; 00089 virtual ~RAS_MaterialBucket() { 00090 00091 } 00092 00093 00094 void Render(const MT_Transform & cameratrans,class RAS_IRasterizer* rasty,class RAS_IRenderTools* rendertools); 00095 00096 void DisableLights() { m_dolights = false;}; 00097 00098 void SchedulePolygons(int drawingmode) { 00099 m_bScheduled = true; 00100 }; 00101 00102 void ClearScheduledPolygons() { 00103 m_bScheduled = false; 00104 }; 00105 00106 RAS_IPolyMaterial* GetPolyMaterial() { 00107 return m_material;}; 00108 00109 00110 00111 bool IsTransparant(); 00112 00113 static void StartFrame(); 00114 static void EndFrame(); 00115 00116 00117 00118 void SetTriangleMode(bool usetriangles) 00119 { 00120 m_bUseTriangles = usetriangles; 00121 } 00122 void SetMeshSlot(KX_MeshSlot& ms) { 00123 m_meshSlots.insert(ms); 00124 } 00125 void RemoveMeshSlot(KX_MeshSlot& ms) { 00126 set<KX_MeshSlot>::iterator it = m_meshSlots.find(ms); 00127 m_meshSlots.erase(it); 00128 } 00129 void MarkVisibleMeshSlot(KX_MeshSlot& ms,bool visible) { 00130 00131 set<KX_MeshSlot>::iterator it = m_meshSlots.find(ms); 00132 (*it).m_bVisible = visible;//m_meshSlots.erase(it); 00133 00134 } 00135 00136 }; 00137 00138 00139 #endif //__KX_BUCKET