15#include "utility/graphic/position.hpp"
17#include "utility/math/vector.hpp"
19namespace utility::graphic
26 template<
typename Type>
37 template<CanBeVectorComponent VectorComponent>
class Vertex
60 , _textureCoordinates {}
78 , _textureCoordinates(textureCoordinates)
126 _textureCoordinates = textureCoordinates;
135 return _textureCoordinates;
170 _position = position;
172 _textureCoordinates = textureCoordinates;
185 const VectorComponent normSquared = _normal[0] * _normal[0]
186 + _normal[1] * _normal[1] + _normal[2] * _normal[2];
187 return std::abs(normSquared - VectorComponent { 1 }) <= epsilon;
197 return _position == other._position && _normal == other._normal
198 && _textureCoordinates == other._textureCoordinates
199 && _color == other._color;
209 return !(*
this == other);
216 using VertexF = Vertex<float>;
221 using VertexD = Vertex<double>;
229 std::ostream &operator<<(std::ostream &stream,
const VertexF &vertex);
237 std::ostream &operator<<(std::ostream &stream,
const VertexD &vertex);
Position in 3D space represented as a vector of three PositionComponentType components (x,...
Vertex type containing common mesh attributes.
bool hasUnitNormal(VectorComponent epsilon=VectorComponent { 1e-5 }) const
Check if the normal is approximately unit length.
Color32Bit getColor(void) const
Get vertex color.
void setPosition(const Position< VectorComponent > &position)
Set vertex position.
Vertex & setAttributes(const Position< VectorComponent > &position, const math::Vector< VectorComponent, 3 > &normal, const math::Vector< VectorComponent, 2 > &textureCoordinates, const Color32Bit &color)
Set all vertex attributes at once.
void setColor(const Color32Bit &color)
Set vertex color.
bool operator!=(const Vertex &other) const
Inequality comparison.
void setNormal(const math::Vector< VectorComponent, 3 > &normal)
Set vertex normal.
math::Vector< VectorComponent, 2 > getTextureCoordinates(void) const
Get vertex texture coordinates.
bool operator==(const Vertex &other) const
Equality comparison.
Position< VectorComponent > getPosition(void) const
Get vertex position.
math::Vector< VectorComponent, 3 > getNormal(void) const
Get vertex normal.
Vertex(const Position< VectorComponent > &position, const math::Vector< VectorComponent, 3 > &normal, const math::Vector< VectorComponent, 2 > &textureCoordinates, const Color32Bit &color)
Construct from all vertex attributes.
Vertex(void)
Default constructor.
void setTextureCoordinates(const math::Vector< VectorComponent, 2 > &textureCoordinates)
Set vertex texture coordinates.
3D vector class inheriting from glm::vec3.
RGBA color representation with blending and manipulation operations.
Concept to constrain position component type.
Concept to constrain color component type.
Concept to constrain vector component type.