ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
BoundarySphere.h
Go to the documentation of this file.
1/**
2 * @file BoundarySphere.h
3 * @brief Defines the BoundarySphere class for simulating spherical boundary objects.
4 *
5 * The BoundarySphere class provides functionality to represent a 3D sphere's position, velocity,
6 * and radius, along with methods to handle motion, detect intersections, and resolve collisions.
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
19/**
20 * @class BoundarySphere
21 * @brief Represents a spherical boundary object for motion and collision simulations.
22 */
24private:
25 Object3D* object; ///< Pointer to the 3D object associated with the sphere.
26 Vector3D centerPosition; ///< Center position of the sphere.
27 Quaternion previousRotation; ///< Previous rotation of the sphere.
28 float radius = 1.0f; ///< Radius of the sphere.
29
30public:
31 Vector3D velocity = Vector3D(0, 0, 0); ///< Velocity vector of the sphere.
32 Vector3D position = Vector3D(0, 0, 0); ///< Current position of the sphere.
33
34 /**
35 * @brief Constructs a BoundarySphere with a given object and radius.
36 * @param object Pointer to the Object3D associated with the sphere.
37 * @param radius Radius of the sphere.
38 */
39 BoundarySphere(Object3D* object, float radius);
40
41 /**
42 * @brief Constructs a BoundarySphere with a given object, position, and radius.
43 * @param object Pointer to the Object3D associated with the sphere.
44 * @param position Initial position of the sphere.
45 * @param radius Radius of the sphere.
46 */
48
49 /**
50 * @brief Gets the radius of the sphere.
51 * @return Radius of the sphere.
52 */
53 float GetRadius();
54
55 /**
56 * @brief Gets the associated Object3D of the sphere.
57 * @return Pointer to the Object3D.
58 */
60
61 /**
62 * @brief Updates the sphere's position and velocity based on acceleration and rotation.
63 * @param dT Time step in seconds.
64 * @param acceleration Acceleration vector applied to the sphere.
65 * @param rotation Rotation quaternion applied to the sphere.
66 */
67 void Update(float dT, Vector3D acceleration, Quaternion rotation);
68
69 /**
70 * @brief Checks if the sphere intersects with another BoundarySphere.
71 * @param bO Pointer to the other BoundarySphere.
72 * @return True if the spheres intersect, false otherwise.
73 */
75
76 /**
77 * @brief Resolves collision between this sphere and another BoundarySphere.
78 * @param elasticity Elasticity coefficient for the collision.
79 * @param bO Pointer to the other BoundarySphere.
80 */
81 void Collide(float elasticity, BoundarySphere* bO);
82};
Represents a spherical boundary object for motion and collision simulations.
void Update(float dT, Vector3D acceleration, Quaternion rotation)
Updates the sphere's position and velocity based on acceleration and rotation.
Object3D * object
Pointer to the 3D object associated with the sphere.
Vector3D velocity
Velocity vector of the sphere.
float radius
Radius of the sphere.
bool IsIntersecting(BoundarySphere *bO)
Checks if the sphere intersects with another BoundarySphere.
Vector3D position
Current position of the sphere.
float GetRadius()
Gets the radius of the sphere.
Vector3D centerPosition
Center position of the sphere.
void Collide(float elasticity, BoundarySphere *bO)
Resolves collision between this sphere and another BoundarySphere.
Object3D * GetObject3D()
Gets the associated Object3D of the sphere.
Quaternion previousRotation
Previous rotation of the sphere.
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