LibCarna Version 3.4.0
Loading...
Searching...
No Matches
Vertex.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 - 2016 Leonid Kostrykin
3 *
4 * Chair of Medical Engineering (mediTEC)
5 * RWTH Aachen University
6 * Pauwelsstr. 20
7 * 52074 Aachen
8 * Germany
9 *
10 *
11 * Copyright (C) 2021 - 2025 Leonid Kostrykin
12 *
13 */
14
15#ifndef VERTEX_H_6014714286
16#define VERTEX_H_6014714286
17
18#include <LibCarna/LibCarna.hpp>
20
27namespace LibCarna
28{
29
30namespace base
31{
32
33
34
35// ----------------------------------------------------------------------------------
36// VertexPosition
37// ----------------------------------------------------------------------------------
38
46{
60 float x, y, z, w;
61
65
68 template< typename VectorType >
69 void setPosition( const VectorType& position );
70};
71
72
73template< typename VectorType >
75{
76 x = position.x();
77 y = position.y();
78 z = position.z();
79}
80
81
82
83// ----------------------------------------------------------------------------------
84// VertexNormal
85// ----------------------------------------------------------------------------------
86
94{
108 float nx, ny, nz, nw;
109
113
116 template< typename VectorType >
117 void setNormal( const VectorType& normal );
118};
119
120
121template< typename VectorType >
123{
124 nx = normal.x();
125 ny = normal.y();
126 nz = normal.z();
127}
128
129
130
131// ----------------------------------------------------------------------------------
132// VertexColor
133// ----------------------------------------------------------------------------------
134
142{
155 float r, g, b, a;
156
160
163 template< typename VectorType >
164 void setColor( const VectorType& color );
165};
166
167
168template< typename VectorType >
170{
171 r = color.x();
172 g = color.y();
173 b = color.z();
174 a = color.w();
175}
176
177
178
179// ----------------------------------------------------------------------------------
180// VERTEX_NULL_COMPONENT
181// ----------------------------------------------------------------------------------
182
188#define VERTEX_NULL_COMPONENT( name ) \
189 template< typename VectorType > \
190 void set ## name( const VectorType& ) \
191 { \
192 }
193
194
195
196// ----------------------------------------------------------------------------------
197// PVertex
198// ----------------------------------------------------------------------------------
199
273struct LIBCARNA PVertex
274 : public VertexPosition
275{
280
284
288};
289
290
291
292// ----------------------------------------------------------------------------------
293// PNVertex
294// ----------------------------------------------------------------------------------
295
301struct LIBCARNA PNVertex
302 : public VertexPosition
303 , public VertexNormal
304{
309
313};
314
315
316
317// ----------------------------------------------------------------------------------
318// PCVertex
319// ----------------------------------------------------------------------------------
320
326struct LIBCARNA PCVertex
327 : public VertexPosition
328 , public VertexColor
329{
334
338};
339
340
341
342} // namespace LibCarna :: base
343
344} // namespace LibCarna
345
346#endif // VERTEX_H_6014714286
Contains forward-declarations.
Defines LibCarna::base::VertexAttributes.
Represents an association.
Represents a color. Objects from this class are copyable and assignable.
Definition Color.hpp:45
std::vector< VertexAttribute > VertexAttributes
Defines VertexAttribute vector.
Defines vertex that consists of the two attributes position and color.
Definition Vertex.hpp:329
static const VertexAttributes attributes
Holds the declaration of the vertex format.
Definition Vertex.hpp:333
Defines vertex that consists of the two attributes position and normal vector.
Definition Vertex.hpp:304
static const VertexAttributes attributes
Holds the declaration of the vertex format.
Definition Vertex.hpp:308
Defines simple-most vertex that only consists of a positional attribute.
Definition Vertex.hpp:275
static const VertexAttributes attributes
Holds the declaration of the vertex format.
Definition Vertex.hpp:279
Defines vertex component for colors. Usage is explained here.
Definition Vertex.hpp:142
void setColor(const VectorType &color)
Definition Vertex.hpp:169
float a
Holds the alpha color component of this vertex.
Definition Vertex.hpp:155
float g
Holds the green color component of this vertex.
Definition Vertex.hpp:155
float r
Holds the red color component of this vertex.
Definition Vertex.hpp:155
float b
Holds the blue color component of this vertex.
Definition Vertex.hpp:155
Defines vertex component for normal vectors. Usage is explained here.
Definition Vertex.hpp:94
void setNormal(const VectorType &normal)
Definition Vertex.hpp:122
float nx
Holds the normal vector x-component of this vertex.
Definition Vertex.hpp:108
float nw
Holds the normal vector w-component of this vertex. This will be 0 usually.
Definition Vertex.hpp:108
float ny
Holds the normal vector y-component of this vertex.
Definition Vertex.hpp:108
float nz
Holds the normal vector z-component of this vertex.
Definition Vertex.hpp:108
Defines vertex component for position vectors. Usage is explained here.
Definition Vertex.hpp:46
void setPosition(const VectorType &position)
Definition Vertex.hpp:74
float z
Holds the positional z-component of this vertex.
Definition Vertex.hpp:60
float y
Holds the positional y-component of this vertex.
Definition Vertex.hpp:60
float x
Holds the positional x-component of this vertex.
Definition Vertex.hpp:60
float w
Holds the positional w-component of this vertex. This will be 1 usually.
Definition Vertex.hpp:60