Node

struct glen::Node

Base node class. All other nodes derive from this. It can be used as a parent transform for other Nodes. Can be instantiated as a ‘dummy’ node.

Subclassed by CameraNode, LightNode, MeshNode

Public Functions

Node()

Constructor.

Node(const std::string name)

Constructor.

void update_view(CameraNode*)

If node type has a material, update it with the latest camera position.If node has children, update them aswell.

void draw()

Render the mesh to the screen (if applicable).

void draw_material(Material *material)

Render mesh with provided material (if applicable).

const std::string &name() const

Return

The node name

const glm::mat4 local_to_node() const

Return

Transform from the parent node to this one.

glm::mat4 *local_to_node()

Return

Transform matrix from the parent node to this one (mutable).

const glm::mat4 world_to_node() const

Return

The transform matrix from the world to this node.

const glm::mat3 world_normal_to_node() const

Return

The transform matrix normals from world to this node. This is useful for doing deferrend rendering with a g-buffer.

const glm::vec3 direction()

Return

The direction the node is pointing.

const glm::vec3 local_position() const

Return

The local coordinates.

const glm::vec3 world_position() const

Return

The world space coordinates.

const glm::vec3 local_rotation() const

Return

The local rotation (Euler angles).

const glm::vec3 local_scale() const

The local scale values.

Return

const Node *parent() const

Return

The parent of this node.

std::unordered_map<std::string, Node*> &children()

Return

The children of this node (mutable).

void add_child(Node *child)

Add a node as a child of this one.

All children will transform with their parents.

void set_parent(Node *parent)

Set which node will be the parent of this one.

Node *disconnect_child(const std::string nodeName)

Disconnect the given child node.

Return

The disconnected node (if it exists as a child)

void set_position(const glm::vec3 &position)

Set position coordinates of node.

void set_rotation(const glm::vec3 &rotation)

Set rotation (Euler angles) of node.

void set_scale(const glm::vec3 &scale)

Set the scale values of the node.

void set_scale(const GLfloat scale)

Set a single value with which to scale the node uniformly.

Mesh Node

struct glen::MeshNode : public Node

Main mesh type node. Links a mesh to a material so it can be rendered on screen

Public Functions

MeshNode(const std::string name, Mesh *mesh, Material *material)

Constructor. Name, mesh and material are required to create a Mesh Node.

MeshNode(const MeshNode &other) = delete

Use move constructor instead of copy constructor.

MeshNode(MeshNode &&other) = default

Move constructor.

MeshNode &operator=(const MeshNode &other) = delete

Use move assign instead of copy assign.

MeshNode &operator=(MeshNode &&other) = default

Move assign.

~MeshNode() = default
void update_view(CameraNode *cameraNode) override

If node type has a material, update it with the latest camera position.If node has children, update them aswell.

void draw() override

Render the mesh with assigned material applied.

void draw_material(Material *material) override

Render mesh with provided material applied.

Mesh *mesh()

Return

The mesh object (mutable)

Material *material()

Return

The assigned material (mutable)

void set_material(Material *material)

Light Node

struct glen::LightNode : public Node

Light node type. Inherits from Node. Required for adding a light to the scene

Public Functions

LightNode(const std::string name, Light *light)

Constructor.

void update_view(CameraNode *camera_node) override

If node type has a material, update it with the latest camera position.If node has children, update them aswell.

void draw() override

Render the light mesh (if enabled).

const Light *light() const

Return

The light object.

Light *light()

Return

The light object (mutable).

ShadowMap *shadowMap()

Return

The shadow map object (mutable).

const GLuint shader_pos() const

Return

The index used in some shaders (BlinnShader for instance) to identify this light

void set_shadowMap(ShadowMap *shadowMap)

Add a shadowMap object to the node so the light can cast shadows.

Parameters
  • shadowMap:

void set_shader_pos(const GLuint index)

Parameters
  • index: The index used in some shaders (BlinnShader for instance) to identify this light

Camera Node

struct glen::CameraNode : public Node

Camera node. Inherits from Node. Required for adding a camera to a scene.

Public Functions

CameraNode(const std::string name, Camera *camera)

Constructor.

void update()

Run update command on camera.

const Camera *camera() const

Return

The camera object.

Camera *camera()

Return

The camera object (mutable).

const glm::vec3 world_position() const override

Return

The world space coordinates.

const glm::mat4 world_to_cam() const

Return

The world to camera transform matrix.

const glm::mat4 world_to_projection() const

Return

The world to projection transfrom matrix.

void set_position(const glm::vec3 &position) override

Set position coordinates of node.