Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TriFace.h
Go to the documentation of this file.
1#pragma once
2
3#include "Math/TVector3.h"
4#include "Math/TVector2.h"
5
6#include <cstddef>
7#include <array>
8#include <optional>
9#include <utility>
10
11namespace ph
12{
13
14class TriFace final
15{
16public:
17 TriFace(std::size_t index, std::array<math::Vector3R, 3> vertices);
18
19 void setTexCoords(std::array<math::Vector3R, 3> texCoords);
20 void setShadingNormals(std::array<math::Vector3R, 3> shadingNormals);
21
22 std::size_t getIndex() const;
23 const std::array<math::Vector3R, 3>& getVertices() const;
24 const std::array<math::Vector3R, 3>& getTexCoords() const;
25 const std::array<math::Vector3R, 3>& getShadingNormals() const;
26 bool hasTexCoords() const;
27 bool hasShadingNormals() const;
28
29 // TODO: getXxxOrDefault() methods
30
31private:
32 std::size_t m_index;
33 std::array<math::Vector3R, 3> m_vertices;
34 std::optional<std::array<math::Vector3R, 3>> m_uvws;
35 std::optional<std::array<math::Vector3R, 3>> m_normals;
36};
37
38// In-header Implementations:
39
40inline TriFace::TriFace(const std::size_t index, std::array<math::Vector3R, 3> vertices) :
41 m_index (index),
42 m_vertices(std::move(vertices)),
43 m_uvws (),
44 m_normals ()
45{}
46
47inline void TriFace::setTexCoords(std::array<math::Vector3R, 3> texCoords)
48{
49 m_uvws = std::move(texCoords);
50}
51
52inline void TriFace::setShadingNormals(std::array<math::Vector3R, 3> shadingNormals)
53{
54 m_normals = std::move(shadingNormals);
55}
56
57inline std::size_t TriFace::getIndex() const
58{
59 return m_index;
60}
61
62inline const std::array<math::Vector3R, 3>& TriFace::getVertices() const
63{
64 return m_vertices;
65}
66
67inline const std::array<math::Vector3R, 3>& TriFace::getTexCoords() const
68{
69 PH_ASSERT(m_uvws);
70
71 return *m_uvws;
72}
73
74inline const std::array<math::Vector3R, 3>& TriFace::getShadingNormals() const
75{
76 PH_ASSERT(m_normals);
77
78 return *m_normals;
79}
80
81inline bool TriFace::hasTexCoords() const
82{
83 return m_uvws.has_value();
84}
85
86inline bool TriFace::hasShadingNormals() const
87{
88 return m_normals.has_value();
89}
90
91}// end namespace ph
Definition TriFace.h:15
const std::array< math::Vector3R, 3 > & getShadingNormals() const
Definition TriFace.h:74
const std::array< math::Vector3R, 3 > & getTexCoords() const
Definition TriFace.h:67
bool hasShadingNormals() const
Definition TriFace.h:86
std::size_t getIndex() const
Definition TriFace.h:57
void setShadingNormals(std::array< math::Vector3R, 3 > shadingNormals)
Definition TriFace.h:52
TriFace(std::size_t index, std::array< math::Vector3R, 3 > vertices)
Definition TriFace.h:40
const std::array< math::Vector3R, 3 > & getVertices() const
Definition TriFace.h:62
bool hasTexCoords() const
Definition TriFace.h:81
void setTexCoords(std::array< math::Vector3R, 3 > texCoords)
Definition TriFace.h:47
The root for all renderer implementations.
Definition EEngineProject.h:6
Definition TAABB2D.h:96