Saga3D API Documentation  1.0-RC4
S3DVertex.h
Go to the documentation of this file.
1 #ifndef __S3D_VERTEX_H_INCLUDED__
2 #define __S3D_VERTEX_H_INCLUDED__
3 
4 #include "SColor.h"
5 #include "GraphicsConstants.h"
6 #include <array>
7 #include <vector>
8 
9 namespace saga
10 {
11 namespace scene
12 {
13 
15 struct S3DVertex
16 {
18  S3DVertex() {}
19 
20  S3DVertex(float x, float y, float z)
21  : Position(x, y, z) {}
22 
23  S3DVertex(const glm::vec3& Position, const glm::vec3& normal,
24  glm::vec4 color, const glm::vec2& TextureCoords)
25  : Position(Position), Normal(normal), Color(color), TextureCoords(TextureCoords) {}
26 
27  S3DVertex(const glm::vec3& Position, const glm::vec3& normal,
28  glm::vec4 color, const glm::vec2& TextureCoords, const glm::vec3& tangent, const glm::vec3& bitangent)
29  : Position(Position), Normal(normal), Color(color), TextureCoords(TextureCoords), Tangent(tangent), BiTangent(bitangent) {}
30 
31  glm::vec3 Position;
32  glm::vec3 Normal;
33  glm::vec4 Color;
34  glm::vec2 TextureCoords;
35  glm::vec3 Tangent;
36  glm::vec3 BiTangent;
37  glm::vec4 BoneWeights;
38  glm::vec4 BoneIDs;
39  std::vector<unsigned char> Attributes;
40 
41  bool operator==(const S3DVertex& other) const
42  {
43  return ((Position == other.Position) && (Normal == other.Normal) &&
44  (Color == other.Color) && (TextureCoords == other.TextureCoords)) &&
45  (Tangent == other.Tangent) && (BiTangent == other.BiTangent);
46  }
47 
48  bool operator!=(const S3DVertex& other) const
49  {
50  return ((Position != other.Position) || (Normal != other.Normal) ||
51  (Color != other.Color) || (TextureCoords != other.TextureCoords)) ||
52  (Tangent != other.Tangent) || (BiTangent != other.BiTangent);
53  }
54 
55  bool operator<(const S3DVertex& other) const
56  {
57  return (glm::all(glm::lessThan(Position, other.Position)) ||
58  ((glm::all(glm::equal(Position, other.Position)) && glm::all(glm::lessThan(Normal, other.Normal))) ||
59  (glm::all(glm::equal(Position, other.Position)) && glm::all(glm::equal(Normal, other.Normal)) && glm::all(glm::lessThan(Color, other.Color))) ||
60  (glm::all(glm::equal(Position, other.Position)) && glm::all(glm::equal(Normal, other.Normal)) && glm::all(glm::equal(Color, other.Color)) &&
61  glm::all(glm::lessThan(TextureCoords, other.TextureCoords)))));
62  }
63 
64  S3DVertex getInterpolated(const S3DVertex& other, float d)
65  {
66  d = glm::clamp(d, 0.0f, 1.0f);
67  return S3DVertex(glm::mix(Position, other.Position, d),
68  glm::mix(Normal, other.Normal, d),
69  glm::mix(Color, other.Color, d),
70  glm::mix(TextureCoords, other.TextureCoords, d),
71  glm::mix(Tangent, other.Tangent, d),
72  glm::mix(BiTangent, other.BiTangent, d));
73  }
74 };
75 
76 } // namespace video
77 } // namespace saga
78 
79 #endif
80 
saga::scene::S3DVertex::S3DVertex
S3DVertex(const glm::vec3 &Position, const glm::vec3 &normal, glm::vec4 color, const glm::vec2 &TextureCoords)
Definition: S3DVertex.h:23
saga::scene::S3DVertex::BiTangent
glm::vec3 BiTangent
Definition: S3DVertex.h:36
saga::scene::S3DVertex::TextureCoords
glm::vec2 TextureCoords
Definition: S3DVertex.h:34
saga::scene::S3DVertex
standard vertex used by the Irrlicht engine.
Definition: S3DVertex.h:15
saga::scene::S3DVertex::Normal
glm::vec3 Normal
Definition: S3DVertex.h:32
saga::scene::S3DVertex::BoneWeights
glm::vec4 BoneWeights
Definition: S3DVertex.h:37
saga::scene::S3DVertex::Tangent
glm::vec3 Tangent
Definition: S3DVertex.h:35
saga::scene::S3DVertex::operator==
bool operator==(const S3DVertex &other) const
Definition: S3DVertex.h:41
saga::scene::S3DVertex::Color
glm::vec4 Color
Definition: S3DVertex.h:33
GraphicsConstants.h
saga::scene::S3DVertex::BoneIDs
glm::vec4 BoneIDs
Definition: S3DVertex.h:38
saga::scene::S3DVertex::operator!=
bool operator!=(const S3DVertex &other) const
Definition: S3DVertex.h:48
saga::scene::S3DVertex::S3DVertex
S3DVertex()
default constructor
Definition: S3DVertex.h:18
saga::scene::S3DVertex::S3DVertex
S3DVertex(const glm::vec3 &Position, const glm::vec3 &normal, glm::vec4 color, const glm::vec2 &TextureCoords, const glm::vec3 &tangent, const glm::vec3 &bitangent)
Definition: S3DVertex.h:27
saga::scene::S3DVertex::S3DVertex
S3DVertex(float x, float y, float z)
Definition: S3DVertex.h:20
saga::scene::S3DVertex::operator<
bool operator<(const S3DVertex &other) const
Definition: S3DVertex.h:55
saga::scene::S3DVertex::getInterpolated
S3DVertex getInterpolated(const S3DVertex &other, float d)
Definition: S3DVertex.h:64
saga::scene::S3DVertex::Attributes
std::vector< unsigned char > Attributes
Definition: S3DVertex.h:39
saga::scene::S3DVertex::Position
glm::vec3 Position
Definition: S3DVertex.h:31
saga
Definition: aabbox3d.h:11
saga::core::clamp
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition: irrMath.h:206
SColor.h