Represents a node of a scene graph.
#include <node.hpp>
◆ add_child()
void Node::add_child |
( |
Node const * |
child | ) |
|
- Parameters
-
[in] | child | pointer to the child to add; the pointer has to be non-null |
◆ add_texture()
void Node::add_texture |
( |
std::string const & |
name, |
|
|
GLuint |
tex_id, |
|
|
GLenum |
type |
|
) |
| |
- Parameters
-
[in] | name | the variable name used by the attached OpenGL shader program; in assignment 1, this will be diffuse_texture |
[in] | tex_id | the name of an OpenGL 2D-texture |
[in] | type | the type of texture, i.e. GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc. |
◆ get_child()
Node const * Node::get_child |
( |
size_t |
index | ) |
const |
- Parameters
-
[in] | index | the index of the child to return; index should be strictly less than the number of children |
- Returns
- a pointer to the desired child
◆ get_children_nb()
size_t Node::get_children_nb |
( |
| ) |
const |
- Returns
- the number of children
◆ get_indices_nb()
size_t Node::get_indices_nb |
( |
| ) |
const |
- Returns
- how many indices to use when rendering
◆ get_transform() [1/2]
◆ get_transform() [2/2]
- Returns
- the composition of the rotation, scaling and translation transformations; this is the model matrix of this node
◆ render() [1/2]
void Node::render |
( |
glm::mat4 const & |
view_projection, |
|
|
glm::mat4 const & |
parent_transform = glm::mat4(1.0f) |
|
) |
| const |
- Parameters
-
[in] | view_projection | Matrix transforming from world-space to clip-space |
[in] | parent_transform | Matrix transforming from parent-space to world-space |
◆ render() [2/2]
void Node::render |
( |
glm::mat4 const & |
view_projection, |
|
|
glm::mat4 const & |
world, |
|
|
GLuint |
program, |
|
|
std::function< void(GLuint)> const & |
set_uniforms = [](GLuint ){} |
|
) |
| const |
Note that the internal transform of this node is not used during the rendering, only the |view_projection| and |world| matrices are.
- Parameters
-
[in] | view_projection | Matrix transforming from world-space to clip-space |
[in] | world | Matrix transforming from model-space to world-space |
[in] | program | OpenGL shader program to use |
[in] | set_uniforms | function that will take as argument an OpenGL shader program, and will setup that program's uniforms |
◆ set_geometry()
It will overwrite any constants provided by an earlier call to |set_material_constants()|.
A node without any geometry will not render itself, but its children will be rendered if they have any geometry.
- Parameters
-
[in] | shape | OpenGL data to use as geometry |
◆ set_indices_nb()
void Node::set_indices_nb |
( |
size_t const & |
indices_nb | ) |
|
- Parameters
-
[in] | indices_nb | how many indices to use when rendering |
◆ set_material_constants()
It will overwrite any constants provided by the geometry.
A node without any geometry will not render itself, but its children will be rendered if they have any geometry.
- Parameters
-
[in] | constants | Material constants to be made available during rendering |
◆ set_name()
void Node::set_name |
( |
std::string const & |
name | ) |
|
This name will be used when pushing debug groups to scope OpenGL commands and help when debugging or profiling the application using third-party applications.
- Parameters
-
[in] | name | the name used when creating the debug group during rendering; it will automatically be prefixed by "Render ". |
◆ set_program()
void Node::set_program |
( |
GLuint const *const |
program, |
|
|
std::function< void(GLuint)> const & |
set_uniforms = [](GLuint ){} |
|
) |
| |
A node without a program will not render itself, but its children will be rendered if they have one.
- Parameters
-
[in] | program | pointer to the program OpenGL shader program to use; the pointer should not be null. |
[in] | set_uniforms | function that will take as argument an OpenGL shader program, and will setup that program's uniforms |
◆ _children
std::vector<Node const*> Node::_children |
|
private |
◆ _constants
◆ _drawing_mode
GLenum Node::_drawing_mode { GL_TRIANGLES } |
|
private |
◆ _has_indices
bool Node::_has_indices { false } |
|
private |
◆ _indices_nb
GLsizei Node::_indices_nb { 0u } |
|
private |
◆ _name
std::string Node::_name {"Render un-named node"} |
|
private |
◆ _program
GLuint const* Node::_program { nullptr } |
|
private |
◆ _set_uniforms
std::function<void (GLuint)> Node::_set_uniforms |
|
private |
◆ _textures
std::vector<std::tuple<std::string, GLuint, GLenum> > Node::_textures |
|
private |
◆ _transform
◆ _vao
◆ _vertices_nb
GLsizei Node::_vertices_nb { 0u } |
|
private |
The documentation for this class was generated from the following files: