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

Represents a static body in the physics simulation. More...

#include <bodies.h>

Inheritance diagram for StaticBody:
Collaboration diagram for StaticBody:

Public Member Functions

void constructor (vec3 forcedNormal)
 Constructor for the static body class.
 
void get_collisions_shapes (Node ****shapes, u8 **length)
 Retrieves the collision shapes and their lengths.
 
void update_global_position (vec3 pos, vec3 rot, vec3 scale)
 Updates the global position of a static body.
 
void update (vec3 pos, vec3 rot, vec3 scale)
 Updates the position, rotation, and scale of a static body.
 
void load (FILE *file, Camera **c, Script *scripts, Node *editor)
 Loads data from a file and initializes the provided Camera, Script, and Node structures.
 
void save (FILE *file)
 Saves the current state of the static body to a file.
 
float get_velocity_norm ()
 Get the velocity norm of a node.
 
void get_velocity (vec3 velocity)
 Get the velocity of a node.
 
void get_mass (float *mass)
 Get the mass of a node.
 
void get_center_of_mass (vec3 com)
 Get the center of mass of a node.
 
void get_collision_normal (vec3 normal)
 Retrieves the collision normal vector.
 
- Public Member Functions inherited from Body
void is_body (bool *body)
 Checks if the given pointer represents a body.
 
void apply_impulse ()
 Applies an impulse to the physics body.
 
void add_shape (Node *child)
 Adds a child shape to the specified node.
 
void add_shape_and_realloc (Node *child)
 Adds a child shape to the specified node and reallocates memory if necessary.
 
void remove_shape (Node *child)
 Removes a child shape from the specified node.
 
void remove_shape_and_realloc (Node *child)
 Removes a child shape from the specified node and reallocates memory if necessary.
 
void remove_shape_and_free (Node *child)
 Removes a child shape from the specified node and frees the memory allocated for the child shape.
 
void remove_shape_and_free_and_realloc (Node *child)
 Removes a child shape from the specified node, frees the memory allocated for the child shape, and reallocates memory if necessary.
 
void get_collision_normal (float *normal)
 Calculates the collision normal vector.
 
- 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.
 

Public Attributes

struct Node ** collisionsShapes
 
vec3 forcedNormal
 
u8 length
 
- 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 a static body in the physics simulation.

A static body does not move and is used for objects like walls or floors.

Member Function Documentation

◆ constructor()

void StaticBody::constructor ( vec3  forcedNormal)
inline

Constructor for the static body class.

This function initializes a static body with the given normal force.

Parameters
forcedNormalVec3 representing the normal force to be applied to the static body.

◆ get_collisions_shapes()

void StaticBody::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.

◆ update_global_position()

void StaticBody::update_global_position ( vec3  pos,
vec3  rot,
vec3  scale 
)
inline

Updates the global position of a static body.

This function updates the global position of a static body based on the provided position, rotation, and scale vectors.

Parameters
posVec3 structure representing the position of the static body.
rotVec3 structure representing the rotation of the static body.
scaleVec3 structure representing the scale of the static body.

◆ update()

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

Updates the position, rotation, and scale of a static body.

This function updates the transformation properties of a static body in the physics engine.

Parameters
posVec3 structure representing the position of the static body.
rotVec3 structure representing the rotation of the static body.
scaleVec3 structure representing the scale of the static body.

◆ load()

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

Loads data from a file and initializes the provided Camera, Script, and Node structures.

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

◆ save()

void StaticBody::save ( FILE *  file)
inline

Saves the current state of the static body to a file.

This function writes the relevant data of the static body to the provided file.

Parameters
fileA pointer to a FILE object that identifies the file to which the data will be written.

◆ get_velocity_norm()

float StaticBody::get_velocity_norm ( )
inline

Get the velocity norm of a node.

Returns
The velocity norm of the node.

◆ get_velocity()

void StaticBody::get_velocity ( vec3  velocity)
inline

Get the velocity of a node.

Parameters
velocityOutput vector to store the velocity.

◆ get_mass()

void StaticBody::get_mass ( float *  mass)
inline

Get the mass of a node.

Parameters
massOutput pointer to store the mass.

◆ get_center_of_mass()

void StaticBody::get_center_of_mass ( vec3  com)
inline

Get the center of mass of a node.

Parameters
comOutput vector to store the center of mass.

◆ get_collision_normal()

void StaticBody::get_collision_normal ( vec3  normal)
inline

Retrieves the collision normal vector.

This function calculates and returns the normal vector of a collision. The normal vector is a unit vector that is perpendicular to the surface at the point of collision.

Parameters
[out]normalVec3 where the normal vector will be stored.

Member Data Documentation

◆ collisionsShapes

struct Node** StaticBody::collisionsShapes

Array of collision shapes associated with the static body.

◆ forcedNormal

vec3 StaticBody::forcedNormal

If defined, force the collision normal of the static body.

◆ length

u8 StaticBody::length

Number of collision shapes.


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