|
gdk-graphics 0a0aef92e917cfbac53dffbc32c295e4de914093
|
vertex data stored in system memory. More...
#include <model_data.h>
Public Types | |
| enum class | primitive_mode { triangles } |
| using | attribute_collection_type = string_keyed<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 |
| the order the vertices are drawn in, empty if they are drawn in storage order | |
| bool | indexed () const |
| does this model name its vertices in an explicit order? | |
| void | set_indexes (std::vector< index_value_type > aIndexes) |
| draw the vertices in this order rather than in the order they are stored | |
| const attribute_collection_type & | attributes () const |
| get collection of all attribute data | |
| const attribute_data & | get_attribute_data (std::string_view aAttributeName) const |
| get attribute data by name, e.g: "a_Position" | |
| attribute_data & | get_attribute_data (std::string_view 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 vector3_type &aPos, const quaternion_type &aRot={}, const vector3_type &aSca={1, 1, 1}) |
| applies a transformation to a 3 component attribute | |
| void | transform (const std::string &aPositionAttributeName, const matrix4x4_type &aTransform) |
| applies a transformation matrix to a 3 component attribute | |
| void | transform (const std::string &aUVAttributeName, const vector2_type &aPos, const float aRotation=0, const vector2_type &aSca={1, 1}) |
| applies a transformation to a 2 component attribute | |
| void | sort_by_nearest_triangle (const vector3_type &aObserverWorldPosition, matrix4x4_type aEntityInstanceWorldMatrix, std::string_view aPositionAttributeName="a_Position") |
| void | sort_by_furthest_triangle (const vector3_type &aObserverWorldPosition, matrix4x4_type aEntityInstanceWorldMatrix, std::string_view aPositionAttributeName="a_Position") |
| void | push_back (const model_data &other) |
| append a different model_data to this model_data | |
| void | overwrite (const std::size_t index, const model_data &other) |
| overwrite a section of vertex data using another vertex data instance | |
| void | overwrite (std::string_view aAttributeName, const std::size_t vertexOffset, const model_data &other) |
| overwrite a section of a single attribute in the vertex data | |
| std::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_data & | operator+= (const model_data &other) |
| model_data & | operator= (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_data & | operator= (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) | |
| model_data (attribute_collection_type &&aAttributeData, std::vector< index_value_type > &&aIndexes) | |
Static Public Member Functions | |
| static model_data | make_quad () |
| creates model data for a unit sized quad with position and uv data | |
vertex data stored in system memory.
vertex data is comprised of a collection of attributes, which in turn are a collection of components
| gdk::graphics::model_data::model_data | ( | attribute_collection_type && | aAttributeData | ) |
| exception | if an attribute is not whole vertices, or the attributes count different numbers of them |
| gdk::graphics::model_data::model_data | ( | attribute_collection_type && | aAttributeData, |
| std::vector< index_value_type > && | aIndexes ) |
| exception | if an index is past the end of aAttributeData. |
| const std::vector< index_value_type > & gdk::graphics::model_data::indexes | ( | ) | const |
the order the vertices are drawn in, empty if they are drawn in storage order
A model with indices is drawn with glDrawElements and one without with glDrawArrays. Indexing lets a vertex shared by several triangles be stored once, which for a typical closed surface is about a third of the vertices a triangle soup needs.
| model_data & gdk::graphics::model_data::operator+= | ( | const model_data & | other | ) |
append a copy of different model_data to this model_data
| void gdk::graphics::model_data::overwrite | ( | const std::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
| void gdk::graphics::model_data::overwrite | ( | std::string_view | aAttributeName, |
| const std::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
| void gdk::graphics::model_data::push_back | ( | const model_data & | other | ) |
append a different model_data to this model_data
Nothing changes when it throws. The appended indices are offset so that they still name the appended vertices. If only one of the two is indexed, the other is given the indices it implies, because the result has to be one thing or the other.
| void gdk::graphics::model_data::set_indexes | ( | std::vector< index_value_type > | aIndexes | ) |
draw the vertices in this order rather than in the order they are stored
| exception | if an index is past the end of the vertex data. Out of range indices are undefined behaviour in gl: they usually draw garbage or take the driver down, and they never say why, so they are refused here where the cause is still visible. |
An empty list removes the indices, returning the model to storage order.
| void gdk::graphics::model_data::sort_by_furthest_triangle | ( | const vector3_type & | aObserverWorldPosition, |
| matrix4x4_type | aEntityInstanceWorldMatrix, | ||
| std::string_view | 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
| void gdk::graphics::model_data::sort_by_nearest_triangle | ( | const vector3_type & | aObserverWorldPosition, |
| matrix4x4_type | aEntityInstanceWorldMatrix, | ||
| std::string_view | 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