Carna Version 3.3.3
Loading...
Searching...
No Matches
Vertex.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Leonid Kostrykin
3 *
4 */
5
6#ifndef VERTEX_H_6014714286
7#define VERTEX_H_6014714286
8
9#include <Carna/Carna.h>
11
19namespace Carna
20{
21
22namespace base
23{
24
25
26
27// ----------------------------------------------------------------------------------
28// VertexPosition
29// ----------------------------------------------------------------------------------
30
40{
54 float x, y, z, w;
55
59
62 template< typename VectorType >
63 void setPosition( const VectorType& position );
64};
65
66
67template< typename VectorType >
69{
70 x = position.x();
71 y = position.y();
72 z = position.z();
73}
74
75
76
77// ----------------------------------------------------------------------------------
78// VertexNormal
79// ----------------------------------------------------------------------------------
80
89{
103 float nx, ny, nz, nw;
104
108
113 template< typename VectorType >
114 void setNormal( const VectorType& normal );
115};
116
117
118template< typename VectorType >
120{
121 nx = normal.x();
122 ny = normal.y();
123 nz = normal.z();
124}
125
126
127
128// ----------------------------------------------------------------------------------
129// VertexColor
130// ----------------------------------------------------------------------------------
131
140{
153 float r, g, b, a;
154
158
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
190#define VERTEX_NULL_COMPONENT( name ) \
191 template< typename VectorType > \
192 void set ## name( const VectorType& ) \
193 { \
194 }
195
196
197
198// ----------------------------------------------------------------------------------
199// PVertex
200// ----------------------------------------------------------------------------------
201
276struct CARNA_LIB PVertex
277 : public VertexPosition
278{
283
289
295};
296
297
298
299// ----------------------------------------------------------------------------------
300// PNVertex
301// ----------------------------------------------------------------------------------
302
310struct CARNA_LIB PNVertex
311 : public VertexPosition
312 , public VertexNormal
313{
318
324};
325
326
327
328// ----------------------------------------------------------------------------------
329// PCVertex
330// ----------------------------------------------------------------------------------
331
338struct CARNA_LIB PCVertex
339 : public VertexPosition
340 , public VertexColor
341{
346
352};
353
354
355
356} // namespace Carna :: base
357
358} // namespace Carna
359
360#endif // VERTEX_H_6014714286
Defines Carna::base::VertexAttributes.
Represents an association.
Definition Association.h:45
Represents a color. Objects from this class are copyable and assignable.
Definition Color.h:42
std::vector< VertexAttribute > VertexAttributes
Defines VertexAttribute vector.
Defines vertex that consists of the two attributes position and color.
Definition Vertex.h:341
static const VertexAttributes attributes
Holds the declaration of the vertex format.
Definition Vertex.h:345
Defines vertex that consists of the two attributes position and normal vector.
Definition Vertex.h:313
static const VertexAttributes attributes
Holds the declaration of the vertex format.
Definition Vertex.h:317
Defines simple-most vertex that only consists of a positional attribute.
Definition Vertex.h:278
VERTEX_NULL_COMPONENT(Normal)
static const VertexAttributes attributes
Holds the declaration of the vertex format.
Definition Vertex.h:282
Defines vertex component for colors. Usage is explained here.
Definition Vertex.h:140
float b
Holds the blue color component of this vertex.
Definition Vertex.h:153
float r
Holds the red color component of this vertex.
Definition Vertex.h:153
float a
Holds the alpha color component of this vertex.
Definition Vertex.h:153
void setColor(const VectorType &color)
Definition Vertex.h:169
float g
Holds the green color component of this vertex.
Definition Vertex.h:153
Defines vertex component for normal vectors. Usage is explained here.
Definition Vertex.h:89
float ny
Holds the normal vector y-component of this vertex.
Definition Vertex.h:103
float nx
Holds the normal vector x-component of this vertex.
Definition Vertex.h:103
void setNormal(const VectorType &normal)
Definition Vertex.h:119
float nz
Holds the normal vector z-component of this vertex.
Definition Vertex.h:103
float nw
Holds the normal vector w-component of this vertex. This will be 0 usually.
Definition Vertex.h:103
Defines vertex component for position vectors. Usage is explained here.
Definition Vertex.h:40
void setPosition(const VectorType &position)
Definition Vertex.h:68
float y
Holds the positional y-component of this vertex.
Definition Vertex.h:54
float w
Holds the positional w-component of this vertex. This will be 1 usually.
Definition Vertex.h:54
float x
Holds the positional x-component of this vertex.
Definition Vertex.h:54
float z
Holds the positional z-component of this vertex.
Definition Vertex.h:54