Represents a rigid body in the physics simulation. More...
#include <bodies.h>


Public Member Functions | |
| void | constructor (vec3 velocity, vec3 angularVelocity, vec3 gravity, float mass, float friction, vec3 centerOfMass) |
| Constructor for the rigid 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 rigid body. | |
| void | apply_torque (vec3 torque) |
| Applies a torque to the rigid body. | |
| void | update (vec3 pos, vec3 rot, vec3 scale, float delta) |
| Updates the position, rotation, and scale of a rigid body. | |
| void | load (FILE *file, Camera **c, Script *scripts, Node *editor) |
| Loads data from a file and initializes the given parameters. | |
| void | save (FILE *file) |
| Saves the current state of the RigidBody to a file. | |
| void | apply_impulse (vec3 impulse, vec3 torque, vec3 correction) |
| Applies an impulse to a rigid body. | |
| 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. | |
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 | velocity |
| vec3 | gravity |
| vec3 | angularVelocity |
| vec3 | angularAcceleration |
| vec3 | centerOfMass |
| float | mass |
| float | friction |
| u8 | length |
Public Attributes inherited from Node | |
| 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 |
Additional Inherited Members | |
Static Public Attributes inherited from Node | |
| static Shader | glowShader = 0 |
| A static Shader variable used for glow effect. | |
Represents a rigid body in the physics simulation.
A rigid body can move and is affected by forces and collisions.
|
inline |
Constructor for the rigid body class.
This function initializes a rigid body with the given parameters.
| velocity | Vec3 representing the initial velocity of the rigid body. |
| angularVelocity | Vec3 representing the initial angular velocity of the rigid body. |
| gravity | Vec3 representing the gravity affecting the rigid body. |
| mass | Float representing the mass of the rigid body. |
| friction | Float representing the friction coefficient of the rigid body. |
| centerOfMass | Vec3 representing the center of mass of the rigid body. |
Retrieves the collision shapes and their lengths.
This function populates the provided pointers with the collision shapes and their respective lengths.
| [out] | shapes | A pointer to a 4-dimensional array of Node pointers that will be populated with the collision shapes. |
| [out] | length | A pointer to an array of unsigned 8-bit integers that will be populated with the lengths of the collision shapes. |
|
inline |
Updates the global position of a rigid body.
This function updates the global position of a rigid body based on the provided position, rotation, and scale vectors.
| pos | Vec3 structure representing the position of the rigid body. |
| rot | Vec3 structure representing the rotation of the rigid body. |
| scale | Vec3 structure representing the scale of the rigid body. |
|
inline |
Applies a torque to the rigid body.
This function takes a pointer to a torque vector and applies it to the rigid body. The torque vector should be in the form of a float array representing the torque components.
| torque | Vec3 representing the torque to be applied. |
|
inline |
Updates the position, rotation, and scale of a rigid body.
This function updates the position, rotation, and scale of a rigid body based on the given delta time.
| pos | Vec3 structure representing the position of the rigid body. |
| rot | Vec3 structure representing the rotation of the rigid body. |
| scale | Vec3 structure representing the scale of the rigid body. |
| delta | The time delta used to update the rigid body's properties. |
|
inline |
Saves the current state of the RigidBody to a file.
This function writes the current state of the RigidBody instance to the specified file. The file should be opened in a mode that allows writing binary data.
| file | A pointer to a FILE object that identifies the file to which the data will be written. |
|
inline |
Applies an impulse to a rigid body.
This function applies an impulse to a rigid body, affecting its linear and angular velocity. The impulse is applied at the center of mass of the rigid body, and the torque is applied to affect the angular velocity.
| impulse | Vec3 representing the impulse to be applied. |
| torque | Vec3 representing the torque to be applied. |
| correction | Vec3 representing the correction to be applied. |
|
inline |
Get the velocity norm of a node.
|
inline |
Get the velocity of a node.
| velocity | Output vector to store the velocity. |
|
inline |
Get the mass of a node.
| mass | Output pointer to store the mass. |
|
inline |
Get the center of mass of a node.
| com | Output vector to store the center of mass. |
| struct Node** RigidBody::collisionsShapes |
Array of collision shapes associated with the rigid body.
| vec3 RigidBody::velocity |
Current velocity of the rigid body.
| vec3 RigidBody::gravity |
Gravity affecting the rigid body.
| vec3 RigidBody::angularVelocity |
Angular velocity of the rigid body.
| vec3 RigidBody::angularAcceleration |
Angular acceleration of the rigid body.
| vec3 RigidBody::centerOfMass |
Center of mass of the rigid body.
| float RigidBody::mass |
Mass of the rigid body.
| float RigidBody::friction |
Friction coefficient of the rigid body.
| u8 RigidBody::length |
Number of collision shapes.