The small3d library
Classes | Public Member Functions | Public Attributes | List of all members
small3d::BoundingBoxSet Class Reference

Set of bounding boxes for a SceneObject, calculated based on the vertices of a Model. More...

#include <BoundingBoxSet.hpp>

Classes

struct  extremes
 Structure to hold the coordinates of the extremes of each box.
 

Public Member Functions

int getNumBoxes () const
 Get the number of boxes contained in the set.
 
 BoundingBoxSet ()
 Default constructor.
 
 BoundingBoxSet (const std::vector< float > &vertexData, const Vec3 &scale, uint32_t subdivisions)
 Constructor that creates a box set, constructed based on the vertex data that can be found in a Model. More...
 
 ~BoundingBoxSet ()=default
 Destructor.
 
bool contains (const Vec3 point, const Vec3 thisOffset, const Mat4 thisRotation) const
 Check if a point is inside any of the boxes. More...
 
bool containsCorners (const BoundingBoxSet &otherBoxSet, const Vec3 thisOffset, const Mat4 thisRotation, const Vec3 otherOffset, const Mat4 otherRotation) const
 Check any of the corners of another set of bounding boxes is inside any of the boxes of this set. More...
 
std::vector< ModelgetModels ()
 Get the bounding boxes in a set of Models that can be rendered. More...
 

Public Attributes

std::vector< extremes > boxExtremes
 The extreme coordinates (max and min) of each box.
 
std::vector< std::vector< float > > vertices
 Vertex coordinates.
 
std::vector< std::vector< unsigned int > > facesVertexIndexes
 Faces vertex indexes (rectangles)
 
std::vector< std::vector< unsigned int > > facesVertexIndexesTriangulated
 Faces vertex indexes (triangles, for rendering)
 

Detailed Description

Set of bounding boxes for a SceneObject, calculated based on the vertices of a Model.

Constructor & Destructor Documentation

◆ BoundingBoxSet()

small3d::BoundingBoxSet::BoundingBoxSet ( const std::vector< float > &  vertexData,
const Vec3 scale,
uint32_t  subdivisions 
)

Constructor that creates a box set, constructed based on the vertex data that can be found in a Model.

Parameters
vertexDataThe vertex data. Array of floats to be interpreted as an array of 4 component vertex coordinates.
scaleScale applied to the vertexData before calculating boxes.
subdivisionsHow many times to subdivide the initially one created bounding box, getting more accurate collision detection at the expense of performance.

Member Function Documentation

◆ contains()

bool small3d::BoundingBoxSet::contains ( const Vec3  point,
const Vec3  thisOffset,
const Mat4  thisRotation 
) const

Check if a point is inside any of the boxes.

Parameters
pointThe point (as a vector)
thisOffsetThe offset (location) of the box set
thisRotationThe rotation transformation of the box set
Returns
True the point is inside a box, False if not.

◆ containsCorners()

bool small3d::BoundingBoxSet::containsCorners ( const BoundingBoxSet otherBoxSet,
const Vec3  thisOffset,
const Mat4  thisRotation,
const Vec3  otherOffset,
const Mat4  otherRotation 
) const

Check any of the corners of another set of bounding boxes is inside any of the boxes of this set.

Parameters
otherBoxSetThe other box set
thisOffsetThe offset (location) of this box set
thisRotationThe rotation transformation of this box set
otherOffsetThe offset (location) of the other box set
otherRotationThe rotation transformation of the other box set
Returns
True if a corner of the other bounding box set is contained in this set, False otherwise.

◆ getModels()

std::vector< Model > small3d::BoundingBoxSet::getModels ( )

Get the bounding boxes in a set of Models that can be rendered.

Returns
The set of bounding boxes as Models

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