Claude Chappe' Curse - A C Game
Logo Institut d'Informatique Claude Chappe Logo Université de Le Mans Logo Raeptor Production
 
Loading...
Searching...
No Matches
Node Class Reference

Represents a node in the tree structure. More...

#include <node.h>

Inheritance diagram for Node:
Collaboration diagram for Node:

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 Nodeparent
 
u16 length
 
u8 type
 
u8 flags
 
vec3 pos
 
vec3 rot
 
vec3 scale
 
vec3 globalPos
 
vec3 globalRot
 
vec3 globalScale
 
Behaviorbehavior
 
BehaviorAttributeattribute
 
u8 attributes_count
 
Shader shader
 

Static Public Attributes

static Shader glowShader = 0
 A static Shader variable used for glow effect.
 

Detailed Description

Represents a node in the tree structure.

Member Function Documentation

◆ constructor()

void Node::constructor ( )
inline

Constructor for the Node class.

This function initializes a new instance of the Node class. It sets up the necessary properties and states for the node.

Note
Ensure that all required resources are available before calling this constructor.

◆ initialize_node()

void Node::initialize_node ( )
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.

◆ get_glow_shader()

void Node::get_glow_shader ( Shader shader)
inline

Retrieves the glow shader.

This function assigns the glow shader to the provided Shader object.

Parameters
shaderA pointer to a Shader object where the glow shader will be stored.

◆ get_settings_data()

void Node::get_settings_data ( void ***  ptr,
int *  length 
)
inline

Retrieves settings data.

This function populates the provided pointer with settings data and sets the length of the data.

Parameters
[out]ptrA pointer to a pointer to a pointer that will be set to the settings data.
[out]lengthA pointer to an integer that will be set to the length of the settings data.

◆ load()

void Node::load ( )
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.

◆ save()

void Node::save ( FILE *  file)
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.

Parameters
fileA pointer to a FILE object that identifies the file to which the state will be saved. The file should be opened in write mode.

◆ prepare_render()

void Node::prepare_render ( mat4  modelMatrix,
Shader  activeShader 
)
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.

Parameters
modelMatrixThe model matrix to be used for rendering.
activeShaderThe shader to be used for rendering.

◆ render()

void Node::render ( )
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.

◆ update_global_position()

void Node::update_global_position ( vec3  pos,
vec3  rot,
vec3  scale 
)
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.

Parameters
posPointer to a vec3 structure representing the position vector.
rotPointer to a vec3 structure representing the rotation vector.
scalePointer to a vec3 structure representing the scale vector.

◆ update()

void Node::update ( vec3  pos,
vec3  rot,
vec3  scale 
)
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.

Parameters
posPointer to a vec3 structure representing the position of the node.
rotPointer to a vec3 structure representing the rotation of the node.
scalePointer to a vec3 structure representing the scale of the node.

◆ on_resize()

void Node::on_resize ( )
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.

◆ free()

void Node::free ( )
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.

◆ is_cshape()

void Node::is_cshape ( bool *  cshape)
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.

Parameters
cshapeA 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.

◆ is_body()

void Node::is_body ( bool *  body)
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.

Parameters
bodyA 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.

◆ is_area()

void Node::is_area ( bool *  area)
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.

Parameters
areaA 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.

◆ is_render_target()

void Node::is_render_target ( bool *  render_target)
inline

Sets the render target status.

This function sets the status of whether the current node is a render target.

Parameters
render_targetA pointer to a boolean value. If true, the node is set as a render target. If false, the node is not a render target.

◆ is_gui_element()

void Node::is_gui_element ( bool *  result)
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.

Parameters
resultA pointer to a boolean variable where the result will be stored.
  • true if the node is a GUI element.
  • false otherwise.

◆ add_child()

void Node::add_child ( Node child)
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.

Parameters
childThe child node to be added.

◆ add_child_and_realloc()

void Node::add_child_and_realloc ( Node child)
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.

Parameters
childThe child node to be added.

◆ remove_child()

void Node::remove_child ( Node child)
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.

Parameters
childThe child node to be removed.

◆ remove_child_and_realloc()

void Node::remove_child_and_realloc ( Node child)
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.

Parameters
childThe child node to be removed.

◆ remove_child_and_free()

void Node::remove_child_and_free ( Node child)
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.

Parameters
childThe child node to be removed and freed.

◆ remove_child_and_free_and_realloc()

void Node::remove_child_and_free_and_realloc ( Node child)
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.

Parameters
childThe child node to be removed and freed.

◆ index_of_child()

int Node::index_of_child ( Node child)
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.

Parameters
childThe child node whose index is to be retrieved.
Returns
The index of the child node in the parent node's children array.
Note
If the child node is not found in the parent node's children array, the function returns -1.

◆ print()

void Node::print ( int  level)
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.

Parameters
nodeThe node to be printed.
levelThe level of indentation for printing.

◆ emit_ready()

void Node::emit_ready (   ...)
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.

Parameters
...args The arguments to pass to the behavior function.
Note
The behavior function is expected to be a callable object stored in the behavior map with the key BEHAVIOR_SCRIPT_READY.

◆ emit_update()

void Node::emit_update (   ...)
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.

Parameters
...args Arguments to be passed to the behavior script.

◆ emit_signal()

void Node::emit_signal (   ...)
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.

Parameters
...args The arguments to be passed to the signal handler.

Member Data Documentation

◆ glowShader

Node::glowShader = 0
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.

◆ object

void* Node::object

A pointer to an object associated with the node.

◆ children

struct Node** Node::children

An array of child nodes.

◆ parent

struct Node* Node::parent

A pointer to the parent node.

◆ length

u16 Node::length

The number of child nodes.

◆ type

u8 Node::type

The type of the node.

◆ flags

u8 Node::flags

Flags indicating the state and properties of the node.

◆ pos

vec3 Node::pos

The position of the node.

◆ rot

vec3 Node::rot

The rotation of the node.

◆ scale

vec3 Node::scale

The scale of the node.

◆ globalPos

vec3 Node::globalPos

The global position of the node.

◆ globalRot

vec3 Node::globalRot

The global rotation of the node.

◆ globalScale

vec3 Node::globalScale

The global scale of the node.

◆ behavior

Behavior* Node::behavior

The behavior associated with the node.

◆ attribute

BehaviorAttribute* Node::attribute

The parameters associated with the behavior.

◆ attributes_count

u8 Node::attributes_count

The number of parameters associated with the behavior.

◆ shader

Shader Node::shader

The shader associated with the node.


The documentation for this class was generated from the following files: