3 * ***** BEGIN GPL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20 * All rights reserved.
22 * The Original Code is: all of this file.
24 * Contributor(s): none yet.
26 * ***** END GPL LICENSE BLOCK *****
29 #include "RAS_IPolygonMaterial.h"
30 #include "RAS_IRasterizer.h"
32 #include "DNA_image_types.h"
33 #include "DNA_meshdata_types.h"
39 void RAS_IPolyMaterial::Initialize(
40 const STR_String& texname,
41 const STR_String& matname,
51 m_texturename = texname;
52 m_materialname = matname;
53 m_materialindex = materialindex;
55 m_tilexrep = tilexrep;
56 m_tileyrep = tileyrep;
61 m_polymatid = m_newpolymatid++;
65 m_specular.setValue(0.5,0.5,0.5);
67 m_diffuse.setValue(0.5,0.5,0.5);
70 RAS_IPolyMaterial::RAS_IPolyMaterial()
71 : m_texturename("__Dummy_Texture_Name__"),
72 m_materialname("__Dummy_Material_Name__"),
86 m_specular = MT_Vector3(0.5,0.5,0.5);
88 m_diffuse = MT_Vector3(0.5,0.5,0.5);
91 RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname,
92 const STR_String& matname,
101 : m_texturename(texname),
102 m_materialname(matname),
104 m_tilexrep(tilexrep),
105 m_tileyrep(tileyrep),
106 m_drawingmode (mode),
110 m_materialindex(materialindex),
111 m_polymatid(m_newpolymatid++),
116 m_specular = MT_Vector3(0.5,0.5,0.5);
118 m_diffuse = MT_Vector3(0.5,0.5,0.5);
122 bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const
124 if(m_flag &RAS_BLENDERMAT)
127 this->m_multimode == lhs.m_multimode &&
128 this->m_flag == lhs.m_flag &&
129 this->m_drawingmode == lhs.m_drawingmode &&
130 this->m_transp == lhs.m_transp &&
131 this->m_texturename.hash() == lhs.m_texturename.hash() &&
132 this->m_materialname.hash() == lhs.m_materialname.hash()
140 this->m_tile == lhs.m_tile &&
141 this->m_tilexrep == lhs.m_tilexrep &&
142 this->m_tileyrep == lhs.m_tileyrep &&
143 this->m_transp == lhs.m_transp &&
144 this->m_alpha == lhs.m_alpha &&
145 this->m_zsort == lhs.m_zsort &&
146 this->m_drawingmode == lhs.m_drawingmode &&
147 this->m_texturename.hash() == lhs.m_texturename.hash() &&
148 this->m_materialname.hash() == lhs.m_materialname.hash()
154 void RAS_IPolyMaterial::GetMaterialRGBAColor(unsigned char *rgba) const
162 bool RAS_IPolyMaterial::Less(const RAS_IPolyMaterial& rhs) const
167 return m_polymatid < rhs.m_polymatid;
170 bool RAS_IPolyMaterial::IsAlpha() const
172 return m_alpha || m_zsort;
175 bool RAS_IPolyMaterial::IsZSort() const
180 unsigned int RAS_IPolyMaterial::hash() const
182 return m_texturename.hash();
185 int RAS_IPolyMaterial::GetDrawingMode() const
187 return m_drawingmode;
190 const STR_String& RAS_IPolyMaterial::GetMaterialName() const
192 return m_materialname;
195 dword RAS_IPolyMaterial::GetMaterialNameHash() const
197 return m_materialname.hash();
200 const STR_String& RAS_IPolyMaterial::GetTextureName() const
202 return m_texturename;
205 int RAS_IPolyMaterial::GetMaterialIndex() const
207 return m_materialindex;
210 Material *RAS_IPolyMaterial::GetBlenderMaterial() const
215 Scene* RAS_IPolyMaterial::GetBlenderScene() const
220 void RAS_IPolyMaterial::ReleaseMaterial()
224 unsigned int RAS_IPolyMaterial::GetFlag() const
229 bool RAS_IPolyMaterial::UsesLighting(RAS_IRasterizer *rasty) const
231 bool dolights = false;
233 if(m_flag & RAS_BLENDERMAT)
234 dolights = (m_flag &RAS_MULTILIGHT)!=0;
235 else if(rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID);
236 else if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW);
238 dolights = (m_drawingmode & 16)!=0;
243 bool RAS_IPolyMaterial::UsesObjectColor() const
245 return !(m_flag & RAS_BLENDERGLSL);
248 unsigned int RAS_IPolyMaterial::m_newpolymatid = 0;