Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# S3DVertex.h

Go to the documentation of this file.

    00001 // Copyright (C) 2002-2009 Nikolaus Gebhardt
    00002 // This file is part of the "Irrlicht Engine".
    00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
    00004
    00005 #ifndef __S_3D_VERTEX_H_INCLUDED__
    00006 #define __S_3D_VERTEX_H_INCLUDED__
    00007
    00008 #include "vector3d.h"
    00009 #include "vector2d.h"
    00010 #include "SColor.h"
    00011
    00012 namespace irr
    00013 {
    00014 namespace video
    00015 {
    00016
    00018 enum E_VERTEX_TYPE
    00019 {
    00021         EVT_STANDARD = 0,
    00022
    00024
    00025         EVT_2TCOORDS,
    00026
    00028
    00029         EVT_TANGENTS
    00030 };
    00031
    00033 const char* const sBuiltInVertexTypeNames[] =
    00034 {
    00035         "standard",
    00036         "2tcoords",
    00037         "tangents",
    00038         0
    00039 };
    00040
    00042 struct S3DVertex
    00043 {
    00045         S3DVertex() {}
    00046
    00048         S3DVertex(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
    00049                 : Pos(x,y,z), Normal(nx,ny,nz), Color(c), TCoords(tu,tv) {}
    00050
    00052         S3DVertex(const core::vector3df& pos, const core::vector3df& normal,
    00053                 SColor color, const core::vector2d<f32>& tcoords)
    00054                 : Pos(pos), Normal(normal), Color(color), TCoords(tcoords) {}
    00055
    00057         core::vector3df Pos;
    00058
    00060         core::vector3df Normal;
    00061
    00063         SColor Color;
    00064
    00066         core::vector2d<f32> TCoords;
    00067
    00068         bool operator==(const S3DVertex& other) const
    00069         {
    00070                 return ((Pos == other.Pos) && (Normal == other.Normal) &&
    00071                         (Color == other.Color) && (TCoords == other.TCoords));
    00072         }
    00073
    00074         bool operator!=(const S3DVertex& other) const
    00075         {
    00076                 return ((Pos != other.Pos) || (Normal != other.Normal) ||
    00077                         (Color != other.Color) || (TCoords != other.TCoords));
    00078         }
    00079
    00080         bool operator<(const S3DVertex& other) const
    00081         {
    00082                 return ((Pos < other.Pos) ||
    00083                                 ((Pos == other.Pos) && (Normal < other.Normal)) ||
    00084                                 ((Pos == other.Pos) && (Normal == other.Normal) && (Color < other.Color)) ||
    00085                                 ((Pos == other.Pos) && (Normal == other.Normal) && (Color == other.Color) && (TCoords < other.TCoords)));
    00086         }
    00087
    00088         E_VERTEX_TYPE getType() const
    00089         {
    00090                 return EVT_STANDARD;
    00091         }
    00092 };
    00093
    00094
    00096
    00099 struct S3DVertex2TCoords : public S3DVertex
    00100 {
    00102         S3DVertex2TCoords() : S3DVertex() {}
    00103
    00105         S3DVertex2TCoords(f32 x, f32 y, f32 z, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
    00106                 : S3DVertex(x,y,z, 0.0f, 0.0f, 0.0f, c, tu,tv), TCoords2(tu2,tv2) {}
    00107
    00109         S3DVertex2TCoords(const core::vector3df& pos, SColor color,
    00110                 const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2)
    00111                 : S3DVertex(pos, core::vector3df(), color, tcoords), TCoords2(tcoords2) {}
    00112
    00114         S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal, const SColor& color,
    00115                 const core::vector2d<f32>& tcoords, const core::vector2d<f32>& tcoords2)
    00116                 : S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords2) {}
    00117
    00119         S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv, f32 tu2, f32 tv2)
    00120                 : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu2,tv2) {}
    00121
    00123         S3DVertex2TCoords(f32 x, f32 y, f32 z, f32 nx, f32 ny, f32 nz, SColor c, f32 tu, f32 tv)
    00124                 : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), TCoords2(tu,tv) {}
    00125
    00127         S3DVertex2TCoords(const core::vector3df& pos, const core::vector3df& normal,
    00128                 SColor color, const core::vector2d<f32>& tcoords)
    00129                 : S3DVertex(pos, normal, color, tcoords), TCoords2(tcoords) {}
    00130
    00132         S3DVertex2TCoords(S3DVertex& o) : S3DVertex(o) {}
    00133
    00135         core::vector2d<f32> TCoords2;
    00136
    00138         bool operator==(const S3DVertex2TCoords& other) const
    00139         {
    00140                 return ((static_cast<S3DVertex>(*this)==other) &&
    00141                         (TCoords2 == other.TCoords2));
    00142         }
    00143
    00145         bool operator!=(const S3DVertex2TCoords& other) const
    00146         {
    00147                 return ((static_cast<S3DVertex>(*this)!=other) ||
    00148                         (TCoords2 != other.TCoords2));
    00149         }
    00150
    00151         bool operator<(const S3DVertex2TCoords& other) const
    00152         {
    00153                 return ((static_cast<S3DVertex>(*this) < other) ||
    00154                                 ((static_cast<S3DVertex>(*this) == other) && (TCoords2 < other.TCoords2)));
    00155         }
    00156
    00157         E_VERTEX_TYPE getType() const
    00158         {
    00159                 return EVT_2TCOORDS;
    00160         }
    00161 };
    00162
    00163
    00165
    00166 struct S3DVertexTangents : public S3DVertex
    00167 {
    00169         S3DVertexTangents() : S3DVertex() { }
    00170
    00172         S3DVertexTangents(f32 x, f32 y, f32 z, f32 nx=0.0f, f32 ny=0.0f, f32 nz=0.0f,
    00173                         SColor c = 0xFFFFFFFF, f32 tu=0.0f, f32 tv=0.0f,
    00174                         f32 tanx=0.0f, f32 tany=0.0f, f32 tanz=0.0f,
    00175                         f32 bx=0.0f, f32 by=0.0f, f32 bz=0.0f)
    00176                 : S3DVertex(x,y,z, nx,ny,nz, c, tu,tv), Tangent(tanx,tany,tanz), Binormal(bx,by,bz) { }
    00177
    00179         S3DVertexTangents(const core::vector3df& pos, SColor c,
    00180                 const core::vector2df& tcoords)
    00181                 : S3DVertex(pos, core::vector3df(), c, tcoords) { }
    00182
    00184         S3DVertexTangents(const core::vector3df& pos,
    00185                 const core::vector3df& normal, SColor c,
    00186                 const core::vector2df& tcoords,
    00187                 const core::vector3df& tangent=core::vector3df(),
    00188                 const core::vector3df& binormal=core::vector3df())
    00189                 : S3DVertex(pos, normal, c, tcoords), Tangent(tangent), Binormal(binormal) { }
    00190
    00192         core::vector3df Tangent;
    00193
    00195         core::vector3df Binormal;
    00196
    00197         bool operator==(const S3DVertexTangents& other) const
    00198         {
    00199                 return ((static_cast<S3DVertex>(*this)==other) &&
    00200                         (Tangent == other.Tangent) &&
    00201                         (Binormal == other.Binormal));
    00202         }
    00203
    00204         bool operator!=(const S3DVertexTangents& other) const
    00205         {
    00206                 return ((static_cast<S3DVertex>(*this)!=other) ||
    00207                         (Tangent != other.Tangent) ||
    00208                         (Binormal != other.Binormal));
    00209         }
    00210
    00211         bool operator<(const S3DVertexTangents& other) const
    00212         {
    00213                 return ((static_cast<S3DVertex>(*this) < other) ||
    00214                                 ((static_cast<S3DVertex>(*this) == other) && (Tangent < other.Tangent)) ||
    00215                                 ((static_cast<S3DVertex>(*this) == other) && (Tangent == other.Tangent) && (Binormal < other.Binormal)));
    00216         }
    00217
    00218         E_VERTEX_TYPE getType() const
    00219         {
    00220                 return EVT_TANGENTS;
    00221         }
    00222 };
    00223
    00224
    00225
    00226 inline u32 getVertexPitchFromType(E_VERTEX_TYPE vertexType)
    00227 {
    00228         switch (vertexType)
    00229         {
    00230         case video::EVT_2TCOORDS:
    00231                 return sizeof(video::S3DVertex2TCoords);
    00232         case video::EVT_TANGENTS:
    00233                 return sizeof(video::S3DVertexTangents);
    00234         default:
    00235                 return sizeof(video::S3DVertex);
    00236         }
    00237 }
    00238
    00239
    00240 } // end namespace video
    00241 } // end namespace irr
    00242
    00243 #endif
    00244

| The Irrlicht Engine Documentation © 2003-2009 by Nikolaus Gebhardt. Generated on Sun Jan 10 09:24:05 2010 by Doxygen (1.5.6)