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).
-
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
-
void
add_child(Node *child)¶ Add a node as a child of this one.
All children will transform with their parents.
-
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
positioncoordinates 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,
meshandmaterialare required to create a Mesh Node.
-
~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.
-
Light Node¶
-
struct
glen::LightNode: public Node¶ Light node type. Inherits from
Node. Required for adding a light to the scenePublic Functions
-
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 GLuint
shader_pos() const¶ - Return
The index used in some shaders (
BlinnShaderfor instance) to identify this light
-
void
set_shadowMap(ShadowMap *shadowMap)¶ Add a
shadowMapobject 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 (BlinnShaderfor instance) to identify this light
-
void
Camera Node¶
-
struct
glen::CameraNode: public Node¶ Camera node. Inherits from
Node. Required for adding a camera to a scene.Public Functions
-
void
update()¶ Run update command on camera.
-
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
positioncoordinates of node.
-
void