Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
SMaterialLayer.hpp
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 nirtcpp/nirtcpp.hpp
4
5#ifndef S_MATERIAL_LAYER_HPP_INCLUDED
6#define S_MATERIAL_LAYER_HPP_INCLUDED
7
8#include <nirtcpp/core/engine/matrix4.hpp>
9#include <nirtcpp/core/engine/irrAllocator.hpp>
10
11namespace nirt
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
48 // Note for implementors: Serialization is in CNullDriver
50 {
51 public:
53 SMaterialLayer() : Texture(0), TextureWrapU(ETC_REPEAT), TextureWrapV(ETC_REPEAT), TextureWrapW(ETC_REPEAT),
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 }
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
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 ||
164 TextureWrapV != b.TextureWrapV ||
165 TextureWrapW != b.TextureWrapW ||
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
190 u8 TextureWrapV:4;
191 u8 TextureWrapW:4;
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 nirt
229
230#endif // S_MATERIAL_LAYER_HPP_INCLUDED
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.hpp:49
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
Interface of a Video Driver dependent Texture.
Definition ITexture.hpp:186
Struct for holding material parameters which exist per texture layer.
Definition SMaterialLayer.hpp:50
bool TrilinearFilter
Is trilinear filtering enabled? Default: false.
Definition SMaterialLayer.hpp:199
s8 LODBias
Bias for the mipmap choosing decision.
Definition SMaterialLayer.hpp:215
bool operator==(const SMaterialLayer &b) const
Equality operator.
Definition SMaterialLayer.hpp:181
ITexture * Texture
Texture.
Definition SMaterialLayer.hpp:185
u8 TextureWrapU
Texture Clamp Mode.
Definition SMaterialLayer.hpp:189
SMaterialLayer & operator=(const SMaterialLayer &other)
Assignment operator.
Definition SMaterialLayer.hpp:80
SMaterialLayer()
Default constructor.
Definition SMaterialLayer.hpp:53
const core::matrix4 & getTextureMatrix() const
Gets the immutable texture transformation matrix.
Definition SMaterialLayer.hpp:133
u8 AnisotropicFilter
Is anisotropic filtering enabled? Default: 0, disabled.
Definition SMaterialLayer.hpp:208
void setTextureMatrix(const core::matrix4 &mat)
Sets the texture transformation matrix to mat.
Definition SMaterialLayer.hpp:145
SMaterialLayer(const SMaterialLayer &other)
Copy constructor.
Definition SMaterialLayer.hpp:60
bool operator!=(const SMaterialLayer &b) const
Inequality operator.
Definition SMaterialLayer.hpp:159
~SMaterialLayer()
Destructor.
Definition SMaterialLayer.hpp:68
core::matrix4 & getTextureMatrix()
Gets the texture transformation matrix.
Definition SMaterialLayer.hpp:121
bool BilinearFilter
Is bilinear filtering enabled? Default: true.
Definition SMaterialLayer.hpp:194
Struct for holding parameters for a material renderer.
Definition SMaterial.hpp:304
NIRTCPP_API const matrix4 IdentityMatrix
global const identity matrix
E_TEXTURE_CLAMP
Texture coord clamp mode outside [0.0, 1.0].
Definition SMaterialLayer.hpp:19
@ ETC_REPEAT
Texture repeats.
Definition SMaterialLayer.hpp:21
@ ETC_CLAMP_TO_BORDER
Texture is clamped to the border pixel (if exists)
Definition SMaterialLayer.hpp:27
@ ETC_MIRROR
Texture is alternatingly mirrored (0..1..0..1..0..)
Definition SMaterialLayer.hpp:29
@ ETC_MIRROR_CLAMP_TO_BORDER
Texture is mirrored once and then clamped to border.
Definition SMaterialLayer.hpp:35
@ ETC_CLAMP
Texture is clamped to the last pixel.
Definition SMaterialLayer.hpp:23
@ ETC_CLAMP_TO_EDGE
Texture is clamped to the edge pixel.
Definition SMaterialLayer.hpp:25
@ ETC_MIRROR_CLAMP_TO_EDGE
Texture is mirrored once and then clamped to edge.
Definition SMaterialLayer.hpp:33
@ ETC_MIRROR_CLAMP
Texture is mirrored once and then clamped (0..1..0)
Definition SMaterialLayer.hpp:31
As of Nirtcpp 1.6, position2d is a synonym for vector2d.
Definition vector3d.hpp:11
signed char s8
8 bit signed variable.
Definition irrTypes.hpp:32
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.hpp:24

Nirtcpp    @cppfx.xyz

Utxcpp    utx::print