![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
Represents a spherical boundary object for motion and collision simulations. More...
#include <BoundarySphere.h>
Public Member Functions | |
BoundarySphere (Object3D *object, float radius) | |
Constructs a BoundarySphere with a given object and radius. | |
BoundarySphere (Object3D *object, Vector3D position, float radius) | |
Constructs a BoundarySphere with a given object, position, and radius. | |
float | GetRadius () |
Gets the radius of the sphere. | |
Object3D * | GetObject3D () |
Gets the associated Object3D of the sphere. | |
void | Update (float dT, Vector3D acceleration, Quaternion rotation) |
Updates the sphere's position and velocity based on acceleration and rotation. | |
bool | IsIntersecting (BoundarySphere *bO) |
Checks if the sphere intersects with another BoundarySphere. | |
void | Collide (float elasticity, BoundarySphere *bO) |
Resolves collision between this sphere and another BoundarySphere. | |
Public Attributes | |
Vector3D | velocity = Vector3D(0, 0, 0) |
Velocity vector of the sphere. | |
Vector3D | position = Vector3D(0, 0, 0) |
Current position of the sphere. | |
Private Attributes | |
Object3D * | object |
Pointer to the 3D object associated with the sphere. | |
Vector3D | centerPosition |
Center position of the sphere. | |
Quaternion | previousRotation |
Previous rotation of the sphere. | |
float | radius = 1.0f |
Radius of the sphere. | |
Represents a spherical boundary object for motion and collision simulations.
Definition at line 23 of file BoundarySphere.h.
BoundarySphere | ( | Object3D * | object, |
float | radius | ||
) |
Constructs a BoundarySphere with a given object and radius.
object | Pointer to the Object3D associated with the sphere. |
radius | Radius of the sphere. |
Definition at line 3 of file BoundarySphere.cpp.
BoundarySphere | ( | Object3D * | object, |
Vector3D | position, | ||
float | radius | ||
) |
Constructs a BoundarySphere with a given object, position, and radius.
object | Pointer to the Object3D associated with the sphere. |
position | Initial position of the sphere. |
radius | Radius of the sphere. |
Definition at line 9 of file BoundarySphere.cpp.
void Collide | ( | float | elasticity, |
BoundarySphere * | bO | ||
) |
Resolves collision between this sphere and another BoundarySphere.
elasticity | Elasticity coefficient for the collision. |
bO | Pointer to the other BoundarySphere. |
Definition at line 36 of file BoundarySphere.cpp.
References Vector3D::DotProduct(), IsIntersecting(), position, and velocity.
Referenced by BoundaryMotionSimulator::Update().
Object3D * GetObject3D | ( | ) |
Gets the associated Object3D of the sphere.
Definition at line 19 of file BoundarySphere.cpp.
References object.
Referenced by BoundaryMotionSimulator::Update().
float GetRadius | ( | ) |
Gets the radius of the sphere.
Definition at line 15 of file BoundarySphere.cpp.
References radius.
Referenced by BoundaryCube::CollideSphere(), BoundaryCube::IsIntersecting(), and IsIntersecting().
bool IsIntersecting | ( | BoundarySphere * | bO | ) |
Checks if the sphere intersects with another BoundarySphere.
bO | Pointer to the other BoundarySphere. |
Definition at line 32 of file BoundarySphere.cpp.
References GetRadius(), position, and radius.
Referenced by Collide().
void Update | ( | float | dT, |
Vector3D | acceleration, | ||
Quaternion | rotation | ||
) |
Updates the sphere's position and velocity based on acceleration and rotation.
dT | Time step in seconds. |
acceleration | Acceleration vector applied to the sphere. |
rotation | Rotation quaternion applied to the sphere. |
Definition at line 23 of file BoundarySphere.cpp.
References Vector3D::Constrain(), Quaternion::MultiplicativeInverse(), Quaternion::Multiply(), position, previousRotation, Quaternion::RotateVector(), and velocity.
Referenced by BoundaryMotionSimulator::Update().
|
private |
Center position of the sphere.
Definition at line 26 of file BoundarySphere.h.
|
private |
Pointer to the 3D object associated with the sphere.
Definition at line 25 of file BoundarySphere.h.
Referenced by BoundarySphere(), BoundarySphere(), and GetObject3D().
Current position of the sphere.
Definition at line 32 of file BoundarySphere.h.
Referenced by BoundarySphere(), BoundarySphere(), Collide(), BoundaryCube::CollideSphere(), BoundaryCube::IsIntersecting(), IsIntersecting(), and Update().
|
private |
Previous rotation of the sphere.
Definition at line 27 of file BoundarySphere.h.
Referenced by Update().
|
private |
Radius of the sphere.
Definition at line 28 of file BoundarySphere.h.
Referenced by BoundarySphere(), BoundarySphere(), GetRadius(), and IsIntersecting().
Velocity vector of the sphere.
Definition at line 31 of file BoundarySphere.h.
Referenced by Collide(), BoundaryCube::CollideSphere(), BoundaryMotionSimulator::Randomize(), BoundaryMotionSimulator::Update(), and Update().