Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Vertex.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_GEOMETRY_VERTEX_H_
21 #define OMNI_GEOMETRY_VERTEX_H_
22 
23 #include <QVector2D>
24 #include <QVector3D>
25 
26 namespace omni {
27  namespace geometry {
28  /// A vertex is a geometry entity with a position, normal and texture
29  // coordinates
30  struct Vertex
31  {
32  /// Default constructor
33  Vertex();
34 
35  /// Construct from given position, normal and optional texture coordinates
36  Vertex(
37  const QVector3D& _pos,
38  const QVector3D& _normal,
39  const QVector3D& _texCoord = QVector3D());
40 
41  /// Set new position
42  void setPos(QVector3D const& _pos);
43 
44  /// Return reference to position
45  QVector3D & pos();
46 
47  /// Return const reference to position
48  QVector3D const& pos() const;
49 
50  /// Sets new normal (is not normalized!)
51  void setNormal(QVector3D const& _normal);
52 
53  /// Return reference to normal
54  QVector3D & normal();
55 
56  /// Return const reference to normal
57  QVector3D const& normal() const;
58 
59  /// Set new texture coordinates
60  void setTexCoord(QVector3D const& _texCoord);
61 
62 
63  /// Return reference to texture coordinates
64  QVector3D & texCoord();
65 
66  /// Return const reference to texture coordinates
67  QVector3D const& texCoord() const;
68 
69  inline static constexpr size_t texCoordOffset()
70  {
71  return 0;
72  }
73 
74  inline static constexpr size_t normalOffset()
75  {
76  return sizeof(QVector3D);
77  }
78 
79  inline static constexpr size_t posOffset()
80  {
81  return sizeof(QVector3D) + sizeof(QVector3D);
82  }
83 
84  private:
85  QVector3D texCoord_;
86  QVector3D normal_;
87  QVector3D pos_;
88  };
89  }
90  using geometry::Vertex;
91 }
92 
93 #endif /* OMNI_GEOMETRY_VERTEX_H_ */
QVector3D & normal()
Return reference to normal.
Definition: Vertex.cpp:56
QVector3D normal_
Definition: Vertex.h:86
void setPos(QVector3D const &_pos)
Set new position.
Definition: Vertex.cpp:36
void setTexCoord(QVector3D const &_texCoord)
Set new texture coordinates.
Definition: Vertex.cpp:66
QVector3D pos_
Definition: Vertex.h:87
QVector3D texCoord_
Definition: Vertex.h:85
static constexpr size_t posOffset()
Definition: Vertex.h:79
Vertex()
Default constructor.
Definition: Vertex.cpp:24
static constexpr size_t normalOffset()
Definition: Vertex.h:74
static constexpr size_t texCoordOffset()
Definition: Vertex.h:69
QVector3D & pos()
Return reference to position.
Definition: Vertex.cpp:41
void setNormal(QVector3D const &_normal)
Sets new normal (is not normalized!)
Definition: Vertex.cpp:51
QVector3D & texCoord()
Return reference to texture coordinates.
Definition: Vertex.cpp:71
A vertex is a geometry entity with a position, normal and texture.
Definition: Vertex.h:30