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

Represents an area with collision shapes and nodes. More...

#include <physics.h>

Inheritance diagram for Area:
Collaboration diagram for Area:

Public Member Functions

void constructor (int signal_id)
 Constructor for the physics area class.
 
void load (FILE *file, Camera **c, Script *scripts, Node *editor)
 Loads data from a file and initializes the given camera, scripts, and editor node.
 
void collect_node (Node *node, float distance, vec3 impactPoint)
 Collects a node based on the given distance and calculates the impact point.
 
void is_area (bool *area)
 Checks if the given area is valid.
 
void sort_nodes ()
 Sorts the nodes in the physics area.
 
void update (vec3 pos, vec3 rot, vec3 scale)
 Updates the position, rotation, and scale of an object.
 
void get_collisions_shapes (Node ****shapes, u8 **length)
 Retrieves the collision shapes and their lengths.
 
void get_node_collection (CollectedNode **nodes, u8 *length)
 Retrieves a collection of nodes.
 
void save (FILE *file)
 Saves the current state of the physics area to a file.
 
- Public Member Functions inherited from PhysicalNode
void free ()
 Frees the resources allocated for the PhysicalNode instance.
 
- Public Member Functions inherited from Node
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.
 

Static Public Member Functions

static int compare_distance_nodes (const void *a, const void *b)
 Compares the distances of two nodes.
 

Public Attributes

struct Node ** collisionsShapes
 
u8 length
 
struct CollectedNodecollectedNodes
 
u32 collectedLength
 
u16 signal_id
 
- Public Attributes inherited from Node
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
 

Additional Inherited Members

- Static Public Attributes inherited from Node
static Shader glowShader = 0
 A static Shader variable used for glow effect.
 

Detailed Description

Represents an area with collision shapes and nodes.

This structure holds information about an area, including its collision shapes, collected nodes, and sorted nodes.

Member Function Documentation

◆ constructor()

void Area::constructor ( int  signal_id)
inline

Constructor for the physics area class.

This function initializes a new instance of the physics area class with the given signal ID.

Parameters
signal_idThe signal ID to initialize the physics area instance with.

◆ load()

void Area::load ( FILE *  file,
Camera **  c,
Script scripts,
Node editor 
)
inline

Loads data from a file and initializes the given camera, scripts, and editor node.

This function reads data from the specified file and uses it to initialize the provided camera, scripts, and editor node. The exact format and content of the file are assumed to be known by the caller.

Parameters
fileA pointer to the FILE object from which data will be read.
cA double pointer to a Camera object that will be initialized with data from the file.
scriptsA pointer to a Script object that will be initialized with data from the file.
editorA pointer to a Node object representing the editor that will be initialized with data from the file.

◆ collect_node()

void Area::collect_node ( Node node,
float  distance,
vec3  impactPoint 
)
inline

Collects a node based on the given distance and calculates the impact point.

This function processes a given node and calculates the impact point based on the specified distance.

Parameters
nodeA pointer to the Node structure that needs to be processed.
distanceA double value representing the distance used in the calculation.
impactPointVec3 where the calculated impact point will be stored.

◆ is_area()

void Area::is_area ( bool *  area)
inline

Checks if the given area is valid.

This function takes a pointer to a boolean variable and checks if the area is valid.

Parameters
areaA pointer to a boolean variable that indicates the validity of the area.

◆ compare_distance_nodes()

static int Area::compare_distance_nodes ( const void *  a,
const void *  b 
)
inlinestatic

Compares the distances of two nodes.

This function is used to compare the distances of two nodes. It is typically used in sorting algorithms where nodes need to be ordered based on their distances.

Parameters
aPointer to the first node to compare.
bPointer to the second node to compare.
Returns
An integer less than, equal to, or greater than zero if the distance of the first node is considered to be respectively less than, equal to, or greater than the distance of the second node.

◆ sort_nodes()

void Area::sort_nodes ( )
inline

Sorts the nodes in the physics area.

This function sorts the nodes in the physics area based on a specific criterion. The sorting algorithm and criterion are not specified in the provided code snippet.

Note
Ensure that the nodes are properly initialized before calling this function.

◆ update()

void Area::update ( vec3  pos,
vec3  rot,
vec3  scale 
)
inline

Updates the position, rotation, and scale of an object.

This function takes pointers to the position, rotation, and scale of an object and updates them accordingly.

Parameters
posVec3 position of the object. It is expected to be a float array of size 3 representing x, y, and z coordinates.
rotVec3 rotation of the object. It is expected to be a float array of size 3 representing rotation angles around x, y, and z axes.
scaleVec3 scale of the object. It is expected to be a float array of size 3 representing scaling factors along x, y, and z axes.

◆ get_collisions_shapes()

void Area::get_collisions_shapes ( Node ****  shapes,
u8 **  length 
)
inline

Retrieves the collision shapes and their lengths.

This function populates the provided pointers with the collision shapes and their corresponding lengths.

Parameters
shapesA pointer to a 4-dimensional array of Node pointers. This will be populated with the collision shapes.
lengthA pointer to an array of unsigned 8-bit integers. This will be populated with the lengths of the collision shapes.

◆ get_node_collection()

void Area::get_node_collection ( CollectedNode **  nodes,
u8 length 
)
inline

Retrieves a collection of nodes.

This function populates the provided array with a collection of nodes and sets the length of the collection.

Parameters
[out]nodesA pointer to an array of CollectedNode pointers that will be populated with the nodes.
[out]lengthA pointer to an unsigned 8-bit integer that will be set to the length of the node collection.

◆ save()

void Area::save ( FILE *  file)
inline

Saves the current state of the physics area to a file.

This function writes the current state of the physics area to the specified file. The file should be opened in a mode that allows writing before calling this function.

Parameters
fileA pointer to a FILE object that identifies the file to which the state will be saved.

Member Data Documentation

◆ collisionsShapes

struct Node** Area::collisionsShapes

◆ length

u8 Area::length

< Array of collected nodes with distances.

◆ collectedNodes

struct CollectedNode* Area::collectedNodes

< Number of collision shapes.

◆ collectedLength

u32 Area::collectedLength

< Array of collected nodes with distances.

◆ signal_id

u16 Area::signal_id

< Number of collected nodes.


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