Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials
S3DVertex.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2010 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 
12 namespace irr
13 {
14 namespace video
15 {
16 
19 {
22 
24 
26 
28 
30 };
31 
33 const char* const sBuiltInVertexTypeNames[] =
34 {
35  "standard",
36  "2tcoords",
37  "tangents",
38  0
39 };
40 
42 struct S3DVertex
43 {
45  S3DVertex() {}
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 
94 
96 
100 {
103 
105  S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
106  : S3DVertex(x,y,z, 0.0f, 0.0f, 0.0f, c, tu,tv), TCoords2(tu2,tv2) {}
107 
110  const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2)
111  : S3DVertex(pos, core::vector3df(), color, tcoords), TCoords2(tcoords2) {}
112 
114  S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, const SColor& color,
115  const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2)
116  : S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords2) {}
117 
119  S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
120  : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu2,tv2) {}
121 
123  S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
124  : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu,tv) {}
125 
128  SColor color, const core::vector2d<f32>& tcoords)
129  : S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords) {}
130 
133 
136 
138  bool operator==(const S3DVertex2TCoords& other) const
139  {
140  return ((static_cast<S3DVertex>(*this)==other) &&
141  (TCoords2 == other.TCoords2));
142  }
143 
145  bool operator!=(const S3DVertex2TCoords& other) const
146  {
147  return ((static_cast<S3DVertex>(*this)!=other) ||
148  (TCoords2 != other.TCoords2));
149  }
150 
151  bool operator<(const S3DVertex2TCoords& other) const
152  {
153  return ((static_cast<S3DVertex>(*this) < other) ||
154  ((static_cast<S3DVertex>(*this) == other) && (TCoords2 < other.TCoords2)));
155  }
156 
158  {
159  return EVT_2TCOORDS;
160  }
161 };
162 
163 
165 
167 {
170 
172  S3DVertexTangents(f32 x, f32 y, f32 z, f32 nx=0.0f, f32 ny=0.0f, f32 nz=0.0f,
173  SColor c = 0xFFFFFFFF, f32 tu=0.0f, f32 tv=0.0f,
174  f32 tanx=0.0f, f32 tany=0.0f, f32 tanz=0.0f,
175  f32 bx=0.0f, f32 by=0.0f, f32 bz=0.0f)
176  : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), Tangent(tanx,tany,tanz), Binormal(bx,by,bz) { }
177 
180  const core::vector2df& tcoords)
181  : S3DVertex(pos, core::vector3df(), c, tcoords) { }
182 
185  const core::vector3df& normal, SColor c,
186  const core::vector2df& tcoords,
187  const core::vector3df& tangent=core::vector3df(),
188  const core::vector3df& binormal=core::vector3df())
189  : S3DVertex(pos, normal, c, tcoords), Tangent(tangent), Binormal(binormal) { }
190 
193 
196 
197  bool operator==(const S3DVertexTangents& other) const
198  {
199  return ((static_cast<S3DVertex>(*this)==other) &&
200  (Tangent == other.Tangent) &&
201  (Binormal == other.Binormal));
202  }
203 
204  bool operator!=(const S3DVertexTangents& other) const
205  {
206  return ((static_cast<S3DVertex>(*this)!=other) ||
207  (Tangent != other.Tangent) ||
208  (Binormal != other.Binormal));
209  }
210 
211  bool operator<(const S3DVertexTangents& other) const
212  {
213  return ((static_cast<S3DVertex>(*this) < other) ||
214  ((static_cast<S3DVertex>(*this) == other) && (Tangent < other.Tangent)) ||
215  ((static_cast<S3DVertex>(*this) == other) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
216  }
217 
219  {
220  return EVT_TANGENTS;
221  }
222 };
223 
224 
225 
227 {
228  switch (vertexType)
229  {
230  case video::EVT_2TCOORDS:
231  return sizeof(video::S3DVertex2TCoords);
232  case video::EVT_TANGENTS:
233  return sizeof(video::S3DVertexTangents);
234  default:
235  return sizeof(video::S3DVertex);
236  }
237 }
238 
239 
240 } // end namespace video
241 } // end namespace irr
242 
243 #endif
244 

The Irrlicht Engine
The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Tue Jun 5 2012 17:57:14 by Doxygen (1.8.1)