Loading...
Searching...
No Matches
SMaterialLayer.h
Go to the documentation of this file.
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __S_MATERIAL_LAYER_H_INCLUDED__
#define __S_MATERIAL_LAYER_H_INCLUDED__
#include "matrix4.h"
#include "irrAllocator.h"
namespace irr
{
namespace video
{
class ITexture;
enum E_TEXTURE_CLAMP
{
ETC_REPEAT = 0,
ETC_CLAMP,
ETC_CLAMP_TO_EDGE,
ETC_CLAMP_TO_BORDER,
ETC_MIRROR,
ETC_MIRROR_CLAMP,
ETC_MIRROR_CLAMP_TO_EDGE,
ETC_MIRROR_CLAMP_TO_BORDER
};
static const char* const aTextureClampNames[] = {
"texture_clamp_repeat",
"texture_clamp_clamp",
"texture_clamp_clamp_to_edge",
"texture_clamp_clamp_to_border",
"texture_clamp_mirror",
"texture_clamp_mirror_clamp",
"texture_clamp_mirror_clamp_to_edge",
"texture_clamp_mirror_clamp_to_border", 0};
class SMaterialLayer
{
public:
SMaterialLayer()
: Texture(0),
TextureWrapU(ETC_REPEAT),
TextureWrapV(ETC_REPEAT),
BilinearFilter(true),
TrilinearFilter(false),
AnisotropicFilter(0),
LODBias(0),
TextureMatrix(0)
{}
SMaterialLayer(const SMaterialLayer& other)
{
// This pointer is checked during assignment
TextureMatrix = 0;
*this = other;
}
~SMaterialLayer()
{
MatrixAllocator.destruct(TextureMatrix);
MatrixAllocator.deallocate(TextureMatrix);
}
SMaterialLayer& operator=(const SMaterialLayer& other)
{
// Check for self-assignment!
if (this == &other)
return *this;
Texture = other.Texture;
if (TextureMatrix)
{
if (other.TextureMatrix)
*TextureMatrix = *other.TextureMatrix;
else
{
MatrixAllocator.destruct(TextureMatrix);
MatrixAllocator.deallocate(TextureMatrix);
TextureMatrix = 0;
}
}
else
{
if (other.TextureMatrix)
{
TextureMatrix = MatrixAllocator.allocate(1);
MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix);
}
else
TextureMatrix = 0;
}
TextureWrapU = other.TextureWrapU;
TextureWrapV = other.TextureWrapV;
BilinearFilter = other.BilinearFilter;
TrilinearFilter = other.TrilinearFilter;
AnisotropicFilter = other.AnisotropicFilter;
LODBias = other.LODBias;
return *this;
}
core::matrix4& getTextureMatrix()
{
if (!TextureMatrix)
{
TextureMatrix = MatrixAllocator.allocate(1);
MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix);
}
return *TextureMatrix;
}
const core::matrix4& getTextureMatrix() const
{
if (TextureMatrix)
return *TextureMatrix;
else
return core::IdentityMatrix;
}
void setTextureMatrix(const core::matrix4& mat)
{
if (!TextureMatrix)
{
TextureMatrix = MatrixAllocator.allocate(1);
MatrixAllocator.construct(TextureMatrix,mat);
}
else
*TextureMatrix = mat;
}
inline bool operator!=(const SMaterialLayer& b) const
{
bool different =
Texture != b.Texture ||
TextureWrapU != b.TextureWrapU ||
TextureWrapV != b.TextureWrapV ||
BilinearFilter != b.BilinearFilter ||
TrilinearFilter != b.TrilinearFilter ||
AnisotropicFilter != b.AnisotropicFilter ||
LODBias != b.LODBias;
if (different)
return true;
else
different |= (TextureMatrix != b.TextureMatrix) &&
TextureMatrix && b.TextureMatrix &&
(*TextureMatrix != *(b.TextureMatrix));
return different;
}
inline bool operator==(const SMaterialLayer& b) const
{ return !(b!=*this); }
ITexture* Texture;
u8 TextureWrapU:4;
u8 TextureWrapV:4;
bool BilinearFilter:1;
bool TrilinearFilter:1;
u8 AnisotropicFilter;
s8 LODBias;
private:
friend class SMaterial;
irr::core::irrAllocator<irr::core::matrix4> MatrixAllocator;
core::matrix4* TextureMatrix;
};
} // end namespace video
} // end namespace irr
#endif // __S_MATERIAL_LAYER_H_INCLUDED__
irr::core::irrAllocator
Very simple allocator implementation, containers using it can be used across dll boundaries.
Definition irrAllocator.h:26
irr::video::ITexture
Interface of a Video Driver dependent Texture.
Definition ITexture.h:99
irr::video::SMaterialLayer::operator==
bool operator==(const SMaterialLayer &b) const
Equality operator.
Definition SMaterialLayer.h:180
irr::video::SMaterialLayer::setTextureMatrix
void setTextureMatrix(const core::matrix4 &mat)
Sets the texture transformation matrix to mat.
Definition SMaterialLayer.h:144
irr::video::SMaterialLayer::SMaterial
friend class SMaterial
Definition SMaterialLayer.h:216
irr::video::SMaterialLayer::operator!=
bool operator!=(const SMaterialLayer &b) const
Inequality operator.
Definition SMaterialLayer.h:158
irr::video::SMaterialLayer::~SMaterialLayer
~SMaterialLayer()
Destructor.
Definition SMaterialLayer.h:73
irr::video::SMaterialLayer::LODBias
s8 LODBias
Bias for the mipmap choosing decision.
Definition SMaterialLayer.h:213
irr::video::SMaterialLayer::getTextureMatrix
const core::matrix4 & getTextureMatrix() const
Gets the immutable texture transformation matrix.
Definition SMaterialLayer.h:134
irr::video::SMaterialLayer::operator=
SMaterialLayer & operator=(const SMaterialLayer &other)
Assignment operator.
Definition SMaterialLayer.h:82
irr::video::SMaterialLayer::BilinearFilter
bool BilinearFilter
Is bilinear filtering enabled? Default: true.
Definition SMaterialLayer.h:192
irr::video::SMaterialLayer::SMaterialLayer
SMaterialLayer()
Default constructor.
Definition SMaterialLayer.h:52
irr::video::SMaterialLayer::TextureWrapV
u8 TextureWrapV
Definition SMaterialLayer.h:189
irr::video::SMaterialLayer::getTextureMatrix
core::matrix4 & getTextureMatrix()
Gets the texture transformation matrix.
Definition SMaterialLayer.h:122
irr::video::SMaterialLayer::TrilinearFilter
bool TrilinearFilter
Is trilinear filtering enabled? Default: false.
Definition SMaterialLayer.h:197
irr::video::SMaterialLayer::AnisotropicFilter
u8 AnisotropicFilter
Is anisotropic filtering enabled? Default: 0, disabled.
Definition SMaterialLayer.h:206
irr::video::SMaterialLayer::Texture
ITexture * Texture
Texture.
Definition SMaterialLayer.h:184
irr::video::SMaterialLayer::TextureWrapU
u8 TextureWrapU
Texture Clamp Mode.
Definition SMaterialLayer.h:188
irr::video::SMaterialLayer::SMaterialLayer
SMaterialLayer(const SMaterialLayer &other)
Copy constructor.
Definition SMaterialLayer.h:65
irrAllocator.h
matrix4.h
irr::core::matrix4
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2235
irr::core::IdentityMatrix
IRRLICHT_API const matrix4 IdentityMatrix
global const identity matrix
irr::video
The video namespace contains classes for accessing the video driver. All 2d and 3d rendering is done ...
Definition EDriverFeatures.h:11
irr::video::E_TEXTURE_CLAMP
E_TEXTURE_CLAMP
Texture coord clamp mode outside [0.0, 1.0].
Definition SMaterialLayer.h:19
irr::video::ETC_REPEAT
@ ETC_REPEAT
Texture repeats.
Definition SMaterialLayer.h:21
irr::video::ETC_CLAMP
@ ETC_CLAMP
Texture is clamped to the last pixel.
Definition SMaterialLayer.h:23
irr::video::ETC_CLAMP_TO_BORDER
@ ETC_CLAMP_TO_BORDER
Texture is clamped to the border pixel (if exists).
Definition SMaterialLayer.h:27
irr::video::ETC_MIRROR_CLAMP_TO_BORDER
@ ETC_MIRROR_CLAMP_TO_BORDER
Texture is mirrored once and then clamped to border.
Definition SMaterialLayer.h:35
irr::video::ETC_MIRROR
@ ETC_MIRROR
Texture is alternatingly mirrored (0..1..0..1..0..).
Definition SMaterialLayer.h:29
irr::video::ETC_MIRROR_CLAMP_TO_EDGE
@ ETC_MIRROR_CLAMP_TO_EDGE
Texture is mirrored once and then clamped to edge.
Definition SMaterialLayer.h:33
irr::video::ETC_MIRROR_CLAMP
@ ETC_MIRROR_CLAMP
Texture is mirrored once and then clamped (0..1..0).
Definition SMaterialLayer.h:31
irr::video::ETC_CLAMP_TO_EDGE
@ ETC_CLAMP_TO_EDGE
Texture is clamped to the edge pixel.
Definition SMaterialLayer.h:25
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
irr::u8
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.h:18
irr::s8
signed char s8
8 bit signed variable.
Definition irrTypes.h:26
- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0