Irrlicht 3D Engine
 
Loading...
Searching...
No Matches
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
11namespace irr
12{
13namespace video
14{
15 class ITexture;
16
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
49 {
50 public:
53 : Texture(0),
56 BilinearFilter(true),
57 TrilinearFilter(false),
59 LODBias(0),
60 TextureMatrix(0)
61 {}
62
64
66 {
67 // This pointer is checked during assignment
68 TextureMatrix = 0;
69 *this = other;
70 }
71
74 {
75 MatrixAllocator.destruct(TextureMatrix);
76 MatrixAllocator.deallocate(TextureMatrix);
77 }
78
80
83 {
84 // Check for self-assignment!
85 if (this == &other)
86 return *this;
87
88 Texture = other.Texture;
89 if (TextureMatrix)
90 {
91 if (other.TextureMatrix)
92 *TextureMatrix = *other.TextureMatrix;
93 else
94 {
95 MatrixAllocator.destruct(TextureMatrix);
96 MatrixAllocator.deallocate(TextureMatrix);
97 TextureMatrix = 0;
98 }
99 }
100 else
101 {
102 if (other.TextureMatrix)
103 {
104 TextureMatrix = MatrixAllocator.allocate(1);
105 MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix);
106 }
107 else
108 TextureMatrix = 0;
109 }
115 LODBias = other.LODBias;
116
117 return *this;
118 }
119
121
123 {
124 if (!TextureMatrix)
125 {
126 TextureMatrix = MatrixAllocator.allocate(1);
127 MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix);
128 }
129 return *TextureMatrix;
130 }
131
133
135 {
136 if (TextureMatrix)
137 return *TextureMatrix;
138 else
140 }
141
143
145 {
146 if (!TextureMatrix)
147 {
148 TextureMatrix = MatrixAllocator.allocate(1);
149 MatrixAllocator.construct(TextureMatrix,mat);
150 }
151 else
152 *TextureMatrix = mat;
153 }
154
156
158 inline bool operator!=(const SMaterialLayer& b) const
159 {
160 bool different =
161 Texture != b.Texture ||
167 LODBias != b.LODBias;
168 if (different)
169 return true;
170 else
171 different |= (TextureMatrix != b.TextureMatrix) &&
172 TextureMatrix && b.TextureMatrix &&
173 (*TextureMatrix != *(b.TextureMatrix));
174 return different;
175 }
176
178
180 inline bool operator==(const SMaterialLayer& b) const
181 { return !(b!=*this); }
182
185
187
190
193
195
198
200
207
209
214
215 private:
216 friend class SMaterial;
218
220
222 core::matrix4* TextureMatrix;
223 };
224
225} // end namespace video
226} // end namespace irr
227
228#endif // __S_MATERIAL_LAYER_H_INCLUDED__
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.h:46
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
Interface of a Video Driver dependent Texture.
Definition ITexture.h:99
Struct for holding parameters for a material renderer.
Definition SMaterial.h:227
Struct for holding material parameters which exist per texture layer.
bool operator==(const SMaterialLayer &b) const
Equality operator.
void setTextureMatrix(const core::matrix4 &mat)
Sets the texture transformation matrix to mat.
bool operator!=(const SMaterialLayer &b) const
Inequality operator.
s8 LODBias
Bias for the mipmap choosing decision.
const core::matrix4 & getTextureMatrix() const
Gets the immutable texture transformation matrix.
SMaterialLayer & operator=(const SMaterialLayer &other)
Assignment operator.
bool BilinearFilter
Is bilinear filtering enabled? Default: true.
SMaterialLayer()
Default constructor.
core::matrix4 & getTextureMatrix()
Gets the texture transformation matrix.
bool TrilinearFilter
Is trilinear filtering enabled? Default: false.
u8 AnisotropicFilter
Is anisotropic filtering enabled? Default: 0, disabled.
ITexture * Texture
Texture.
u8 TextureWrapU
Texture Clamp Mode.
SMaterialLayer(const SMaterialLayer &other)
Copy constructor.
IRRLICHT_API const matrix4 IdentityMatrix
global const identity matrix
E_TEXTURE_CLAMP
Texture coord clamp mode outside [0.0, 1.0].
@ ETC_REPEAT
Texture repeats.
@ ETC_CLAMP
Texture is clamped to the last pixel.
@ ETC_CLAMP_TO_BORDER
Texture is clamped to the border pixel (if exists)
@ ETC_MIRROR_CLAMP_TO_BORDER
Texture is mirrored once and then clamped to border.
@ ETC_MIRROR
Texture is alternatingly mirrored (0..1..0..1..0..)
@ ETC_MIRROR_CLAMP_TO_EDGE
Texture is mirrored once and then clamped to edge.
@ ETC_MIRROR_CLAMP
Texture is mirrored once and then clamped (0..1..0)
@ ETC_CLAMP_TO_EDGE
Texture is clamped to the edge pixel.
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.h:18
signed char s8
8 bit signed variable.
Definition irrTypes.h:26