Loading...
Searching...
No Matches
S3DVertex.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_3D_VERTEX_H_INCLUDED__
#define __S_3D_VERTEX_H_INCLUDED__
#include "vector3d.h"
#include "vector2d.h"
#include "SColor.h"
namespace irr
{
namespace video
{
enum E_VERTEX_TYPE
{
EVT_STANDARD = 0,
EVT_2TCOORDS,
EVT_TANGENTS
};
const char* const sBuiltInVertexTypeNames[] =
{
"standard",
"2tcoords",
"tangents",
0
};
struct S3DVertex
{
S3DVertex() {}
S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
: Pos(x,y,z), Normal(nx,ny,nz), Color(c), TCoords(tu,tv) {}
S3DVertex(const core::vector3df& pos, const core::vector3df& normal,
SColor color, const core::vector2d<f32>& tcoords)
: Pos(pos), Normal(normal), Color(color), TCoords(tcoords) {}
core::vector3df Pos;
core::vector3df Normal;
SColor Color;
core::vector2d<f32> TCoords;
bool operator==(const S3DVertex& other) const
{
return ((Pos == other.Pos) && (Normal == other.Normal) &&
(Color == other.Color) && (TCoords == other.TCoords));
}
bool operator!=(const S3DVertex& other) const
{
return ((Pos != other.Pos) || (Normal != other.Normal) ||
(Color != other.Color) || (TCoords != other.TCoords));
}
bool operator<(const S3DVertex& other) const
{
return ((Pos < other.Pos) ||
((Pos == other.Pos) && (Normal < other.Normal)) ||
((Pos == other.Pos) && (Normal == other.Normal) && (Color < other.Color)) ||
((Pos == other.Pos) && (Normal == other.Normal) && (Color == other.Color) && (TCoords < other.TCoords)));
}
E_VERTEX_TYPE getType() const
{
return EVT_STANDARD;
}
//\param d d=0 returns other, d=1 returns this, values between interpolate.
S3DVertex getInterpolated(const S3DVertex& other, f32 d)
{
d = core::clamp(d, 0.0f, 1.0f);
return S3DVertex(Pos.getInterpolated(other.Pos, d),
Normal.getInterpolated(other.Normal, d),
Color.getInterpolated(other.Color, d),
TCoords.getInterpolated(other.TCoords, d));
}
};
struct S3DVertex2TCoords : public S3DVertex
{
S3DVertex2TCoords() : S3DVertex() {}
S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
: S3DVertex(x,y,z, 0.0f, 0.0f, 0.0f, c, tu,tv), TCoords2(tu2,tv2) {}
S3DVertex2TCoords(const core::vector3df& pos, SColor color,
const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2)
: S3DVertex(pos, core::vector3df(), color, tcoords), TCoords2(tcoords2) {}
S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, const SColor& color,
const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2)
: S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords2) {}
S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
: S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu2,tv2) {}
S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
: S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu,tv) {}
S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal,
SColor color, const core::vector2d<f32>& tcoords)
: S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords) {}
S3DVertex2TCoords(S3DVertex& o) : S3DVertex(o) {}
core::vector2d<f32> TCoords2;
bool operator==(const S3DVertex2TCoords& other) const
{
return ((static_cast<S3DVertex>(*this)==other) &&
(TCoords2 == other.TCoords2));
}
bool operator!=(const S3DVertex2TCoords& other) const
{
return ((static_cast<S3DVertex>(*this)!=other) ||
(TCoords2 != other.TCoords2));
}
bool operator<(const S3DVertex2TCoords& other) const
{
return ((static_cast<S3DVertex>(*this) < other) ||
((static_cast<S3DVertex>(*this) == other) && (TCoords2 < other.TCoords2)));
}
E_VERTEX_TYPE getType() const
{
return EVT_2TCOORDS;
}
//\param d d=0 returns other, d=1 returns this, values between interpolate.
S3DVertex2TCoords getInterpolated(const S3DVertex2TCoords& other, f32 d)
{
d = core::clamp(d, 0.0f, 1.0f);
return S3DVertex2TCoords(Pos.getInterpolated(other.Pos, d),
Normal.getInterpolated(other.Normal, d),
Color.getInterpolated(other.Color, d),
TCoords.getInterpolated(other.TCoords, d),
TCoords2.getInterpolated(other.TCoords2, d));
}
};
struct S3DVertexTangents : public S3DVertex
{
S3DVertexTangents() : S3DVertex() { }
S3DVertexTangents(f32 x, f32 y, f32 z, f32 nx=0.0f, f32 ny=0.0f, f32 nz=0.0f,
SColor c = 0xFFFFFFFF, f32 tu=0.0f, f32 tv=0.0f,
f32 tanx=0.0f, f32 tany=0.0f, f32 tanz=0.0f,
f32 bx=0.0f, f32 by=0.0f, f32 bz=0.0f)
: S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), Tangent(tanx,tany,tanz), Binormal(bx,by,bz) { }
S3DVertexTangents(const core::vector3df& pos, SColor c,
const core::vector2df& tcoords)
: S3DVertex(pos, core::vector3df(), c, tcoords) { }
S3DVertexTangents(const core::vector3df& pos,
const core::vector3df& normal, SColor c,
const core::vector2df& tcoords,
const core::vector3df& tangent=core::vector3df(),
const core::vector3df& binormal=core::vector3df())
: S3DVertex(pos, normal, c, tcoords), Tangent(tangent), Binormal(binormal) { }
core::vector3df Tangent;
core::vector3df Binormal;
bool operator==(const S3DVertexTangents& other) const
{
return ((static_cast<S3DVertex>(*this)==other) &&
(Tangent == other.Tangent) &&
(Binormal == other.Binormal));
}
bool operator!=(const S3DVertexTangents& other) const
{
return ((static_cast<S3DVertex>(*this)!=other) ||
(Tangent != other.Tangent) ||
(Binormal != other.Binormal));
}
bool operator<(const S3DVertexTangents& other) const
{
return ((static_cast<S3DVertex>(*this) < other) ||
((static_cast<S3DVertex>(*this) == other) && (Tangent < other.Tangent)) ||
((static_cast<S3DVertex>(*this) == other) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
}
E_VERTEX_TYPE getType() const
{
return EVT_TANGENTS;
}
S3DVertexTangents getInterpolated(const S3DVertexTangents& other, f32 d)
{
d = core::clamp(d, 0.0f, 1.0f);
return S3DVertexTangents(Pos.getInterpolated(other.Pos, d),
Normal.getInterpolated(other.Normal, d),
Color.getInterpolated(other.Color, d),
TCoords.getInterpolated(other.TCoords, d),
Tangent.getInterpolated(other.Tangent, d),
Binormal.getInterpolated(other.Binormal, d));
}
};
inline u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType)
{
switch (vertexType)
{
case video::EVT_2TCOORDS:
return sizeof(video::S3DVertex2TCoords);
case video::EVT_TANGENTS:
return sizeof(video::S3DVertexTangents);
default:
return sizeof(video::S3DVertex);
}
}
} // end namespace video
} // end namespace irr
#endif
SColor.h
irr::core::vector2d
2d vector template class with lots of operators and methods.
Definition vector2d.h:22
irr::video::SColor
Class representing a 32 bit ARGB color.
Definition SColor.h:202
irr::core
Basic classes such as vectors, planes, arrays, lists, and so on can be found in this namespace.
Definition aabbox3d.h:15
irr::core::vector3df
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
irr::core::vector2df
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition vector2d.h:323
irr::core::clamp
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition irrMath.h:166
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_VERTEX_TYPE
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.h:19
irr::video::EVT_2TCOORDS
@ EVT_2TCOORDS
Vertex with two texture coordinates, video::S3DVertex2TCoords.
Definition S3DVertex.h:25
irr::video::EVT_TANGENTS
@ EVT_TANGENTS
Vertex with a tangent and binormal vector, video::S3DVertexTangents.
Definition S3DVertex.h:29
irr::video::EVT_STANDARD
@ EVT_STANDARD
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition S3DVertex.h:21
irr::video::sBuiltInVertexTypeNames
const char *const sBuiltInVertexTypeNames[]
Array holding the built in vertex type names.
Definition S3DVertex.h:33
irr::video::getVertexPitchFromType
u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType)
Definition S3DVertex.h:258
irr
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
irr::f32
float f32
32 bit floating point variable.
Definition irrTypes.h:104
irr::u32
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
irr::video::S3DVertex2TCoords
Vertex with two texture coordinates.
Definition S3DVertex.h:110
irr::video::S3DVertex2TCoords::getInterpolated
S3DVertex2TCoords getInterpolated(const S3DVertex2TCoords &other, f32 d)
Definition S3DVertex.h:173
irr::video::S3DVertex2TCoords::operator!=
bool operator!=(const S3DVertex2TCoords &other) const
Inequality operator.
Definition S3DVertex.h:155
irr::video::S3DVertex2TCoords::operator<
bool operator<(const S3DVertex2TCoords &other) const
Definition S3DVertex.h:161
irr::video::S3DVertex2TCoords::S3DVertex2TCoords
S3DVertex2TCoords()
default constructor
Definition S3DVertex.h:112
irr::video::S3DVertex2TCoords::TCoords2
core::vector2d< f32 > TCoords2
Second set of texture coordinates.
Definition S3DVertex.h:145
irr::video::S3DVertex2TCoords::S3DVertex2TCoords
S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
constructor with the same texture coords and normal
Definition S3DVertex.h:133
irr::video::S3DVertex2TCoords::S3DVertex2TCoords
S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
constructor with two different texture coords, but no normal
Definition S3DVertex.h:115
irr::video::S3DVertex2TCoords::operator==
bool operator==(const S3DVertex2TCoords &other) const
Equality operator.
Definition S3DVertex.h:148
irr::video::S3DVertex2TCoords::S3DVertex2TCoords
S3DVertex2TCoords(const core::vector3df &pos, SColor color, const core::vector2d< f32 > &tcoords, const core::vector2d< f32 > &tcoords2)
constructor with two different texture coords, but no normal
Definition S3DVertex.h:119
irr::video::S3DVertex2TCoords::S3DVertex2TCoords
S3DVertex2TCoords(S3DVertex &o)
constructor from S3DVertex
Definition S3DVertex.h:142
irr::video::S3DVertex2TCoords::getType
E_VERTEX_TYPE getType() const
Definition S3DVertex.h:167
irr::video::S3DVertex2TCoords::S3DVertex2TCoords
S3DVertex2TCoords(const core::vector3df &pos, const core::vector3df &normal, SColor color, const core::vector2d< f32 > &tcoords)
constructor with the same texture coords and normal
Definition S3DVertex.h:137
irr::video::S3DVertex2TCoords::S3DVertex2TCoords
S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
constructor with all values
Definition S3DVertex.h:129
irr::video::S3DVertex2TCoords::S3DVertex2TCoords
S3DVertex2TCoords(const core::vector3df &pos, const core::vector3df &normal, const SColor &color, const core::vector2d< f32 > &tcoords, const core::vector2d< f32 > &tcoords2)
constructor with all values
Definition S3DVertex.h:124
irr::video::S3DVertex
standard vertex used by the Irrlicht engine.
Definition S3DVertex.h:43
irr::video::S3DVertex::TCoords
core::vector2d< f32 > TCoords
Texture coordinates.
Definition S3DVertex.h:66
irr::video::S3DVertex::operator!=
bool operator!=(const S3DVertex &other) const
Definition S3DVertex.h:74
irr::video::S3DVertex::S3DVertex
S3DVertex()
default constructor
Definition S3DVertex.h:45
irr::video::S3DVertex::S3DVertex
S3DVertex(const core::vector3df &pos, const core::vector3df &normal, SColor color, const core::vector2d< f32 > &tcoords)
constructor
Definition S3DVertex.h:52
irr::video::S3DVertex::Normal
core::vector3df Normal
Normal vector.
Definition S3DVertex.h:60
irr::video::S3DVertex::Color
SColor Color
Color.
Definition S3DVertex.h:63
irr::video::S3DVertex::S3DVertex
S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
constructor
Definition S3DVertex.h:48
irr::video::S3DVertex::getType
E_VERTEX_TYPE getType() const
Definition S3DVertex.h:88
irr::video::S3DVertex::operator<
bool operator<(const S3DVertex &other) const
Definition S3DVertex.h:80
irr::video::S3DVertex::Pos
core::vector3df Pos
Position.
Definition S3DVertex.h:57
irr::video::S3DVertex::operator==
bool operator==(const S3DVertex &other) const
Definition S3DVertex.h:68
irr::video::S3DVertex::getInterpolated
S3DVertex getInterpolated(const S3DVertex &other, f32 d)
Definition S3DVertex.h:94
irr::video::S3DVertexTangents
Vertex with a tangent and binormal vector.
Definition S3DVertex.h:188
irr::video::S3DVertexTangents::S3DVertexTangents
S3DVertexTangents(const core::vector3df &pos, const core::vector3df &normal, SColor c, const core::vector2df &tcoords, const core::vector3df &tangent=core::vector3df(), const core::vector3df &binormal=core::vector3df())
constructor
Definition S3DVertex.h:205
irr::video::S3DVertexTangents::getType
E_VERTEX_TYPE getType() const
Definition S3DVertex.h:239
irr::video::S3DVertexTangents::Binormal
core::vector3df Binormal
Binormal vector (tangent x normal).
Definition S3DVertex.h:216
irr::video::S3DVertexTangents::Tangent
core::vector3df Tangent
Tangent vector along the x-axis of the texture.
Definition S3DVertex.h:213
irr::video::S3DVertexTangents::S3DVertexTangents
S3DVertexTangents(const core::vector3df &pos, SColor c, const core::vector2df &tcoords)
constructor
Definition S3DVertex.h:200
irr::video::S3DVertexTangents::S3DVertexTangents
S3DVertexTangents()
default constructor
Definition S3DVertex.h:190
irr::video::S3DVertexTangents::S3DVertexTangents
S3DVertexTangents(f32 x, f32 y, f32 z, f32 nx=0.0f, f32 ny=0.0f, f32 nz=0.0f, SColor c=0xFFFFFFFF, f32 tu=0.0f, f32 tv=0.0f, f32 tanx=0.0f, f32 tany=0.0f, f32 tanz=0.0f, f32 bx=0.0f, f32 by=0.0f, f32 bz=0.0f)
constructor
Definition S3DVertex.h:193
irr::video::S3DVertexTangents::operator!=
bool operator!=(const S3DVertexTangents &other) const
Definition S3DVertex.h:225
irr::video::S3DVertexTangents::getInterpolated
S3DVertexTangents getInterpolated(const S3DVertexTangents &other, f32 d)
Definition S3DVertex.h:244
irr::video::S3DVertexTangents::operator<
bool operator<(const S3DVertexTangents &other) const
Definition S3DVertex.h:232
irr::video::S3DVertexTangents::operator==
bool operator==(const S3DVertexTangents &other) const
Definition S3DVertex.h:218
vector2d.h
vector3d.h
- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0