Represents a node in the tree structure. More...
#include <node.h>
Public Member Functions | |
void | constructor () |
Constructor for the Node class. | |
void | initialize_node () |
Initializes a node. | |
void | get_glow_shader (Shader *shader) |
Retrieves the glow shader. | |
void | get_settings_data (void ***ptr, int *length) |
Retrieves settings data. | |
void | load () |
Loads the necessary resources or data for the node. | |
void | save (FILE *file) |
Saves the current state to the specified file. | |
void | prepare_render (mat4 modelMatrix, Shader activeShader) |
Renders a node using the specified model matrix and shader. | |
void | render () |
Renders the node. | |
void | update_global_position (vec3 pos, vec3 rot, vec3 scale) |
Updates the global position of a node. | |
void | update (vec3 pos, vec3 rot, vec3 scale) |
Updates the position, rotation, and scale of a node. | |
void | on_resize () |
Handles the resize event for the node. | |
void | free () |
Frees the resources allocated by the object. | |
void | is_cshape (bool *cshape) |
Checks if the current shape is a custom shape. | |
void | is_body (bool *body) |
Sets the body status of the node. | |
void | is_area (bool *area) |
Checks if the current node is within a specified area. | |
void | is_render_target (bool *render_target) |
Sets the render target status. | |
void | is_gui_element (bool *result) |
Determines if the current node is a GUI element. | |
void | add_child (Node *child) |
Adds a child node to a parent node. | |
void | add_child_and_realloc (Node *child) |
Adds a child node to a parent node and reallocates memory if necessary. | |
void | remove_child (Node *child) |
Removes a child node from a parent node. | |
void | remove_child_and_realloc (Node *child) |
Removes a child node from a parent node and reallocates memory if necessary. | |
void | remove_child_and_free (Node *child) |
Removes a child node from a parent node and frees the memory of the child node. | |
void | remove_child_and_free_and_realloc (Node *child) |
Removes a child node from a parent node, frees the memory of the child node, and reallocates memory if necessary. | |
int | index_of_child (Node *child) |
Retrieves the index of a child node in a parent node's children array. | |
void | print (int level) |
Prints the details of a node at a specified level of indentation. | |
void | emit_ready (...) |
Emits the 'ready' signal for the node. | |
void | emit_update (...) |
Emits an update event for the node. | |
void | emit_signal (...) |
Emits a signal if the node has a script and the script has a signal handler. | |
Public Attributes | |
void * | object |
struct Node ** | children |
struct Node * | parent |
u16 | length |
u8 | type |
u8 | flags |
vec3 | pos |
vec3 | rot |
vec3 | scale |
vec3 | globalPos |
vec3 | globalRot |
vec3 | globalScale |
Behavior * | behavior |
BehaviorAttribute * | attribute |
u8 | attributes_count |
Shader | shader |
Static Public Attributes | |
static Shader | glowShader = 0 |
A static Shader variable used for glow effect. | |
Represents a node in the tree structure.
|
inline |
|
inline |
Initializes a node.
This function sets up the necessary parameters and state for a node. It should be called before using the node in any operations to ensure it is properly initialized.
|
inline |
Retrieves the glow shader.
This function assigns the glow shader to the provided Shader object.
shader | A pointer to a Shader object where the glow shader will be stored. |
|
inline |
Retrieves settings data.
This function populates the provided pointer with settings data and sets the length of the data.
[out] | ptr | A pointer to a pointer to a pointer that will be set to the settings data. |
[out] | length | A pointer to an integer that will be set to the length of the settings data. |
|
inline |
Loads the necessary resources or data for the node.
This function is responsible for initializing and loading any resources, data, or configurations required by the node. It should be called before the node is used to ensure that all dependencies are properly set up.
|
inline |
Saves the current state to the specified file.
This function writes the current state of the object to the given file. The file must be opened in write mode before calling this function.
file | A pointer to a FILE object that identifies the file to which the state will be saved. The file should be opened in write mode. |
|
inline |
Renders a node using the specified model matrix and shader.
This function renders the specified node using the provided model matrix and active shader.
modelMatrix | The model matrix to be used for rendering. |
activeShader | The shader to be used for rendering. |
|
inline |
Renders the node.
This function is responsible for rendering the node. It should be called whenever the node needs to be drawn on the screen. The specific rendering implementation details are handled within this function.
|
inline |
Updates the global position of a node.
This function updates the global position of a node based on the provided position, rotation, and scale vectors. It modifies the input vectors to reflect the new global position.
pos | Pointer to a vec3 structure representing the position vector. |
rot | Pointer to a vec3 structure representing the rotation vector. |
scale | Pointer to a vec3 structure representing the scale vector. |
|
inline |
Updates the position, rotation, and scale of a node.
This function takes pointers to vec3 structures representing the position, rotation, and scale of a node and updates them accordingly.
pos | Pointer to a vec3 structure representing the position of the node. |
rot | Pointer to a vec3 structure representing the rotation of the node. |
scale | Pointer to a vec3 structure representing the scale of the node. |
|
inline |
Handles the resize event for the node.
This function is called when the node needs to respond to a resize event. It adjusts the node's properties and layout to accommodate the new size.
|
inline |
Frees the resources allocated by the object.
This function is responsible for releasing any memory or resources that were allocated by the object. It should be called when the object is no longer needed to avoid memory leaks.
|
inline |
Checks if the current shape is a custom shape.
This function determines whether the current shape is a custom shape and sets the provided boolean pointer accordingly.
cshape | A pointer to a boolean variable. The function sets this variable to true if the current shape is a custom shape, otherwise it sets it to false. |
|
inline |
Sets the body status of the node.
This function sets the body status of the node by modifying the value pointed to by the provided boolean pointer.
body | A pointer to a boolean variable that will be set to indicate the body status of the node. If the node is a body, the value pointed to by this parameter will be set to true; otherwise, it will be set to false. |
|
inline |
Checks if the current node is within a specified area.
This function determines whether the current node falls within a given area. The result is stored in the boolean pointer provided as an argument.
area | A pointer to a boolean variable where the result will be stored. The value will be set to true if the node is within the area, and false otherwise. |
|
inline |
Sets the render target status.
This function sets the status of whether the current node is a render target.
render_target | A pointer to a boolean value. If true, the node is set as a render target. If false, the node is not a render target. |
|
inline |
Determines if the current node is a GUI element.
This function checks whether the current node is a graphical user interface (GUI) element and sets the result accordingly.
result | A pointer to a boolean variable where the result will be stored.
|
|
inline |
Adds a child node to a parent node.
This function adds a child node to the specified parent node, establishing a parent-child relationship in the scene graph.
child | The child node to be added. |
|
inline |
Adds a child node to a parent node and reallocates memory if necessary.
This function adds a child node to the specified parent node and reallocates memory for the parent's children array if needed to accommodate the new child.
child | The child node to be added. |
|
inline |
Removes a child node from a parent node.
This function removes a child node from the specified parent node, breaking the parent-child relationship in the scene graph.
child | The child node to be removed. |
|
inline |
Removes a child node from a parent node and reallocates memory if necessary.
This function removes a child node from the specified parent node and reallocates memory for the parent's children array if needed to optimize memory usage.
child | The child node to be removed. |
|
inline |
Removes a child node from a parent node and frees the memory of the child node.
This function removes a child node from the specified parent node and frees the memory allocated for the child node.
child | The child node to be removed and freed. |
|
inline |
Removes a child node from a parent node, frees the memory of the child node, and reallocates memory if necessary.
This function removes a child node from the specified parent node, frees the memory allocated for the child node, and reallocates memory for the parent's children array if needed to optimize memory usage.
child | The child node to be removed and freed. |
|
inline |
Retrieves the index of a child node in a parent node's children array.
This function retrieves the index of a child node in a parent node's children array.
child | The child node whose index is to be retrieved. |
|
inline |
Prints the details of a node at a specified level of indentation.
This function prints the details of the specified node, including its properties and children, at the specified level of indentation for better readability.
node | The node to be printed. |
level | The level of indentation for printing. |
|
inline |
Emits the 'ready' signal for the node.
This function checks if the node has the NODE_SCRIPT flag set and if the BEHAVIOR_SCRIPT_READY behavior is defined. If both conditions are met, it calls the BEHAVIOR_SCRIPT_READY behavior function with the current node instance and the provided arguments.
... | args The arguments to pass to the behavior function. |
|
inline |
Emits an update event for the node.
This function checks if the node has the NODE_SCRIPT flag set and if the behavior script for the update event is defined. If both conditions are met, it calls the update behavior script with the current node and provided arguments.
... | args Arguments to be passed to the behavior script. |
|
inline |
Emits a signal if the node has a script and the script has a signal handler.
This function checks if the node has a script associated with it by verifying the NODE_SCRIPT flag. If the node has a script and the script contains a signal handler for BEHAVIOR_SCRIPT_SIGNAL, it calls the signal handler with the current node and the provided arguments.
... | args The arguments to be passed to the signal handler. |
|
static |
A static Shader variable used for glow effect.
This static variable holds the shader program used to apply a glow effect to the nodes. It is initialized to 0 and should be assigned a valid shader program before use.
void* Node::object |
A pointer to an object associated with the node.
struct Node** Node::children |
An array of child nodes.
struct Node* Node::parent |
A pointer to the parent node.
u16 Node::length |
The number of child nodes.
u8 Node::type |
The type of the node.
u8 Node::flags |
Flags indicating the state and properties of the node.
vec3 Node::pos |
The position of the node.
vec3 Node::rot |
The rotation of the node.
vec3 Node::scale |
The scale of the node.
vec3 Node::globalPos |
The global position of the node.
vec3 Node::globalRot |
The global rotation of the node.
vec3 Node::globalScale |
The global scale of the node.
Behavior* Node::behavior |
The behavior associated with the node.
BehaviorAttribute* Node::attribute |
The parameters associated with the behavior.
u8 Node::attributes_count |
The number of parameters associated with the behavior.
Shader Node::shader |
The shader associated with the node.