Change Encyclo button name and macros icon
[ryzomcore.git] / nel / src / 3d / u_material.cpp
blobb6b9dccc484c3b2669ffe1a594be8bf0728d2036
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
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 Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "std3d.h"
20 #include "nel/3d/u_material.h"
21 #include "nel/3d/u_driver.h"
22 #include "nel/3d/texture_user.h"
23 #include "nel/3d/driver_user.h"
25 #ifdef DEBUG_NEW
26 #define new DEBUG_NEW
27 #endif
29 namespace NL3D
32 // ***************************************************************************
34 bool UMaterial::isSupportedByDriver(UDriver &drv, bool forceBaseCaps)
36 CMaterial *object = getObjectPtr();
37 return object->isSupportedByDriver(*(NLMISC::safe_cast<CDriverUser *>(&drv)->getDriver()), forceBaseCaps);
40 // ***************************************************************************
42 void UMaterial::setAlphaTest(bool active)
44 CMaterial *object = getObjectPtr();
45 object->setAlphaTest(active);
48 // ***************************************************************************
50 bool UMaterial::getAlphaTest() const
52 CMaterial *object = getObjectPtr();
53 return object->getAlphaTest();
56 // ***************************************************************************
58 void UMaterial::setAlphaTestThreshold(float threshold)
60 CMaterial *object = getObjectPtr();
61 object->setAlphaTestThreshold(threshold);
64 // ***************************************************************************
66 float UMaterial::getAlphaTestThreshold() const
68 CMaterial *object = getObjectPtr();
69 return object->getAlphaTestThreshold();
72 // ***************************************************************************
74 void UMaterial::setTexture(UTexture* ptex)
76 setTexture (0, ptex);
79 // ***************************************************************************
81 void UMaterial::setTexture(uint stage, UTexture* ptex)
83 CMaterial *object = getObjectPtr();
84 CTextureUser *text= dynamic_cast<CTextureUser*>(ptex);
85 if (text != NULL)
87 object->setTexture (stage, text->getITexture());
89 else
91 object->setTexture (stage, NULL);
93 // NB: _Material smartpoint to this ITexture. But this is correct because so does CTextureUser.
96 // ***************************************************************************
98 bool UMaterial::texturePresent()
100 return texturePresent (0);
103 // ***************************************************************************
105 bool UMaterial::texturePresent (uint stage)
107 CMaterial *object = getObjectPtr();
108 return object->texturePresent (stage);
111 // ***************************************************************************
113 void UMaterial::selectTextureSet(uint id)
115 CMaterial *object = getObjectPtr();
116 object->selectTextureSet(id);
119 // ***************************************************************************
121 void UMaterial::setBlend(bool active)
123 CMaterial *object = getObjectPtr();
124 object->setBlend(active);
127 // ***************************************************************************
129 void UMaterial::setBlendFunc(TBlend src, TBlend dst)
131 CMaterial *object = getObjectPtr();
132 object->setBlendFunc((CMaterial::TBlend)(uint32)src, (CMaterial::TBlend)(uint32)dst);
135 // ***************************************************************************
137 void UMaterial::setSrcBlend(TBlend val)
139 CMaterial *object = getObjectPtr();
140 object->setSrcBlend((CMaterial::TBlend)(uint32)val);
143 // ***************************************************************************
145 void UMaterial::setDstBlend(TBlend val)
147 CMaterial *object = getObjectPtr();
148 object->setDstBlend((CMaterial::TBlend)(uint32)val);
151 // ***************************************************************************
153 bool UMaterial::getBlend() const
155 CMaterial *object = getObjectPtr();
156 return object->getBlend();
159 // ***************************************************************************
161 UMaterial::TBlend UMaterial::getSrcBlend(void) const
163 CMaterial *object = getObjectPtr();
164 return (UMaterial::TBlend)(uint32)object->getSrcBlend();
167 // ***************************************************************************
169 UMaterial::TBlend UMaterial::getDstBlend(void) const
171 CMaterial *object = getObjectPtr();
172 return (UMaterial::TBlend)(uint32)object->getDstBlend();
175 // ***************************************************************************
177 void UMaterial::texEnvOpRGB(uint stage, TTexOperator ope)
179 CMaterial *object = getObjectPtr();
180 object->texEnvOpRGB(stage, (CMaterial::TTexOperator)(uint32)ope);
183 // ***************************************************************************
185 void UMaterial::texEnvArg0RGB (uint stage, TTexSource src, TTexOperand oper)
187 CMaterial *object = getObjectPtr();
188 object->texEnvArg0RGB (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
191 // ***************************************************************************
193 void UMaterial::texEnvArg1RGB (uint stage, TTexSource src, TTexOperand oper)
195 CMaterial *object = getObjectPtr();
196 object->texEnvArg1RGB (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
199 // ***************************************************************************
201 void UMaterial::texEnvArg2RGB (uint stage, TTexSource src, TTexOperand oper)
203 CMaterial *object = getObjectPtr();
204 object->texEnvArg2RGB (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
207 // ***************************************************************************
209 void UMaterial::texEnvOpAlpha(uint stage, TTexOperator ope)
211 CMaterial *object = getObjectPtr();
212 object->texEnvOpAlpha (stage, (CMaterial::TTexOperator)(uint32)ope);
215 // ***************************************************************************
217 void UMaterial::texEnvArg0Alpha(uint stage, TTexSource src, TTexOperand oper)
219 CMaterial *object = getObjectPtr();
220 object->texEnvArg0Alpha (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
223 // ***************************************************************************
225 void UMaterial::texEnvArg1Alpha(uint stage, TTexSource src, TTexOperand oper)
227 CMaterial *object = getObjectPtr();
228 object->texEnvArg1Alpha (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
231 // ***************************************************************************
233 void UMaterial::texEnvArg2Alpha(uint stage, TTexSource src, TTexOperand oper)
235 CMaterial *object = getObjectPtr();
236 object->texEnvArg2Alpha (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
239 // ***************************************************************************
241 void UMaterial::setZFunc(ZFunc val)
243 CMaterial *object = getObjectPtr();
244 object->setZFunc((CMaterial::ZFunc)(uint32) val);
247 // ***************************************************************************
249 void UMaterial::setZWrite(bool active)
251 CMaterial *object = getObjectPtr();
252 object->setZWrite(active);
255 // ***************************************************************************
257 void UMaterial::setZBias(float val)
259 CMaterial *object = getObjectPtr();
260 object->setZBias(val);
263 // ***************************************************************************
265 UMaterial::ZFunc UMaterial::getZFunc(void) const
267 CMaterial *object = getObjectPtr();
268 return (UMaterial::ZFunc)(uint32)object->getZFunc();
271 // ***************************************************************************
273 bool UMaterial::getZWrite(void) const
275 CMaterial *object = getObjectPtr();
276 return object->getZWrite();
279 // ***************************************************************************
281 float UMaterial::getZBias(void) const
283 CMaterial *object = getObjectPtr();
284 return object->getZBias();
287 // ***************************************************************************
289 void UMaterial::setColor(CRGBA rgba)
291 CMaterial *object = getObjectPtr();
292 object->setColor(rgba);
295 // ***************************************************************************
297 CRGBA UMaterial::getColor(void) const
299 CMaterial *object = getObjectPtr();
300 return object->getColor();
303 // ***************************************************************************
305 void UMaterial::setDoubleSided(bool doubleSided)
307 CMaterial *object = getObjectPtr();
308 object->setDoubleSided(doubleSided);
311 // ***************************************************************************
313 bool UMaterial::getDoubleSided() const
315 CMaterial *object = getObjectPtr();
316 return object->getDoubleSided();
319 // ***************************************************************************
321 void UMaterial::initUnlit()
323 CMaterial *object = getObjectPtr();
324 object->initUnlit();
328 // ***************************************************************************
329 bool UMaterial::isLighted() const
331 CMaterial *object = getObjectPtr();
332 return object->isLighted();
334 // ***************************************************************************
335 CRGBA UMaterial::getEmissive() const
337 CMaterial *object = getObjectPtr();
338 return object->getEmissive();
340 // ***************************************************************************
341 CRGBA UMaterial::getAmbient() const
343 CMaterial *object = getObjectPtr();
344 return object->getAmbient();
346 // ***************************************************************************
347 CRGBA UMaterial::getDiffuse() const
349 CMaterial *object = getObjectPtr();
350 return object->getDiffuse();
352 // ***************************************************************************
353 uint8 UMaterial::getOpacity() const
355 CMaterial *object = getObjectPtr();
356 return object->getOpacity();
358 // ***************************************************************************
359 CRGBA UMaterial::getSpecular() const
361 CMaterial *object = getObjectPtr();
362 return object->getSpecular();
364 // ***************************************************************************
365 float UMaterial::getShininess() const
367 CMaterial *object = getObjectPtr();
368 return object->getShininess();
371 } // NL3D