t
|
The base 3D geometry class. More...
#include <Geometry.hpp>
Public Member Functions | |
Geometry (const BufferAttribute< double > &_vertexPositions, const BufferAttribute< double > &_vertexNormals) | |
Creates a new 3D geometry with the specified vertex buffer and normal buffer. | |
void | setIndices (BufferAttribute< int > _faceIndices) |
Sets the index buffer of this geometry. | |
Public Attributes | |
BufferAttribute< double > | vertexPositions |
The vertex buffer. | |
std::optional< BufferAttribute< int > > | faceIndices |
The index buffer, which is optional. | |
BufferAttribute< double > | vertexNormals |
The normal buffer. | |
FrontFace | frontFace |
The vertex winding order which classifies the front face of a triangle. | |
The base 3D geometry class.
A 3D geometry defines the shape of a 3D object.
A 3D geometry is defined in terms of triangles (which have 3 vertices each) and contains the following data:
Here is an example of creating a simple depth-less triangle geometry.
In the above example, the triangle has 3 vertices at \((0, 1, 0), (-1, 0, 0), (1, 0, 0)\). All 3 vertex normals point towards the positive Z direction on creation.
|
inline |
Creates a new 3D geometry with the specified vertex buffer and normal buffer.
The new geometry will not have an index buffer by default. To set the index buffer, use setIndices
.
The new geometry will assume that the vertices for a front-facing triangle appear in counter-clockwise order. See frontFace
.
_vertexPositions | The vertex buffer of the new geometry. |
_vertexNormals | The normal buffer of the new geometry. |
|
inline |
Sets the index buffer of this geometry.
Every 3 consecutive numbers in this buffer are indices of vertices that form a single triangle.
_faceIndices | The new index buffer of this geometry. |
std::optional<BufferAttribute<int> > t::Geometry::faceIndices |
The index buffer, which is optional.
Every 3 consecutive numbers in this buffer are the indices of the 3 vertices that make up a single triangle.
FrontFace t::Geometry::frontFace |
The vertex winding order which classifies the front face of a triangle.
If the verticies of a triangle after having been transformed in the Material#vertexShader
are in this order, then the triangle is considered to be front-facing. Used in conjunction with Material#cullMode
to determine if a triangle should be drawn or not.
BufferAttribute<double> t::Geometry::vertexNormals |
The normal buffer.
Every 3 consecutive numbers in this buffer are the x, y, and z components of the normal vector of the corresponding vertex.
BufferAttribute<double> t::Geometry::vertexPositions |
The vertex buffer.
Every 3 consecutive numbers in this buffer define the x, y, and z coordinates of a single vertex. The order in which a vertex appears in the buffer defines its index e.g. the first 3 numbers are the position of the vertex at index 0, the next 3 numbers are the position of the vertex at index 1, and so on. If the index buffer is missing, then every 3 consecutive vertices (i.e. 9 consecutive numbers) in this buffer form a triangle.