Home | nevrax.com |
|
material_user.hGo to the documentation of this file.00001 00007 /* Copyright, 2001 Nevrax Ltd. 00008 * 00009 * This file is part of NEVRAX NEL. 00010 * NEVRAX NEL is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2, or (at your option) 00013 * any later version. 00014 00015 * NEVRAX NEL is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 00020 * You should have received a copy of the GNU General Public License 00021 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00022 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00023 * MA 02111-1307, USA. 00024 */ 00025 00026 #ifndef NL_MATERIAL_USER_H 00027 #define NL_MATERIAL_USER_H 00028 00029 #include "nel/misc/types_nl.h" 00030 #include "nel/3d/u_material.h" 00031 #include "3d/material.h" 00032 #include "3d/texture_user.h" 00033 00034 #define NL3D_MEM_MATERIAL NL_ALLOC_CONTEXT( 3dMat ) 00035 00036 namespace NL3D 00037 { 00038 00039 00040 class CDriverUser; 00041 00042 00043 // *************************************************************************** 00050 class CMaterialUser : public UMaterial 00051 { 00052 protected: 00053 CMaterial _Material; 00054 friend class CDriverUser; 00055 00056 public: 00057 00059 // @{ 00060 CMaterialUser() 00061 { 00062 NL3D_MEM_MATERIAL 00063 _Material.initUnlit(); 00064 // Enum assertion. User have access only to 6 first blend modes. Other are internals. 00065 nlassert((uint)UMaterial::blendCount==(uint)CMaterial::blendConstantColor); 00066 // Enum assertion. 00067 nlassert((uint)UMaterial::zfuncCount==(uint)CMaterial::zfuncCount); 00068 } 00069 virtual ~CMaterialUser() 00070 { 00071 NL3D_MEM_MATERIAL 00072 } 00073 // @} 00074 00076 // @{ 00077 virtual void setTexture(UTexture* ptex) 00078 { 00079 NL3D_MEM_MATERIAL 00080 CTextureUser *text= dynamic_cast<CTextureUser*>(ptex); 00081 if (text != NULL) 00082 { 00083 _Material.setTexture (0, text->getITexture()); 00084 } 00085 else 00086 { 00087 _Material.setTexture (0, NULL); 00088 } 00089 // NB: _Material smartpoint to this ITexture. But this is correct because so does CTextureUser. 00090 } 00091 00092 virtual bool texturePresent() 00093 { 00094 NL3D_MEM_MATERIAL 00095 return _Material.texturePresent(0); 00096 } 00097 00098 virtual void selectTextureSet(uint id) 00099 { 00100 NL3D_MEM_MATERIAL 00101 _Material.selectTextureSet(id); 00102 } 00103 00104 // @} 00105 00106 00108 // @{ 00109 virtual void setBlend(bool active) 00110 { 00111 NL3D_MEM_MATERIAL 00112 _Material.setBlend(active); 00113 } 00114 virtual void setBlendFunc(TBlend src, TBlend dst) 00115 { 00116 NL3D_MEM_MATERIAL 00117 _Material.setBlendFunc((CMaterial::TBlend)(uint32)src, (CMaterial::TBlend)(uint32)dst); 00118 } 00119 virtual void setSrcBlend(TBlend val) 00120 { 00121 NL3D_MEM_MATERIAL 00122 _Material.setSrcBlend((CMaterial::TBlend)(uint32)val); 00123 } 00124 virtual void setDstBlend(TBlend val) 00125 { 00126 NL3D_MEM_MATERIAL 00127 _Material.setDstBlend((CMaterial::TBlend)(uint32)val); 00128 } 00129 00130 virtual bool getBlend() const 00131 { 00132 NL3D_MEM_MATERIAL 00133 return _Material.getBlend(); 00134 } 00135 virtual TBlend getSrcBlend(void) const 00136 { 00137 NL3D_MEM_MATERIAL 00138 return (UMaterial::TBlend)(uint32)_Material.getSrcBlend(); 00139 } 00140 virtual TBlend getDstBlend(void) const 00141 { 00142 NL3D_MEM_MATERIAL 00143 return (UMaterial::TBlend)(uint32)_Material.getDstBlend(); 00144 } 00145 // @} 00146 00147 00149 // @{ 00150 virtual void setZFunc(ZFunc val) 00151 { 00152 NL3D_MEM_MATERIAL 00153 _Material.setZFunc((CMaterial::ZFunc)(uint32) val); 00154 } 00155 virtual void setZWrite(bool active) 00156 { 00157 NL3D_MEM_MATERIAL 00158 _Material.setZWrite(active); 00159 } 00160 virtual void setZBias(float val) 00161 { 00162 _Material.setZBias(val); 00163 } 00164 00165 virtual ZFunc getZFunc(void) const 00166 { 00167 NL3D_MEM_MATERIAL 00168 return (UMaterial::ZFunc)(uint32)_Material.getZFunc(); 00169 } 00170 virtual bool getZWrite(void) const 00171 { 00172 NL3D_MEM_MATERIAL 00173 return _Material.getZWrite(); 00174 } 00175 virtual float getZBias(void) const 00176 { 00177 NL3D_MEM_MATERIAL 00178 return _Material.getZBias(); 00179 } 00180 // @} 00181 00182 00184 // @{ 00186 virtual void setColor(CRGBA rgba) 00187 { 00188 NL3D_MEM_MATERIAL 00189 _Material.setColor(rgba); 00190 } 00191 00192 virtual CRGBA getColor(void) const 00193 { 00194 NL3D_MEM_MATERIAL 00195 return _Material.getColor(); 00196 } 00197 // @} 00198 00200 // @{ 00201 virtual void setDoubleSided(bool doubleSided = true) 00202 { 00203 NL3D_MEM_MATERIAL 00204 _Material.setDoubleSided(doubleSided); 00205 } 00206 virtual bool getDoubleSided() const 00207 { 00208 NL3D_MEM_MATERIAL 00209 return _Material.getDoubleSided(); 00210 } 00211 // @} 00212 00214 // @{ 00219 virtual void initUnlit() 00220 { 00221 NL3D_MEM_MATERIAL 00222 _Material.initUnlit(); 00223 } 00224 // @} 00225 00226 00227 00228 public: 00229 00230 // Internal Use only. 00231 CMaterial &getMaterial() 00232 { 00233 NL3D_MEM_MATERIAL 00234 return _Material; 00235 } 00236 00237 }; 00238 00239 00240 } // NL3D 00241 00242 00243 #endif // NL_MATERIAL_USER_H 00244 00245 /* End of material_user.h */ |