Irrlicht 3D Engine
 
Loading...
Searching...
No Matches
S3DVertex.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_3D_VERTEX_H_INCLUDED__
6#define __S_3D_VERTEX_H_INCLUDED__
7
8#include "vector3d.h"
9#include "vector2d.h"
10#include "SColor.h"
11
12namespace irr
13{
14namespace video
15{
16
31
33const char* const sBuiltInVertexTypeNames[] =
34{
35 "standard",
36 "2tcoords",
37 "tangents",
38 0
39};
40
43{
46
48 S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
49 : Pos(x,y,z), Normal(nx,ny,nz), Color(c), TCoords(tu,tv) {}
50
52 S3DVertex(const core::vector3df& pos, const core::vector3df& normal,
53 SColor color, const core::vector2d<f32>& tcoords)
54 : Pos(pos), Normal(normal), Color(color), TCoords(tcoords) {}
55
58
61
64
67
68 bool operator==(const S3DVertex& other) const
69 {
70 return ((Pos == other.Pos) && (Normal == other.Normal) &&
71 (Color == other.Color) && (TCoords == other.TCoords));
72 }
73
74 bool operator!=(const S3DVertex& other) const
75 {
76 return ((Pos != other.Pos) || (Normal != other.Normal) ||
77 (Color != other.Color) || (TCoords != other.TCoords));
78 }
79
80 bool operator<(const S3DVertex& other) const
81 {
82 return ((Pos < other.Pos) ||
83 ((Pos == other.Pos) && (Normal < other.Normal)) ||
84 ((Pos == other.Pos) && (Normal == other.Normal) && (Color < other.Color)) ||
85 ((Pos == other.Pos) && (Normal == other.Normal) && (Color == other.Color) && (TCoords < other.TCoords)));
86 }
87
89 {
90 return EVT_STANDARD;
91 }
92
93 //\param d d=0 returns other, d=1 returns this, values between interpolate.
95 {
96 d = core::clamp(d, 0.0f, 1.0f);
97 return S3DVertex(Pos.getInterpolated(other.Pos, d),
99 Color.getInterpolated(other.Color, d),
101 }
102};
103
104
106
110{
113
115 S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
116 : S3DVertex(x,y,z, 0.0f, 0.0f, 0.0f, c, tu,tv), TCoords2(tu2,tv2) {}
117
120 const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2)
121 : S3DVertex(pos, core::vector3df(), color, tcoords), TCoords2(tcoords2) {}
122
124 S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, const SColor& color,
125 const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2)
126 : S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords2) {}
127
129 S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
130 : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu2,tv2) {}
131
133 S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
134 : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu,tv) {}
135
138 SColor color, const core::vector2d<f32>& tcoords)
139 : S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords) {}
140
143
146
148 bool operator==(const S3DVertex2TCoords& other) const
149 {
150 return ((static_cast<S3DVertex>(*this)==other) &&
151 (TCoords2 == other.TCoords2));
152 }
153
155 bool operator!=(const S3DVertex2TCoords& other) const
156 {
157 return ((static_cast<S3DVertex>(*this)!=other) ||
158 (TCoords2 != other.TCoords2));
159 }
160
161 bool operator<(const S3DVertex2TCoords& other) const
162 {
163 return ((static_cast<S3DVertex>(*this) < other) ||
164 ((static_cast<S3DVertex>(*this) == other) && (TCoords2 < other.TCoords2)));
165 }
166
168 {
169 return EVT_2TCOORDS;
170 }
171
172 //\param d d=0 returns other, d=1 returns this, values between interpolate.
174 {
175 d = core::clamp(d, 0.0f, 1.0f);
176 return S3DVertex2TCoords(Pos.getInterpolated(other.Pos, d),
177 Normal.getInterpolated(other.Normal, d),
178 Color.getInterpolated(other.Color, d),
181 }
182};
183
184
186
188{
191
193 S3DVertexTangents(f32 x, f32 y, f32 z, f32 nx=0.0f, f32 ny=0.0f, f32 nz=0.0f,
194 SColor c = 0xFFFFFFFF, f32 tu=0.0f, f32 tv=0.0f,
195 f32 tanx=0.0f, f32 tany=0.0f, f32 tanz=0.0f,
196 f32 bx=0.0f, f32 by=0.0f, f32 bz=0.0f)
197 : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), Tangent(tanx,tany,tanz), Binormal(bx,by,bz) { }
198
201 const core::vector2df& tcoords)
202 : S3DVertex(pos, core::vector3df(), c, tcoords) { }
203
206 const core::vector3df& normal, SColor c,
207 const core::vector2df& tcoords,
208 const core::vector3df& tangent=core::vector3df(),
209 const core::vector3df& binormal=core::vector3df())
210 : S3DVertex(pos, normal, c, tcoords), Tangent(tangent), Binormal(binormal) { }
211
214
217
218 bool operator==(const S3DVertexTangents& other) const
219 {
220 return ((static_cast<S3DVertex>(*this)==other) &&
221 (Tangent == other.Tangent) &&
222 (Binormal == other.Binormal));
223 }
224
225 bool operator!=(const S3DVertexTangents& other) const
226 {
227 return ((static_cast<S3DVertex>(*this)!=other) ||
228 (Tangent != other.Tangent) ||
229 (Binormal != other.Binormal));
230 }
231
232 bool operator<(const S3DVertexTangents& other) const
233 {
234 return ((static_cast<S3DVertex>(*this) < other) ||
235 ((static_cast<S3DVertex>(*this) == other) && (Tangent < other.Tangent)) ||
236 ((static_cast<S3DVertex>(*this) == other) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
237 }
238
240 {
241 return EVT_TANGENTS;
242 }
243
245 {
246 d = core::clamp(d, 0.0f, 1.0f);
247 return S3DVertexTangents(Pos.getInterpolated(other.Pos, d),
248 Normal.getInterpolated(other.Normal, d),
249 Color.getInterpolated(other.Color, d),
253 }
254};
255
256
257
259{
260 switch (vertexType)
261 {
263 return sizeof(video::S3DVertex2TCoords);
265 return sizeof(video::S3DVertexTangents);
266 default:
267 return sizeof(video::S3DVertex);
268 }
269}
270
271
272} // end namespace video
273} // end namespace irr
274
275#endif
276
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
vector2d< T > getInterpolated(const vector2d< T > &other, f64 d) const
Creates an interpolated vector between this vector and another vector.
Definition vector2d.h:278
vector3d< T > getInterpolated(const vector3d< T > &other, f64 d) const
Creates an interpolated vector between this vector and another vector.
Definition vector3d.h:247
Class representing a 32 bit ARGB color.
Definition SColor.h:202
SColor getInterpolated(const SColor &other, f32 d) const
Interpolates the color with a f32 value to another color.
Definition SColor.h:340
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition irrMath.h:166
E_VERTEX_TYPE
Enumeration for all vertex types there are.
Definition S3DVertex.h:19
@ EVT_2TCOORDS
Vertex with two texture coordinates, video::S3DVertex2TCoords.
Definition S3DVertex.h:25
@ EVT_TANGENTS
Vertex with a tangent and binormal vector, video::S3DVertexTangents.
Definition S3DVertex.h:29
@ EVT_STANDARD
Standard vertex type used by the Irrlicht engine, video::S3DVertex.
Definition S3DVertex.h:21
const char *const sBuiltInVertexTypeNames[]
Array holding the built in vertex type names.
Definition S3DVertex.h:33
u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType)
Definition S3DVertex.h:258
Everything in the Irrlicht Engine can be found in this namespace.
Definition aabbox3d.h:13
float f32
32 bit floating point variable.
Definition irrTypes.h:104
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
Vertex with two texture coordinates.
Definition S3DVertex.h:110
S3DVertex2TCoords getInterpolated(const S3DVertex2TCoords &other, f32 d)
Definition S3DVertex.h:173
bool operator!=(const S3DVertex2TCoords &other) const
Inequality operator.
Definition S3DVertex.h:155
bool operator<(const S3DVertex2TCoords &other) const
Definition S3DVertex.h:161
S3DVertex2TCoords()
default constructor
Definition S3DVertex.h:112
core::vector2d< f32 > TCoords2
Second set of texture coordinates.
Definition S3DVertex.h:145
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
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
bool operator==(const S3DVertex2TCoords &other) const
Equality operator.
Definition S3DVertex.h:148
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
S3DVertex2TCoords(S3DVertex &o)
constructor from S3DVertex
Definition S3DVertex.h:142
E_VERTEX_TYPE getType() const
Definition S3DVertex.h:167
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
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
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
standard vertex used by the Irrlicht engine.
Definition S3DVertex.h:43
core::vector2d< f32 > TCoords
Texture coordinates.
Definition S3DVertex.h:66
bool operator!=(const S3DVertex &other) const
Definition S3DVertex.h:74
S3DVertex()
default constructor
Definition S3DVertex.h:45
S3DVertex(const core::vector3df &pos, const core::vector3df &normal, SColor color, const core::vector2d< f32 > &tcoords)
constructor
Definition S3DVertex.h:52
core::vector3df Normal
Normal vector.
Definition S3DVertex.h:60
SColor Color
Color.
Definition S3DVertex.h:63
S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
constructor
Definition S3DVertex.h:48
E_VERTEX_TYPE getType() const
Definition S3DVertex.h:88
bool operator<(const S3DVertex &other) const
Definition S3DVertex.h:80
core::vector3df Pos
Position.
Definition S3DVertex.h:57
bool operator==(const S3DVertex &other) const
Definition S3DVertex.h:68
S3DVertex getInterpolated(const S3DVertex &other, f32 d)
Definition S3DVertex.h:94
Vertex with a tangent and binormal vector.
Definition S3DVertex.h:188
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
E_VERTEX_TYPE getType() const
Definition S3DVertex.h:239
core::vector3df Binormal
Binormal vector (tangent x normal)
Definition S3DVertex.h:216
core::vector3df Tangent
Tangent vector along the x-axis of the texture.
Definition S3DVertex.h:213
S3DVertexTangents(const core::vector3df &pos, SColor c, const core::vector2df &tcoords)
constructor
Definition S3DVertex.h:200
S3DVertexTangents()
default constructor
Definition S3DVertex.h:190
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
bool operator!=(const S3DVertexTangents &other) const
Definition S3DVertex.h:225
S3DVertexTangents getInterpolated(const S3DVertexTangents &other, f32 d)
Definition S3DVertex.h:244
bool operator<(const S3DVertexTangents &other) const
Definition S3DVertex.h:232
bool operator==(const S3DVertexTangents &other) const
Definition S3DVertex.h:218