ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
BoundaryCube.h
Go to the documentation of this file.
1/**
2 * @file BoundaryCube.h
3 * @brief Defines the BoundaryCube class for representing and managing axis-aligned bounding cubes.
4 *
5 * The BoundaryCube class provides functionality for collision detection and physics calculations
6 * for axis-aligned bounding cubes, including interactions with BoundarySphere objects.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "../../Utils/Math/Rotation.h"
16#include "../../Utils/Math/Vector3D.h"
17#include "../../Scene/Objects/Object3D.h"
18#include "BoundarySphere.h"
19
20/**
21 * @class BoundaryCube
22 * @brief Represents an axis-aligned bounding cube for collision detection and physics.
23 */
25private:
26 Quaternion previousRotation; ///< Previous rotation of the object.
27 Vector3D centerPosition; ///< Center position of the bounding cube.
28 Vector3D maximum; ///< Maximum coordinates of the bounding cube.
29 Vector3D minimum; ///< Minimum coordinates of the bounding cube.
30
31public:
32 Vector3D velocity = Vector3D(0, 0, 0); ///< Velocity of the cube.
33 Vector3D position = Vector3D(0, 0, 0); ///< Current position of the cube.
34
35 /**
36 * @brief Constructs a BoundaryCube object based on the given 3D object.
37 * @param object Pointer to an Object3D instance to initialize the boundary cube.
38 */
39 BoundaryCube(Object3D* object);
40
41 /**
42 * @brief Constructs a BoundaryCube object with a specified center and size.
43 * @param centerPosition Center position of the cube.
44 * @param objectSize Size of the cube.
45 */
47
48 /**
49 * @brief Retrieves the current position of the cube.
50 * @return The current position as a Vector3D.
51 */
53
54 /**
55 * @brief Retrieves the size of the cube.
56 * @return The size as a Vector3D.
57 */
59
60 /**
61 * @brief Retrieves the maximum coordinates of the cube.
62 * @return The maximum coordinates as a Vector3D.
63 */
65
66 /**
67 * @brief Retrieves the minimum coordinates of the cube.
68 * @return The minimum coordinates as a Vector3D.
69 */
71
72 /**
73 * @brief Updates the cube's state based on time, acceleration, and rotation.
74 * @param dT Time step in seconds.
75 * @param acceleration Acceleration vector applied to the cube.
76 * @param rotation Rotation quaternion applied to the cube.
77 */
78 void Update(float dT, Vector3D acceleration, Quaternion rotation);
79
80 /**
81 * @brief Checks for intersection with another BoundaryCube.
82 * @param bO Pointer to the other BoundaryCube.
83 * @return The intersection vector if intersecting, otherwise zero vector.
84 */
86
87 /**
88 * @brief Checks for intersection with a BoundarySphere.
89 * @param bO Pointer to the BoundarySphere.
90 * @return The intersection vector if intersecting, otherwise zero vector.
91 */
93
94 /**
95 * @brief Handles collision with a BoundarySphere.
96 * @param elasticity Elasticity coefficient for the collision.
97 * @param bO Pointer to the BoundarySphere.
98 */
99 void CollideSphere(float elasticity, BoundarySphere* bO);
100};
Defines the BoundarySphere class for simulating spherical boundary objects.
Represents an axis-aligned bounding cube for collision detection and physics.
Vector3D GetMinimum()
Retrieves the minimum coordinates of the cube.
void Update(float dT, Vector3D acceleration, Quaternion rotation)
Updates the cube's state based on time, acceleration, and rotation.
Vector3D velocity
Velocity of the cube.
void CollideSphere(float elasticity, BoundarySphere *bO)
Handles collision with a BoundarySphere.
Vector3D GetSize()
Retrieves the size of the cube.
Vector3D position
Current position of the cube.
Vector3D GetMaximum()
Retrieves the maximum coordinates of the cube.
Vector3D centerPosition
Center position of the bounding cube.
Vector3D GetPosition()
Retrieves the current position of the cube.
Vector3D IsIntersecting(BoundaryCube *bO)
Checks for intersection with another BoundaryCube.
Vector3D minimum
Minimum coordinates of the bounding cube.
Vector3D maximum
Maximum coordinates of the bounding cube.
Quaternion previousRotation
Previous rotation of the object.
Represents a spherical boundary object for motion and collision simulations.
Represents a 3D object with geometry, material, and transformation data.
Definition Object3D.h:28
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26