Carna
Version 3.0.1
|
Defines simple-most vertex that only consists of a positional attribute. More...
#include <Vertex.h>
Public Member Functions | |
VertexBase () | |
Initializes position to \(\left(0, 0, 0, 1\right)\). | |
Public Attributes | |
float | x |
Holds the positional x-component of this vertex. | |
float | y |
Holds the positional y-component of this vertex. | |
float | z |
Holds the positional z-component of this vertex. | |
float | w |
Holds the positional w-component of this vertex. This will be 1 usually. | |
Static Public Attributes | |
static const VertexAttributes | attributes |
Holds the declaration of the vertex format. | |
Defines simple-most vertex that only consists of a positional attribute.
It is easy to define custom vertex formats. The procedure is best explained with an example. Lets assume you want to define a vertex that has additional properties for normal vectors and 2D texture coordinates.
The first step is to define the missing vertex components. The VertexNormal type already provides a vertex component for normal vectors, so lets define a component for 2D texture coordinates:
It is necessary that a vertex component is implemented as a POD, i.e. plain old data type. Virtual methods would mess up the memory layout. However, you might define a constructor that initializes default values, if you wanted.
The next step is to compose the vertex format:
The order of the base classes is arbitrary, but it must be consistent with what comes next, namely the specification of the vertex format.
You should read the above like:
x
, y
, z
, w
.nx
, ny
, nz
, nw
of the normal vector.u
, v
of the texture coordinates vector.When writing your shader, you must declare the vertex format consistently:
Documentation generated by Doxygen