#include <Mesh.h>

Description

3D object defined by triangle primitives.

A Mesh contains 2 components: the Mesh itself and a series of MeshObject s. The Mesh itself provides the base data: vertex positions, normals, UVs, you name it. A MeshObject contains the actual application of that source data, expressing what vertices to use, the material to render the vertices with, etc. Using the Mesh - MeshObject reloationship aptly can allow for flexible control over performance vs. memory cost.

Data Structures

class  MeshObject
 

Public Types

enum  VertexAttribute {
  Position,
  Normal,
  UV,
  UserData
}
 

Functions

void SetVertexCount (uint32_t t)
 
void DefineVertices (VertexAttribute, const std::vector< Dynacoe::Vector > &vertexData)
 
Vector GetVertex (uint32_t index, VertexAttribute) const
 
void SetVertex (uint32_t index, VertexAttribute, const Vector &p)
 
uint32_t NumVertices () const
 
int AddObject (const MeshObject &)
 
MeshObjectGet (int i)
 
void RemoveObject (int)
 
int NumObjects ()
 
bool IsShallow ()
 
void MakeUnique ()
 

Static Functions

static const MeshBasic_Cube ()
 
static const MeshBasic_Square ()
 

Member Enumeration Documentation

enum VertexAttribute
strong

The type of vertex attribute.

Enumerator
Position 

Position of the vertex. 3 components: xyz.

Normal 

The normal vector of the vertex. 3 components: xyz.

UV 

The texture cooridates of the vertex. 2 components: xy.

UserData 

User-defined data. 3 components: xyz.

Member Function Documentation

void SetVertexCount ( uint32_t  t)

sets the number of vertices this mesh will hold. This will pre-emptively allocated space for the mesh vertices as well.

Parameters
iNumber of vertices this Mesh should hold.
void DefineVertices ( VertexAttribute  ,
const std::vector< Dynacoe::Vector > &  vertexData 
)

Explicitly defines the vertices of the mesh.

This overwrites any previous geometry data. Normal data is also overwritten to be zero. The vectors contain per-vertex data:

Parameters
vertexPositionsx, y, z of the local vertex
vertexTextureCoordinatesx, y of the texture, 0 to 1
Vector GetVertex ( uint32_t  index,
VertexAttribute   
) const

Gets the vertex at the given index.

void SetVertex ( uint32_t  index,
VertexAttribute  ,
const Vector p 
)

Sets the vertex at the given.

uint32_t NumVertices ( ) const

Returns the number of vertices.

int AddObject ( const MeshObject )

Adds a MeshObject to the Mesh. When drawn, the MeshObject's faceList will refer to vertices of this mesh.

MeshObject* Get ( int  i)

Retrieves the i'th mesh object of the mesh.

If none exists at the specified position nullptr is returned.

void RemoveObject ( int  )

Removes the obejct at the speicifed position.

int NumObjects ( )

Returns the number of added objects.

bool IsShallow ( )

Returns whether the mesh is a shallow mesh, mean it does not own its vertices.

void MakeUnique ( )

If shallow, the mesh creates is own copy of vertices, making it no longer shallow. If the Mesh is not shallow, no action is taken.

static const Mesh& Basic_Cube ( )
static

Returns a Mesh representing a boring cube.

static const Mesh& Basic_Square ( )
static

Returns a Mesh representing a boring square.


The documentation for this class was generated from the following file:
  • /home/jc/git/Dynacoe/DynacoeSrc/includes/Dynacoe/Mesh.h