ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
BoundaryCube Class Reference

Represents an axis-aligned bounding cube for collision detection and physics. More...

#include <BoundaryCube.h>

Collaboration diagram for BoundaryCube:

Public Member Functions

 BoundaryCube (Object3D *object)
 Constructs a BoundaryCube object based on the given 3D object.
 
 BoundaryCube (Vector3D centerPosition, Vector3D objectSize)
 Constructs a BoundaryCube object with a specified center and size.
 
Vector3D GetPosition ()
 Retrieves the current position of the cube.
 
Vector3D GetSize ()
 Retrieves the size of the cube.
 
Vector3D GetMaximum ()
 Retrieves the maximum coordinates of the cube.
 
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 IsIntersecting (BoundaryCube *bO)
 Checks for intersection with another BoundaryCube.
 
Vector3D IsIntersecting (BoundarySphere *bO)
 Checks for intersection with a BoundarySphere.
 
void CollideSphere (float elasticity, BoundarySphere *bO)
 Handles collision with a BoundarySphere.
 

Public Attributes

Vector3D velocity = Vector3D(0, 0, 0)
 Velocity of the cube.
 
Vector3D position = Vector3D(0, 0, 0)
 Current position of the cube.
 

Private Attributes

Quaternion previousRotation
 Previous rotation of the object.
 
Vector3D centerPosition
 Center position of the bounding cube.
 
Vector3D maximum
 Maximum coordinates of the bounding cube.
 
Vector3D minimum
 Minimum coordinates of the bounding cube.
 

Detailed Description

Represents an axis-aligned bounding cube for collision detection and physics.

Definition at line 24 of file BoundaryCube.h.

Constructor & Destructor Documentation

◆ BoundaryCube() [1/2]

BoundaryCube ( Object3D object)

Constructs a BoundaryCube object based on the given 3D object.

Parameters
objectPointer to an Object3D instance to initialize the boundary cube.

Definition at line 3 of file BoundaryCube.cpp.

References centerPosition, maximum, and minimum.

◆ BoundaryCube() [2/2]

BoundaryCube ( Vector3D  centerPosition,
Vector3D  objectSize 
)

Constructs a BoundaryCube object with a specified center and size.

Parameters
centerPositionCenter position of the cube.
objectSizeSize of the cube.

Definition at line 8 of file BoundaryCube.cpp.

References centerPosition, maximum, and minimum.

Member Function Documentation

◆ CollideSphere()

void CollideSphere ( float  elasticity,
BoundarySphere bO 
)

Handles collision with a BoundarySphere.

Parameters
elasticityElasticity coefficient for the collision.
bOPointer to the BoundarySphere.

Definition at line 66 of file BoundaryCube.cpp.

References Mathematics::Constrain(), BoundarySphere::GetRadius(), IsIntersecting(), maximum, minimum, BoundarySphere::position, BoundarySphere::velocity, Vector3D::X, Vector3D::Y, and Vector3D::Z.

Referenced by BoundaryMotionSimulator::Update().

◆ GetMaximum()

Vector3D GetMaximum ( )

Retrieves the maximum coordinates of the cube.

Returns
The maximum coordinates as a Vector3D.

Definition at line 22 of file BoundaryCube.cpp.

References maximum.

Referenced by IsIntersecting().

◆ GetMinimum()

Vector3D GetMinimum ( )

Retrieves the minimum coordinates of the cube.

Returns
The minimum coordinates as a Vector3D.

Definition at line 26 of file BoundaryCube.cpp.

References minimum.

Referenced by IsIntersecting().

◆ GetPosition()

Vector3D GetPosition ( )

Retrieves the current position of the cube.

Returns
The current position as a Vector3D.

Definition at line 14 of file BoundaryCube.cpp.

References centerPosition.

◆ GetSize()

Vector3D GetSize ( )

Retrieves the size of the cube.

Returns
The size as a Vector3D.

Definition at line 18 of file BoundaryCube.cpp.

References maximum, and minimum.

◆ IsIntersecting() [1/2]

Vector3D IsIntersecting ( BoundaryCube bO)

Checks for intersection with another BoundaryCube.

Parameters
bOPointer to the other BoundaryCube.
Returns
The intersection vector if intersecting, otherwise zero vector.

Definition at line 38 of file BoundaryCube.cpp.

References GetMaximum(), GetMinimum(), maximum, minimum, Vector3D::X, Vector3D::Y, and Vector3D::Z.

Referenced by CollideSphere().

◆ IsIntersecting() [2/2]

Vector3D IsIntersecting ( BoundarySphere bO)

Checks for intersection with a BoundarySphere.

Parameters
bOPointer to the BoundarySphere.
Returns
The intersection vector if intersecting, otherwise zero vector.

Definition at line 51 of file BoundaryCube.cpp.

References BoundarySphere::GetRadius(), maximum, minimum, BoundarySphere::position, Vector3D::X, Vector3D::Y, and Vector3D::Z.

◆ Update()

void Update ( float  dT,
Vector3D  acceleration,
Quaternion  rotation 
)

Updates the cube's state based on time, acceleration, and rotation.

Parameters
dTTime step in seconds.
accelerationAcceleration vector applied to the cube.
rotationRotation quaternion applied to the cube.

Definition at line 30 of file BoundaryCube.cpp.

References Quaternion::MultiplicativeInverse(), Quaternion::Multiply(), position, previousRotation, Quaternion::RotateVector(), and velocity.

Member Data Documentation

◆ centerPosition

Vector3D centerPosition
private

Center position of the bounding cube.

Definition at line 27 of file BoundaryCube.h.

Referenced by BoundaryCube(), BoundaryCube(), and GetPosition().

◆ maximum

Vector3D maximum
private

Maximum coordinates of the bounding cube.

Definition at line 28 of file BoundaryCube.h.

Referenced by BoundaryCube(), BoundaryCube(), CollideSphere(), GetMaximum(), GetSize(), IsIntersecting(), and IsIntersecting().

◆ minimum

Vector3D minimum
private

Minimum coordinates of the bounding cube.

Definition at line 29 of file BoundaryCube.h.

Referenced by BoundaryCube(), BoundaryCube(), CollideSphere(), GetMinimum(), GetSize(), IsIntersecting(), and IsIntersecting().

◆ position

Vector3D position = Vector3D(0, 0, 0)

Current position of the cube.

Definition at line 33 of file BoundaryCube.h.

Referenced by Update().

◆ previousRotation

Quaternion previousRotation
private

Previous rotation of the object.

Definition at line 26 of file BoundaryCube.h.

Referenced by Update().

◆ velocity

Vector3D velocity = Vector3D(0, 0, 0)

Velocity of the cube.

Definition at line 32 of file BoundaryCube.h.

Referenced by Update().


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