2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file RAS_IPolygonMaterial.h
32 #ifndef __RAS_IPOLYGONMATERIAL_H__
33 #define __RAS_IPOLYGONMATERIAL_H__
35 #include "STR_HashedString.h"
37 #include "MT_Vector3.h"
38 #include "STR_HashedString.h"
40 #ifdef WITH_CXX_GUARDEDALLOC
41 #include "MEM_guardedalloc.h"
44 class RAS_IRasterizer;
64 RAS_BLENDERGLSL =1024,
69 * Polygon Material on which the material buckets are sorted
72 class RAS_IPolyMaterial
74 //todo: remove these variables from this interface/protocol class
76 STR_HashedString m_texturename;
77 STR_HashedString m_materialname; //also needed for touchsensor
79 int m_tilexrep,m_tileyrep;
87 unsigned int m_polymatid;
88 static unsigned int m_newpolymatid;
91 unsigned int m_flag;//MaterialProps
92 int m_multimode; // sum of values
96 MT_Vector3 m_specular;
99 /** Used to store caching information for materials. */
100 typedef void* TCachingInfo;
102 // care! these are taken from blender polygonflags, see file DNA_mesh_types.h for #define TF_BILLBOARD etc.
105 BILLBOARD_SCREENALIGNED = 512, /* GEMAT_HALO */
106 BILLBOARD_AXISALIGNED = 1024, /* GEMAT_BILLBOARD */
107 SHADOW =2048 /* GEMAT_SHADOW */
111 RAS_IPolyMaterial(const STR_String& texname,
112 const STR_String& matname,
120 void Initialize(const STR_String& texname,
121 const STR_String& matname,
131 struct GameSettings* game);
133 virtual ~RAS_IPolyMaterial() {};
136 * Returns the caching information for this material,
137 * This can be used to speed up the rasterizing process.
138 * \return The caching information.
140 virtual TCachingInfo GetCachingInfo(void) const { return 0; }
143 * Activates the material in the rasterizer.
144 * On entry, the cachingInfo contains info about the last activated material.
145 * On exit, the cachingInfo should contain updated info about this material.
146 * \param rasty The rasterizer in which the material should be active.
147 * \param cachingInfo The information about the material used to speed up rasterizing.
149 virtual bool Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const
153 virtual void ActivateMeshSlot(const class RAS_MeshSlot & ms, RAS_IRasterizer* rasty) const {}
155 virtual bool Equals(const RAS_IPolyMaterial& lhs) const;
156 bool Less(const RAS_IPolyMaterial& rhs) const;
157 //int GetLightLayer() const;
158 bool IsAlpha() const;
159 bool IsZSort() const;
160 unsigned int hash() const;
161 int GetDrawingMode() const;
162 const STR_String& GetMaterialName() const;
163 dword GetMaterialNameHash() const;
164 const STR_String& GetTextureName() const;
165 unsigned int GetFlag() const;
166 int GetMaterialIndex() const;
168 virtual Material* GetBlenderMaterial() const;
169 virtual Image* GetBlenderImage() const;
170 virtual Scene* GetBlenderScene() const;
171 virtual void ReleaseMaterial();
172 virtual void GetMaterialRGBAColor(unsigned char *rgba) const;
173 virtual bool UsesLighting(RAS_IRasterizer *rasty) const;
174 virtual bool UsesObjectColor() const;
175 virtual bool CastsShadows() const;
177 virtual void Replace_IScene(SCA_IScene *val) {}; /* overridden by KX_BlenderMaterial */
180 * \return the equivalent drawing mode for the material settings (equivalent to old TexFace tface->mode).
182 int ConvertFaceMode(struct GameSettings *game, bool image) const;
185 * PreCalculate texture gen
187 virtual void OnConstruction(int layer){}
190 #ifdef WITH_CXX_GUARDEDALLOC
192 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IPolyMaterial"); }
193 void operator delete( void *mem ) { MEM_freeN(mem); }
197 inline bool operator ==( const RAS_IPolyMaterial & rhs,const RAS_IPolyMaterial & lhs)
199 return ( rhs.Equals(lhs));
202 inline bool operator < ( const RAS_IPolyMaterial & lhs, const RAS_IPolyMaterial & rhs)
204 return lhs.Less(rhs);
207 #endif //__RAS_IPOLYGONMATERIAL_H__