Represents a node of a scene graph.
#include <node.hpp>
◆ Node()
◆ 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 & |
WVP, |
|
|
glm::mat4 const & |
parentTransform = glm::mat4(1.0f) |
|
) |
| const |
- Parameters
-
[in] | WVP | Matrix transforming from world-space to clip-space |
[in] | parentTransform | Matrix transforming from parent-space to world-space |
◆ render() [2/2]
void Node::render |
( |
glm::mat4 const & |
WVP, |
|
|
glm::mat4 const & |
world, |
|
|
GLuint |
program, |
|
|
std::function< void(GLuint)> const & |
set_uniforms = [](GLuint ){} |
|
) |
| const |
- Parameters
-
[in] | WVP | 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()
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_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] | pointer | to the program OpenGL shader program to use; the pointer should not be nul. |
[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 |
◆ _drawing_mode
GLenum Node::_drawing_mode |
|
private |
◆ _has_indices
◆ _indices_nb
GLsizei Node::_indices_nb |
|
private |
◆ _name
◆ _program
GLuint const* Node::_program |
|
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 |
|
private |
The documentation for this class was generated from the following files:
- /home/pmoreau/teaching/CG_Labs/src/core/node.hpp
- /home/pmoreau/teaching/CG_Labs/src/core/node.cpp