gdk-graphics 0b051eb9b5c1eaa0658babaa4463dd7a80aa9d2c
Loading...
Searching...
No Matches
gdk::model_data Class Referencefinal

vertex data stored in system memory. More...

#include <model_data.h>

Public Types

enum class  primitive_mode { triangles }
 
using attribute_collection_type = std::unordered_map<std::string, attribute_data>
 
using index_value_type = unsigned short
 

Public Member Functions

primitive_mode get_primitive_mode () const
 get the primitive mode
 
const std::vector< index_value_type > & indexes () const
 get list of indexes
 
const attribute_collection_type & attributes () const
 get collection of all attribute data
 
const attribute_dataget_attribute_data (const std::string &aAttributeName) const
 get attribute data by name, e.g: "a_Position"
 
attribute_dataget_attribute_data (const std::string &aAttributeName)
 get attribute data by name, e.g: "a_Position"
 
void clear ()
 clears all state from this model_data instance
 
void transform (const std::string &aPositionAttributeName, const graphics_vector3_type &aPos, const graphics_quaternion_type &aRot={}, const graphics_vector3_type &aSca={1})
 applies a transformation to a 3 component attribute
 
void transform (const std::string &aPositionAttributeName, graphics_matrix4x4_type &aTransform)
 
void transform (const std::string &aUVAttributeName, const graphics_vector2_type &aPos, const float aRotation=0, const graphics_vector2_type &aSca={1})
 applies a transformation to a 2 component attribute
 
void sort_by_nearest_triangle (const graphics_vector3_type &aObserverWorldPosition, graphics_matrix4x4_type aEntityInstanceWorldMatrix, const std::string &aPositionAttributeName="a_Position")
 
void sort_by_furthest_triangle (const graphics_vector3_type &aObserverWorldPosition, graphics_matrix4x4_type aEntityInstanceWorldMatrix, const std::string &aPositionAttributeName="a_Position")
 
void push_back (const model_data &other)
 append a different model_data to this model_data
 
void overwrite (const size_t index, const model_data &other)
 overwrite a section of vertex data using another vertex data instance
 
void overwrite (const std::string &aAttributeName, const size_t vertexOffset, const model_data &other)
 overwrite a section of a single attribute in the vertex data
 
size_t vertex_count () const
 get number of verticies in the data
 
model_data operator+ (const model_data &aData)
 create a new instance that is a concatenation of two separate datas
 
model_dataoperator+= (const model_data &other)
 
model_dataoperator= (model_data &&other)=default
 support move semantics
 
 model_data (model_data &&)=default
 support move semantics
 
 model_data (const model_data &)=default
 support copy semantics
 
model_dataoperator= (const model_data &other)=default
 support copy semantics
 
 model_data ()=default
 default inited model_data is very useful for procedurally generated data
 
 model_data (attribute_collection_type &&aAttributeData)
 

Static Public Member Functions

static model_data make_quad ()
 creates model data for a unit sized quad with position and uv data
 

Detailed Description

vertex data stored in system memory.

vertex data is comprised of a collection of attributes, which in turn are a collection of components

Member Function Documentation

◆ operator+=()

model_data & gdk::model_data::operator+= ( const model_data & other)

append a copy of different model_data to this model_data \warn must be same format

◆ overwrite() [1/2]

void gdk::model_data::overwrite ( const size_t index,
const model_data & other )

overwrite a section of vertex data using another vertex data instance

formats must match exactly, the incoming data cannot write past the end of this

◆ overwrite() [2/2]

void gdk::model_data::overwrite ( const std::string & aAttributeName,
const size_t vertexOffset,
const model_data & other )

overwrite a section of a single attribute in the vertex data

the vertex data must contain an attribute with the given name and that attribute must have the same # of components

◆ sort_by_furthest_triangle()

void gdk::model_data::sort_by_furthest_triangle ( const graphics_vector3_type & aObserverWorldPosition,
graphics_matrix4x4_type aEntityInstanceWorldMatrix,
const std::string & aPositionAttributeName = "a_Position" )

sorts verticies from furthest to nearest based on the distance between the centroid of the triangles they form and a given position in world space

◆ sort_by_nearest_triangle()

void gdk::model_data::sort_by_nearest_triangle ( const graphics_vector3_type & aObserverWorldPosition,
graphics_matrix4x4_type aEntityInstanceWorldMatrix,
const std::string & aPositionAttributeName = "a_Position" )

sorts verticies from nearest to furthest based on the distance between the centroid of the triangles they form and a given position in world space


The documentation for this class was generated from the following file: