u_material.cpp

Go to the documentation of this file.
00001 
00005 /* Copyright, 2001 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
00022  */
00023 
00024 #include "std3d.h"
00025 
00026 
00027 #include "nel/3d/u_material.h"
00028 #include "nel/3d/u_driver.h"
00029 #include "nel/3d/texture_user.h"
00030 #include "nel/3d/driver_user.h"
00031 
00032 
00033 namespace NL3D
00034 {
00035 
00036 // ***************************************************************************
00037 
00038 bool UMaterial::isSupportedByDriver(UDriver &drv, bool forceBaseCaps)
00039 {
00040     CMaterial *object = getObjectPtr();
00041     return object->isSupportedByDriver(*(NLMISC::safe_cast<CDriverUser *>(&drv)->getDriver()), forceBaseCaps);
00042 }
00043 
00044 // ***************************************************************************
00045 
00046 void UMaterial::setAlphaTest(bool active)
00047 {
00048     CMaterial *object = getObjectPtr();
00049     object->setAlphaTest(active);
00050 }
00051 
00052 // ***************************************************************************
00053 
00054 bool UMaterial::getAlphaTest() const
00055 {
00056     CMaterial *object = getObjectPtr();
00057     return object->getAlphaTest();
00058 }
00059 
00060 // ***************************************************************************
00061 
00062 void UMaterial::setAlphaTestThreshold(float threshold)
00063 {
00064     CMaterial *object = getObjectPtr();
00065     object->setAlphaTestThreshold(threshold);
00066 }
00067 
00068 // ***************************************************************************
00069 
00070 float UMaterial::getAlphaTestThreshold() const
00071 {
00072     CMaterial *object = getObjectPtr();
00073     return object->getAlphaTestThreshold();
00074 }
00075 
00076 // ***************************************************************************
00077 
00078 void UMaterial::setTexture(UTexture* ptex)
00079 {
00080     setTexture (0, ptex);
00081 }
00082 
00083 // ***************************************************************************
00084 
00085 void UMaterial::setTexture(uint stage, UTexture* ptex)
00086 {
00087     CMaterial *object = getObjectPtr();
00088     CTextureUser    *text= dynamic_cast<CTextureUser*>(ptex);
00089     if (text != NULL)
00090     {
00091         object->setTexture (stage, text->getITexture());
00092     }
00093     else
00094     {
00095         object->setTexture (stage, NULL);
00096     }
00097     // NB: _Material smartpoint to this ITexture. But this is correct because so does CTextureUser.
00098 }
00099 
00100 // ***************************************************************************
00101 
00102 bool UMaterial::texturePresent()
00103 {
00104     return texturePresent (0);
00105 }
00106 
00107 // ***************************************************************************
00108 
00109 bool UMaterial::texturePresent (uint stage)
00110 {
00111     CMaterial *object = getObjectPtr();
00112     return object->texturePresent (stage);
00113 }
00114 
00115 // ***************************************************************************
00116 
00117 void UMaterial::selectTextureSet(uint id)
00118 {
00119     CMaterial *object = getObjectPtr();
00120     object->selectTextureSet(id);
00121 }
00122 
00123 // ***************************************************************************
00124 
00125 void UMaterial::setBlend(bool active)
00126 {
00127     CMaterial *object = getObjectPtr();
00128     object->setBlend(active);
00129 }
00130 
00131 // ***************************************************************************
00132 
00133 void UMaterial::setBlendFunc(TBlend src, TBlend dst)
00134 {
00135     CMaterial *object = getObjectPtr();
00136     object->setBlendFunc((CMaterial::TBlend)(uint32)src, (CMaterial::TBlend)(uint32)dst);
00137 }
00138 
00139 // ***************************************************************************
00140 
00141 void UMaterial::setSrcBlend(TBlend val)
00142 {
00143     CMaterial *object = getObjectPtr();
00144     object->setSrcBlend((CMaterial::TBlend)(uint32)val);
00145 }
00146 
00147 // ***************************************************************************
00148 
00149 void UMaterial::setDstBlend(TBlend val)
00150 {
00151     CMaterial *object = getObjectPtr();
00152     object->setDstBlend((CMaterial::TBlend)(uint32)val);
00153 }
00154 
00155 // ***************************************************************************
00156 
00157 bool UMaterial::getBlend() const
00158 {
00159     CMaterial *object = getObjectPtr();
00160     return object->getBlend();
00161 }
00162 
00163 // ***************************************************************************
00164 
00165 UMaterial::TBlend UMaterial::getSrcBlend(void)  const
00166 {
00167     CMaterial *object = getObjectPtr();
00168     return (UMaterial::TBlend)(uint32)object->getSrcBlend();
00169 }
00170 
00171 // ***************************************************************************
00172 
00173 UMaterial::TBlend UMaterial::getDstBlend(void)  const
00174 {
00175     CMaterial *object = getObjectPtr();
00176     return (UMaterial::TBlend)(uint32)object->getDstBlend();
00177 }
00178 
00179 // ***************************************************************************
00180 
00181 void UMaterial::texEnvOpRGB(uint stage, TTexOperator ope)
00182 {
00183     CMaterial *object = getObjectPtr();
00184     object->texEnvOpRGB(stage, (CMaterial::TTexOperator)(uint32)ope);
00185 }
00186 
00187 // ***************************************************************************
00188 
00189 void UMaterial::texEnvArg0RGB (uint stage, TTexSource src, TTexOperand oper)
00190 {
00191     CMaterial *object = getObjectPtr();
00192     object->texEnvArg0RGB (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00193 }
00194 
00195 // ***************************************************************************
00196 
00197 void UMaterial::texEnvArg1RGB (uint stage, TTexSource src, TTexOperand oper)
00198 {
00199     CMaterial *object = getObjectPtr();
00200     object->texEnvArg1RGB (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00201 }
00202 
00203 // ***************************************************************************
00204 
00205 void UMaterial::texEnvArg2RGB (uint stage, TTexSource src, TTexOperand oper)
00206 {
00207     CMaterial *object = getObjectPtr();
00208     object->texEnvArg2RGB (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00209 }
00210 
00211 // ***************************************************************************
00212 
00213 void UMaterial::texEnvOpAlpha(uint stage, TTexOperator ope)
00214 {
00215     CMaterial *object = getObjectPtr();
00216     object->texEnvOpAlpha (stage, (CMaterial::TTexOperator)(uint32)ope);
00217 }
00218 
00219 // ***************************************************************************
00220 
00221 void UMaterial::texEnvArg0Alpha(uint stage, TTexSource src, TTexOperand oper)
00222 {
00223     CMaterial *object = getObjectPtr();
00224     object->texEnvArg0Alpha (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00225 }
00226 
00227 // ***************************************************************************
00228 
00229 void UMaterial::texEnvArg1Alpha(uint stage, TTexSource src, TTexOperand oper)
00230 {
00231     CMaterial *object = getObjectPtr();
00232     object->texEnvArg1Alpha (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00233 }
00234 
00235 // ***************************************************************************
00236 
00237 void UMaterial::texEnvArg2Alpha(uint stage, TTexSource src, TTexOperand oper)
00238 {
00239     CMaterial *object = getObjectPtr();
00240     object->texEnvArg2Alpha (stage, (CMaterial::TTexSource)(uint32)src, (CMaterial::TTexOperand)(uint32)oper);
00241 }
00242 
00243 // ***************************************************************************
00244 
00245 void            UMaterial::setZFunc(ZFunc val)
00246 {
00247     CMaterial *object = getObjectPtr();
00248     object->setZFunc((CMaterial::ZFunc)(uint32) val);
00249 }
00250 
00251 // ***************************************************************************
00252 
00253 void            UMaterial::setZWrite(bool active)
00254 {
00255     CMaterial *object = getObjectPtr();
00256     object->setZWrite(active);
00257 }
00258 
00259 // ***************************************************************************
00260 
00261 void            UMaterial::setZBias(float val)
00262 {
00263     CMaterial *object = getObjectPtr();
00264     object->setZBias(val);
00265 }
00266 
00267 // ***************************************************************************
00268 
00269 UMaterial::ZFunc            UMaterial::getZFunc(void)  const
00270 {
00271     CMaterial *object = getObjectPtr();
00272     return (UMaterial::ZFunc)(uint32)object->getZFunc();
00273 }
00274 
00275 // ***************************************************************************
00276 
00277 bool            UMaterial::getZWrite(void)  const
00278 {
00279     CMaterial *object = getObjectPtr();
00280     return object->getZWrite();
00281 }
00282 
00283 // ***************************************************************************
00284 
00285 float           UMaterial::getZBias(void)  const
00286 {
00287     CMaterial *object = getObjectPtr();
00288     return object->getZBias();
00289 }
00290 
00291 // ***************************************************************************
00292 
00293 void            UMaterial::setColor(CRGBA rgba)
00294 {
00295     CMaterial *object = getObjectPtr();
00296     object->setColor(rgba);
00297 }
00298 
00299 // ***************************************************************************
00300 
00301 CRGBA           UMaterial::getColor(void) const
00302 {
00303     CMaterial *object = getObjectPtr();
00304     return object->getColor();
00305 }
00306 
00307 // ***************************************************************************
00308 
00309 void            UMaterial::setDoubleSided(bool doubleSided)
00310 {
00311     CMaterial *object = getObjectPtr();
00312     object->setDoubleSided(doubleSided);
00313 }
00314 
00315 // ***************************************************************************
00316 
00317 bool            UMaterial::getDoubleSided() const
00318 {
00319     CMaterial *object = getObjectPtr();
00320     return object->getDoubleSided();
00321 }
00322 
00323 // ***************************************************************************
00324 
00325 void            UMaterial::initUnlit()
00326 {
00327     CMaterial *object = getObjectPtr();
00328     object->initUnlit();
00329 }
00330 
00331 
00332 // ***************************************************************************
00333 bool            UMaterial::isLighted() const
00334 {
00335     CMaterial *object = getObjectPtr();
00336     return object->isLighted();
00337 }
00338 // ***************************************************************************
00339 CRGBA           UMaterial::getEmissive() const
00340 {
00341     CMaterial *object = getObjectPtr();
00342     return object->getEmissive();
00343 }
00344 // ***************************************************************************
00345 CRGBA           UMaterial::getAmbient() const
00346 {
00347     CMaterial *object = getObjectPtr();
00348     return object->getAmbient();
00349 }
00350 // ***************************************************************************
00351 CRGBA           UMaterial::getDiffuse() const
00352 {
00353     CMaterial *object = getObjectPtr();
00354     return object->getDiffuse();
00355 }
00356 // ***************************************************************************
00357 uint8           UMaterial::getOpacity() const
00358 {
00359     CMaterial *object = getObjectPtr();
00360     return object->getOpacity();
00361 }
00362 // ***************************************************************************
00363 CRGBA           UMaterial::getSpecular() const
00364 {
00365     CMaterial *object = getObjectPtr();
00366     return object->getSpecular();
00367 }
00368 // ***************************************************************************
00369 float           UMaterial::getShininess() const
00370 {
00371     CMaterial *object = getObjectPtr();
00372     return object->getShininess();
00373 }
00374 
00375 } // NL3D

Generated on Thu Jan 7 08:26:31 2010 for NeL by  doxygen 1.6.1