CGPdocs

hierarchy_mesh_drawable

Tree of mesh_drawable elements, each placed relative to its parent (articulated objects).

A character as a tree: each node stores its transform relative to its parent, and its global transform is the global transform of its parent times its local transform.
A character as a tree: each node stores its transform relative to its parent, and its global transform is the global transform of its parent times its local transform. Tap to enlarge.
Each node is placed in the frame of its parent; update_local_to_global_coordinates computes global = global(parent) * local into hierarchy_transform_model, and draw uses hierarchy_transform_model * model as model matrix.
Each node is placed in the frame of its parent; update_local_to_global_coordinates computes global = global(parent) * local into hierarchy_transform_model, and draw uses hierarchy_transform_model * model as model matrix. Tap to enlarge.

Fields and methods

Members of the struct hierarchy_mesh_drawable. Most of what you do with a CGP type goes through the free functions listed below.

Fields

std::vector<hierarchy_mesh_drawable_node> elementsNodes of the hierarchy, stored so that every parent comes before its children.
std::map<std::string,int> name_mapLookup table giving the index in elements of each node name.

Methods

void add(hierarchy_mesh_drawable_node const& node)Appends the node and registers its name, aborting if the hierarchy becomes invalid (duplicate name or parent not yet added).3 overloads src
void add(mesh_drawable const& element, std::string const& name, std::string const& name_parent = "global_frame", vec3 const& translation = vec3(), rotation_transform const& = rotation_transform())Appends a copy of the drawable as a node with the given name and parent (global_frame by default) and a local transform made of the rotation and translation, with scaling 1. src
void add(mesh_drawable const& element, std::string const& name, std::string const& name_parent, affine_rts const& transform)Appends a copy of the drawable as a node with the given name, parent and local transform. src
Returns the node with the given name, printing the available names and aborting if it does not exist. src
Sets the hierarchy_transform_model of each drawable to its parent global transform times its transform_local, in the order of elements, and must be called after changing a local transform and before draw. src
Returns a text listing each node index, name and parent name, for debugging. src

Functions taking a hierarchy_mesh_drawable

Draw 2

void draw(
    hierarchy_mesh_drawable const& drawable,
    environment_generic_structure const& environment = environment_generic_structure(),
    int instance_count = 1,
    bool expected_uniforms = true,
    uniform_generic_structure const& additional_uniforms = uniform_generic_structure()
)

Draw every node of the hierarchy with draw(mesh_drawable); call update_local_to_global_coordinates() beforehand.

void draw_wireframe(
    hierarchy_mesh_drawable const& drawable,
    environment_generic_structure const& environment = environment_generic_structure(),
    vec3 const& color = { 0,0,1 },
    int instance_count = 1,
    bool expected_uniforms = true,
    uniform_generic_structure const& additional_uniforms = uniform_generic_structure()
)

Draw the triangle edges of every node of the hierarchy in a flat color (no effect with Emscripten/WebGL).

Functions returning a hierarchy_mesh_drawable

None.

Operators

None.

CGP - Computer Graphics Programming.