Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# SMaterialLayer.h

Go to the documentation of this file.

    00001 // Copyright (C) 2002-2010 Nikolaus Gebhardt
    00002 // This file is part of the "Irrlicht Engine".
    00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
    00004
    00005 #ifndef __S_MATERIAL_LAYER_H_INCLUDED__
    00006 #define __S_MATERIAL_LAYER_H_INCLUDED__
    00007
    00008 #include "matrix4.h"
    00009 #include "irrAllocator.h"
    00010
    00011 namespace irr
    00012 {
    00013 namespace video
    00014 {
    00015         class ITexture;
    00016
    00018         enum E_TEXTURE_CLAMP
    00019         {
    00021                 ETC_REPEAT = 0,
    00023                 ETC_CLAMP,
    00025                 ETC_CLAMP_TO_EDGE,
    00027                 ETC_CLAMP_TO_BORDER,
    00029                 ETC_MIRROR,
    00031                 ETC_MIRROR_CLAMP,
    00033                 ETC_MIRROR_CLAMP_TO_EDGE,
    00035                 ETC_MIRROR_CLAMP_TO_BORDER
    00036         };
    00037         static const char* const aTextureClampNames[] = {
    00038                         "texture_clamp_repeat",
    00039                         "texture_clamp_clamp",
    00040                         "texture_clamp_clamp_to_edge",
    00041                         "texture_clamp_clamp_to_border",
    00042                         "texture_clamp_mirror",
    00043                         "texture_clamp_mirror_clamp",
    00044                         "texture_clamp_mirror_clamp_to_edge",
    00045                         "texture_clamp_mirror_clamp_to_border", 0};
    00046
    00048         class SMaterialLayer
    00049         {
    00050         public:
    00052                 SMaterialLayer()
    00053                         : Texture(0),
    00054                                 TextureWrapU(ETC_REPEAT),
    00055                                 TextureWrapV(ETC_REPEAT),
    00056                                 BilinearFilter(true),
    00057                                 TrilinearFilter(false),
    00058                                 AnisotropicFilter(0),
    00059                                 LODBias(0),
    00060                                 TextureMatrix(0)
    00061                         {}
    00062
    00064
    00065                 SMaterialLayer(const SMaterialLayer& other)
    00066                 {
    00067                         // This pointer is checked during assignment
    00068                         TextureMatrix = 0;
    00069                         *this = other;
    00070                 }
    00071
    00073                 ~SMaterialLayer()
    00074                 {
    00075                         MatrixAllocator.destruct(TextureMatrix);
    00076                         MatrixAllocator.deallocate(TextureMatrix);
    00077                 }
    00078
    00080
    00082                 SMaterialLayer& operator=(const SMaterialLayer& other)
    00083                 {
    00084                         // Check for self-assignment!
    00085                         if (this == &other)
    00086                                 return *this;
    00087
    00088                         Texture = other.Texture;
    00089                         if (TextureMatrix)
    00090                         {
    00091                                 if (other.TextureMatrix)
    00092                                         *TextureMatrix = *other.TextureMatrix;
    00093                                 else
    00094                                 {
    00095                                         MatrixAllocator.destruct(TextureMatrix);
    00096                                         MatrixAllocator.deallocate(TextureMatrix);
    00097                                         TextureMatrix = 0;
    00098                                 }
    00099                         }
    00100                         else
    00101                         {
    00102                                 if (other.TextureMatrix)
    00103                                 {
    00104                                         TextureMatrix = MatrixAllocator.allocate(1);
    00105                                         MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix);
    00106                                 }
    00107                                 else
    00108                                         TextureMatrix = 0;
    00109                         }
    00110                         TextureWrapU = other.TextureWrapU;
    00111                         TextureWrapV = other.TextureWrapV;
    00112                         BilinearFilter = other.BilinearFilter;
    00113                         TrilinearFilter = other.TrilinearFilter;
    00114                         AnisotropicFilter = other.AnisotropicFilter;
    00115                         LODBias = other.LODBias;
    00116
    00117                         return *this;
    00118                 }
    00119
    00121
    00122                 core::matrix4& getTextureMatrix()
    00123                 {
    00124                         if (!TextureMatrix)
    00125                         {
    00126                                 TextureMatrix = MatrixAllocator.allocate(1);
    00127                                 MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix);
    00128                         }
    00129                         return *TextureMatrix;
    00130                 }
    00131
    00133
    00134                 const core::matrix4& getTextureMatrix() const
    00135                 {
    00136                         if (TextureMatrix)
    00137                                 return *TextureMatrix;
    00138                         else
    00139                                 return core::IdentityMatrix;
    00140                 }
    00141
    00143
    00144                 void setTextureMatrix(const core::matrix4& mat)
    00145                 {
    00146                         if (!TextureMatrix)
    00147                         {
    00148                                 TextureMatrix = MatrixAllocator.allocate(1);
    00149                                 MatrixAllocator.construct(TextureMatrix,mat);
    00150                         }
    00151                         else
    00152                                 *TextureMatrix = mat;
    00153                 }
    00154
    00156
    00158                 inline bool operator!=(const SMaterialLayer& b) const
    00159                 {
    00160                         bool different =
    00161                                 Texture != b.Texture ||
    00162                                 TextureWrapU != b.TextureWrapU ||
    00163                                 TextureWrapV != b.TextureWrapV ||
    00164                                 BilinearFilter != b.BilinearFilter ||
    00165                                 TrilinearFilter != b.TrilinearFilter ||
    00166                                 AnisotropicFilter != b.AnisotropicFilter ||
    00167                                 LODBias != b.LODBias;
    00168                         if (different)
    00169                                 return true;
    00170                         else
    00171                                 different |= (TextureMatrix != b.TextureMatrix) &&
    00172                                         TextureMatrix && b.TextureMatrix &&
    00173                                         (*TextureMatrix != *(b.TextureMatrix));
    00174                         return different;
    00175                 }
    00176
    00178
    00180                 inline bool operator==(const SMaterialLayer& b) const
    00181                 { return !(b!=*this); }
    00182
    00184                 ITexture* Texture;
    00185
    00187
    00188                 u8 TextureWrapU:4;
    00189                 u8 TextureWrapV:4;
    00190
    00192                 bool BilinearFilter:1;
    00193
    00195
    00197                 bool TrilinearFilter:1;
    00198
    00200
    00206                 u8 AnisotropicFilter;
    00207
    00209
    00213                 s8 LODBias;
    00214
    00215         private:
    00216                 friend class SMaterial;
    00217                 irr::core::irrAllocator<irr::core::matrix4> MatrixAllocator;
    00218
    00220
    00222                 core::matrix4* TextureMatrix;
    00223         };
    00224
    00225 } // end namespace video
    00226 } // end namespace irr
    00227
    00228 #endif // __S_MATERIAL_LAYER_H_INCLUDED__

| The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Sun Oct 24 12:41:58 2010 by Doxygen (1.6.2)