arsa  2.7
SMaterialLayer.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __S_MATERIAL_LAYER_H_INCLUDED__
6 #define __S_MATERIAL_LAYER_H_INCLUDED__
7 
8 #include "matrix4.h"
9 #include "irrAllocator.h"
10 
11 namespace irr
12 {
13 namespace video
14 {
15  class ITexture;
16 
19  {
36  };
37  static const char* const aTextureClampNames[] = {
38  "texture_clamp_repeat",
39  "texture_clamp_clamp",
40  "texture_clamp_clamp_to_edge",
41  "texture_clamp_clamp_to_border",
42  "texture_clamp_mirror",
43  "texture_clamp_mirror_clamp",
44  "texture_clamp_mirror_clamp_to_edge",
45  "texture_clamp_mirror_clamp_to_border", 0};
46 
48  // Note for implementors: Serialization is in CNullDriver
50  {
51  public:
54  BilinearFilter(true), TrilinearFilter(false), AnisotropicFilter(0), LODBias(0), TextureMatrix(0)
55  {
56  }
57 
59 
61  {
62  // This pointer is checked during assignment
63  TextureMatrix = 0;
64  *this = other;
65  }
66 
69  {
70  if ( TextureMatrix )
71  {
72  MatrixAllocator.destruct(TextureMatrix);
73  MatrixAllocator.deallocate(TextureMatrix);
74  }
75  }
76 
78 
81  {
82  // Check for self-assignment!
83  if (this == &other)
84  return *this;
85 
86  Texture = other.Texture;
87  if (TextureMatrix)
88  {
89  if (other.TextureMatrix)
90  *TextureMatrix = *other.TextureMatrix;
91  else
92  {
93  MatrixAllocator.destruct(TextureMatrix);
94  MatrixAllocator.deallocate(TextureMatrix);
95  TextureMatrix = 0;
96  }
97  }
98  else
99  {
100  if (other.TextureMatrix)
101  {
102  TextureMatrix = MatrixAllocator.allocate(1);
103  MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix);
104  }
105  else
106  TextureMatrix = 0;
107  }
108  TextureWrapU = other.TextureWrapU;
109  TextureWrapV = other.TextureWrapV;
110  TextureWrapW = other.TextureWrapW;
114  LODBias = other.LODBias;
115 
116  return *this;
117  }
118 
120 
122  {
123  if (!TextureMatrix)
124  {
125  TextureMatrix = MatrixAllocator.allocate(1);
126  MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix);
127  }
128  return *TextureMatrix;
129  }
130 
132 
134  {
135  if (TextureMatrix)
136  return *TextureMatrix;
137  else
138  return core::IdentityMatrix;
139  }
140 
142 
146  {
147  if (!TextureMatrix)
148  {
149  TextureMatrix = MatrixAllocator.allocate(1);
150  MatrixAllocator.construct(TextureMatrix,mat);
151  }
152  else
153  *TextureMatrix = mat;
154  }
155 
157 
159  inline bool operator!=(const SMaterialLayer& b) const
160  {
161  bool different =
162  Texture != b.Texture ||
163  TextureWrapU != b.TextureWrapU ||
164  TextureWrapV != b.TextureWrapV ||
165  TextureWrapW != b.TextureWrapW ||
166  BilinearFilter != b.BilinearFilter ||
167  TrilinearFilter != b.TrilinearFilter ||
168  AnisotropicFilter != b.AnisotropicFilter ||
169  LODBias != b.LODBias;
170  if (different)
171  return true;
172  else
173  different |= (TextureMatrix != b.TextureMatrix) &&
174  (!TextureMatrix || !b.TextureMatrix || (*TextureMatrix != *(b.TextureMatrix)));
175  return different;
176  }
177 
179 
181  inline bool operator==(const SMaterialLayer& b) const
182  { return !(b!=*this); }
183 
186 
188 
192 
195 
197 
200 
202 
209 
211 
216 
217  private:
218  friend class SMaterial;
220 
222 
224  core::matrix4* TextureMatrix;
225  };
226 
227 } // end namespace video
228 } // end namespace irr
229 
230 #endif // __S_MATERIAL_LAYER_H_INCLUDED__
SMaterialLayer & operator=(const SMaterialLayer &other)
Assignment operator.
SMaterialLayer(const SMaterialLayer &other)
Copy constructor.
IRRLICHT_API const matrix4 IdentityMatrix
global const identity matrix
const core::matrix4 & getTextureMatrix() const
Gets the immutable texture transformation matrix.
Texture is clamped to the border pixel (if exists)
Texture is alternatingly mirrored (0..1..0..1..0..)
bool TrilinearFilter
Is trilinear filtering enabled? Default: false.
u8 TextureWrapU
Texture Clamp Mode.
bool operator==(const SMaterialLayer &b) const
Equality operator.
Texture is clamped to the edge pixel.
Texture is clamped to the last pixel.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: CARSADPad.h:6
unsigned char u8
8 bit unsigned variable.
Definition: irrTypes.h:22
SMaterialLayer()
Default constructor.
Texture repeats.
Struct for holding material parameters which exist per texture layer.
core::matrix4 & getTextureMatrix()
Gets the texture transformation matrix.
ITexture * Texture
Texture.
signed char s8
8 bit signed variable.
Definition: irrTypes.h:30
u8 AnisotropicFilter
Is anisotropic filtering enabled? Default: 0, disabled.
bool BilinearFilter
Is bilinear filtering enabled? Default: true.
bool operator!=(const SMaterialLayer &b) const
Inequality operator.
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition: matrix4.h:45
GLboolean GLboolean GLboolean b
Interface of a Video Driver dependent Texture.
Definition: ITexture.h:177
s8 LODBias
Bias for the mipmap choosing decision.
Texture is mirrored once and then clamped to edge.
Texture is mirrored once and then clamped (0..1..0)
Very simple allocator implementation, containers using it can be used across dll boundaries.
Definition: irrAllocator.h:25
Texture is mirrored once and then clamped to border.
Struct for holding parameters for a material renderer.
Definition: SMaterial.h:304
E_TEXTURE_CLAMP
Texture coord clamp mode outside [0.0, 1.0].
void setTextureMatrix(const core::matrix4 &mat)
Sets the texture transformation matrix to mat.