LEFT | RIGHT |
1 /* | 1 /* |
2 * $Id$ | |
3 * | |
4 * ***** BEGIN GPL LICENSE BLOCK ***** | 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
5 * | 3 * |
6 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
8 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
9 * of the License, or (at your option) any later version. | 7 * of the License, or (at your option) any later version. |
10 * | 8 * |
11 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 10 matching lines...) Expand all Loading... |
24 * | 22 * |
25 * Contributor(s): none yet. | 23 * Contributor(s): none yet. |
26 * | 24 * |
27 * ***** END GPL LICENSE BLOCK ***** | 25 * ***** END GPL LICENSE BLOCK ***** |
28 */ | 26 */ |
29 | 27 |
30 /** \file RAS_IPolygonMaterial.h | 28 /** \file RAS_IPolygonMaterial.h |
31 * \ingroup bgerast | 29 * \ingroup bgerast |
32 */ | 30 */ |
33 | 31 |
34 #ifndef __RAS_IPOLYGONMATERIAL | 32 #ifndef __RAS_IPOLYGONMATERIAL_H__ |
35 #define __RAS_IPOLYGONMATERIAL | 33 #define __RAS_IPOLYGONMATERIAL_H__ |
36 | 34 |
37 #include "STR_HashedString.h" | 35 #include "STR_HashedString.h" |
38 | 36 |
39 #include "MT_Vector3.h" | 37 #include "MT_Vector3.h" |
40 #include "STR_HashedString.h" | |
41 | 38 |
42 #ifdef WITH_CXX_GUARDEDALLOC | 39 #ifdef WITH_CXX_GUARDEDALLOC |
43 #include "MEM_guardedalloc.h" | 40 #include "MEM_guardedalloc.h" |
44 #endif | 41 #endif |
45 | 42 |
46 class RAS_IRasterizer; | 43 class RAS_IRasterizer; |
47 struct MTFace; | 44 struct MTFace; |
48 struct Material; | 45 struct Material; |
49 struct Image; | 46 struct Image; |
50 struct Scene; | 47 struct Scene; |
51 class SCA_IScene; | 48 class SCA_IScene; |
52 struct GameOptions; | 49 struct Image; |
| 50 struct Scene; |
| 51 class SCA_IScene; |
53 | 52 |
54 enum MaterialProps | 53 enum MaterialProps |
55 { | 54 { |
56 RAS_ZSORT =1, | |
57 RAS_TRANSPARENT =2, | |
58 RAS_TRIANGLE =4, | |
59 RAS_MULTITEX =8, | |
60 RAS_MULTILIGHT =16, | |
61 RAS_BLENDERMAT =32, | |
62 RAS_GLSHADER =64, | |
63 RAS_AUTOGEN =128, | |
64 RAS_NORMAL =256, | |
65 RAS_DEFMULTI =512, | |
66 RAS_BLENDERGLSL =1024 | |
67 }; | |
68 | |
69 /** | |
70 * Polygon Material on which the material buckets are sorted | |
71 * | |
72 */ | |
73 class RAS_IPolyMaterial | |
74 { | |
75 //todo: remove these variables from this interface/protocol class | |
76 protected: | |
77 STR_HashedString m_texturename; | |
78 STR_HashedString m_materialname; //also needed for touchs
ensor·· | |
79 int m_tile; | |
80 int m_tilexrep,m_tileyrep; | |
81 int m_drawingmode; | |
82 int m_transp; | |
83 bool m_alpha; | |
84 bool m_zsort; | |
85 bool m_light; | |
86 int m_materialindex; | |
87 ········ | |
88 unsigned int m_polymatid; | |
89 static unsigned int m_newpolymatid; | |
90 | |
91 // will move... | |
92 unsigned int m_flag;//MaterialProps | |
93 int m_multimode; // sum of v
alues | |
94 public: | |
95 MT_Vector3 m_diffuse; | |
96 float m_shininess; | |
97 MT_Vector3 m_specular; | |
98 float m_specularity; | |
99 ········ | |
100 /** Used to store caching information for materials. */ | |
101 typedef void* TCachingInfo; | |
102 | |
103 // care! these are taken from blender polygonflags, see file DNA_mesh_ty
pes.h for #define TF_BILLBOARD etc. | |
104 enum MaterialFlags | |
105 { | |
106 BILLBOARD_SCREENALIGNED = 512, /* GEMAT_HALO */ | |
107 BILLBOARD_AXISALIGNED = 1024, /* GEMAT_BILLBOARD */ | |
108 SHADOW =2048 /* GEMAT_SHADOW */ | |
109 }; | |
110 | |
111 RAS_IPolyMaterial(); | |
112 RAS_IPolyMaterial(const STR_String& texname, | |
113 const STR_String& matname, | |
114 int materialindex, | |
115 int tile, | |
116 int tilexrep, | |
117 int tileyrep, | |
118 int transp, | |
119 bool alpha, | |
120 bool zsort); | |
121 void Initialize(const STR_String& texname, | |
122 const STR_String& matname, | |
123 int materialindex, | |
124 int tile, | |
125 int tilexrep, | |
126 int tileyrep, | |
127 int transp, | |
128 bool alpha, | |
129 bool zsort, | |
130 bool light, | |
131 bool image, | |
132 struct GameSettings* gameopt); | |
133 | |
134 virtual ~RAS_IPolyMaterial() {}; | |
135 · | |
136 /** | |
137 * Returns the caching information for this material, | |
138 * This can be used to speed up the rasterizing process. | |
139 * @return The caching information. | |
140 */ | |
141 virtual TCachingInfo GetCachingInfo(void) const { return 0; } | |
142 | |
143 /** | |
144 * Activates the material in the rasterizer. | |
145 * On entry, the cachingInfo contains info about the last activated mate
rial. | |
146 * On exit, the cachingInfo should contain updated info about this mater
ial. | |
147 * @param rasty The rasterizer in which the material sho
uld be active. | |
148 * @param cachingInfo The information about the material used to speed
up rasterizing. | |
149 */ | |
150 virtual bool Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo)
const· | |
151 {· | |
152 return false;· | |
153 } | |
154 virtual void ActivateMeshSlot(const class RAS_MeshSlot & ms, RAS_IRaster
izer* rasty) const {} | |
155 | |
156 virtual bool Equals(const RAS_IPolyMaterial&
lhs) const; | |
157 bool Less(const RAS_IPolyMaterial& rhs) const
; | |
158 //int GetLightLayer() const; | |
159 bool IsAlpha() const; | |
160 bool IsZSort() const; | |
161 unsigned int hash() const; | |
162 int GetDrawingMode() const; | |
163 const STR_String& GetMaterialName() const; | |
164 dword GetMaterialNameHash() const; | |
165 const STR_String& GetTextureName() const; | |
166 unsigned int GetFlag() const; | |
167 int GetMaterialIndex() const; | |
168 | |
169 virtual Material* GetBlenderMaterial() const; | |
170 virtual Image* GetBlenderImage() const; | |
171 virtual Scene* GetBlenderScene() const; | |
172 virtual void ReleaseMaterial(); | |
173 virtual void GetMaterialRGBAColor(unsigned char *rgba) const; | |
174 virtual bool UsesLighting(RAS_IRasterizer *rasty) const; | |
175 virtual bool UsesObjectColor() const; | |
176 | |
177 virtual void Replace_IScene(SCA_IScene *val) {}; /* overridde
n by KX_BlenderMaterial */ | |
178 | |
179 /** | |
180 * @return the equivalent drawing mode for the material settings (equival
ent to old TexFace tface->mode). | |
181 */ | |
182 int ConvertFaceMode(struct GameSetti
ngs *gameopt, bool image) const; | |
183 | |
184 /* | |
185 * PreCalculate texture gen | |
186 */ | |
187 virtual void OnConstruction(int layer){} | |
188 ················ | |
189 ················ | |
190 #ifdef WITH_CXX_GUARDEDALLOC | |
191 public: | |
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); } | |
194 #endif | |
195 }; | |
196 | |
197 inline bool operator ==( const RAS_IPolyMaterial & rhs,const RAS_IPolyMaterial
& lhs) | |
198 { | |
199 return ( rhs.Equals(lhs)); | |
200 } | |
201 | |
202 inline bool operator < ( const RAS_IPolyMaterial & lhs, const RAS_IPolyMaterial
& rhs) | |
203 { | |
204 return lhs.Less(rhs); | |
205 } | |
206 | |
207 #endif //__RAS_IPOLYGONMATERIAL | |
208 | |
LEFT | RIGHT |