SLProject 4.0.000
SLAABBox Class Reference

Defines an axis aligned bounding box. More...

#include <SLAABBox.h>

Public Member Functions

 SLAABBox ()
 Default constructor with default zero vector initialization. More...
 
void minWS (const SLVec3f &minC)
 
void maxWS (const SLVec3f &maxC)
 
void minOS (const SLVec3f &minC)
 
void maxOS (const SLVec3f &maxC)
 
void isVisible (SLbool visible)
 
void sqrViewDist (SLfloat sqrVD)
 
SLVec3f minWS ()
 
SLVec3f maxWS ()
 
SLVec3f centerWS ()
 
SLfloat radiusWS ()
 
SLVec3f minOS ()
 
SLVec3f maxOS ()
 
SLVec3f centerOS ()
 
SLfloat radiusOS ()
 
SLbool isVisible ()
 
SLfloat sqrViewDist ()
 
SLRectfrectSS ()
 
void reset ()
 Resets initial state without contents. More...
 
void fromOStoWS (const SLVec3f &minOS, const SLVec3f &maxOS, const SLMat4f &wm)
 Recalculate min and max after transformation in world coords. More...
 
void fromWStoOS (const SLVec3f &minWS, const SLVec3f &maxWS, const SLMat4f &wmI)
 Recalculate min and max before transformation in object coords. More...
 
void updateAxisWS (const SLMat4f &wm)
 Updates the axis of the owning node. More...
 
void updateBoneWS (const SLMat4f &parentWM, SLbool isRoot, const SLMat4f &nodeWM)
 Updates joints axis and the bone line from the parent to us. More...
 
void mergeWS (SLAABBox &bb)
 Merges the bounding box bb to this one by extending this one axis aligned. More...
 
void drawWS (const SLCol4f &color)
 Draws the AABB in world space with lines in a color. More...
 
void drawAxisWS ()
 Draws the axis in world space with lines in a color. More...
 
void drawBoneWS ()
 Draws the joint axis and the parent bone in world space. More...
 
void setCenterAndRadiusWS ()
 Calculates center & radius of the bounding sphere around the AABB. More...
 
void generateVAO ()
 Generates the vertex buffer for the line visualization. More...
 
SLbool isHitInOS (SLRay *ray)
 SLAABBox::isHitInWS: Ray - AABB Intersection Test in object space. More...
 
SLbool isHitInWS (SLRay *ray)
 SLAABBox::isHitInWS: Ray - AABB Intersection Test in world space. More...
 
void calculateRectSS ()
 Calculates the AABBs min. and max. corners in screen space. More...
 
SLfloat rectCoverageInSS ()
 Calculates the bounding rectangle in screen space and returns coverage in SS. More...
 

Private Attributes

SLVec3f _minWS
 Min. corner in world space. More...
 
SLVec3f _minOS
 Min. corner in object space. More...
 
SLVec3f _maxWS
 Max. corner in world space. More...
 
SLVec3f _maxOS
 Max. corner in object space. More...
 
SLVec3f _centerWS
 Center of AABB in world space. More...
 
SLVec3f _centerOS
 Center of AABB in object space. More...
 
SLfloat _radiusWS
 Radius of sphere around AABB in WS. More...
 
SLfloat _radiusOS
 Radius of sphere around AABB in OS. More...
 
SLfloat _sqrViewDist
 Squared dist. from center to viewpoint. More...
 
SLVec3f _axis0WS
 World space axis center point. More...
 
SLVec3f _axisXWS
 World space x-axis vector. More...
 
SLVec3f _axisYWS
 World space y-axis vector. More...
 
SLVec3f _axisZWS
 World space z-axis vector. More...
 
SLbool _boneIsOffset
 Flag if the connection parent to us is a bone or an offset. More...
 
SLVec3f _parent0WS
 World space vector to the parent position. More...
 
SLbool _isVisible
 Flag if AABB is in the view frustum. More...
 
SLRectf _rectSS
 Bounding rectangle in screen space. More...
 
SLGLVertexArrayExt _vao
 Vertex array object for rendering. More...
 

Detailed Description

Defines an axis aligned bounding box.

The SLAABBox class defines an axis aligned bounding box with a minimal and maximal point. Each node (SLNode) will have an AABB the will be calculated in buildAABB. A mesh (SLMesh) will implement buildAABB and calculate the minimal and maximal coordinates in object space (stored in _minOS and _maxOS). For a fast ray-AABB intersection in world space we transform _minOS and _maxOS into world space (with the shapes world matrix) and store it in _minWS and _maxWS. For an even faster intersection test with the plane of the view frustum we calculate in addition the bounding sphere around the AABB. The radius and the center point are stored in _radiusOS/_centerOS and _radiusWS/_centerWS.

Constructor & Destructor Documentation

◆ SLAABBox()

SLAABBox::SLAABBox ( )

Default constructor with default zero vector initialization.

Member Function Documentation

◆ calculateRectSS()

void SLAABBox::calculateRectSS ( )

Calculates the AABBs min. and max. corners in screen space.

◆ centerOS()

SLVec3f SLAABBox::centerOS ( )
inline

◆ centerWS()

SLVec3f SLAABBox::centerWS ( )
inline

◆ drawAxisWS()

void SLAABBox::drawAxisWS ( )

Draws the axis in world space with lines in a color.

◆ drawBoneWS()

void SLAABBox::drawBoneWS ( )

Draws the joint axis and the parent bone in world space.

The joints x-axis is drawn in red, the y-axis in green and the z-axis in blue. If the parent displacement is a bone it is drawn in yellow, if it is a an offset displacement in magenta. See also SLAABBox::updateBoneWS.

◆ drawWS()

void SLAABBox::drawWS ( const SLCol4f color)

Draws the AABB in world space with lines in a color.

◆ fromOStoWS()

void SLAABBox::fromOStoWS ( const SLVec3f minOS,
const SLVec3f maxOS,
const SLMat4f wm 
)

Recalculate min and max after transformation in world coords.

◆ fromWStoOS()

void SLAABBox::fromWStoOS ( const SLVec3f minWS,
const SLVec3f maxWS,
const SLMat4f wmI 
)

Recalculate min and max before transformation in object coords.

◆ generateVAO()

void SLAABBox::generateVAO ( )

Generates the vertex buffer for the line visualization.

◆ isHitInOS()

SLbool SLAABBox::isHitInOS ( SLRay ray)

SLAABBox::isHitInWS: Ray - AABB Intersection Test in object space.

◆ isHitInWS()

SLbool SLAABBox::isHitInWS ( SLRay ray)

SLAABBox::isHitInWS: Ray - AABB Intersection Test in world space.

◆ isVisible() [1/2]

SLbool SLAABBox::isVisible ( )
inline

◆ isVisible() [2/2]

void SLAABBox::isVisible ( SLbool  visible)
inline

◆ maxOS() [1/2]

SLVec3f SLAABBox::maxOS ( )
inline

◆ maxOS() [2/2]

void SLAABBox::maxOS ( const SLVec3f maxC)
inline

◆ maxWS() [1/2]

SLVec3f SLAABBox::maxWS ( )
inline

◆ maxWS() [2/2]

void SLAABBox::maxWS ( const SLVec3f maxC)
inline

◆ mergeWS()

void SLAABBox::mergeWS ( SLAABBox bb)

Merges the bounding box bb to this one by extending this one axis aligned.

◆ minOS() [1/2]

SLVec3f SLAABBox::minOS ( )
inline

◆ minOS() [2/2]

void SLAABBox::minOS ( const SLVec3f minC)
inline

◆ minWS() [1/2]

SLVec3f SLAABBox::minWS ( )
inline

◆ minWS() [2/2]

void SLAABBox::minWS ( const SLVec3f minC)
inline

◆ radiusOS()

SLfloat SLAABBox::radiusOS ( )
inline

◆ radiusWS()

SLfloat SLAABBox::radiusWS ( )
inline

◆ rectCoverageInSS()

SLfloat SLAABBox::rectCoverageInSS ( )

Calculates the bounding rectangle in screen space and returns coverage in SS.

◆ rectSS()

SLRectf & SLAABBox::rectSS ( )
inline

◆ reset()

void SLAABBox::reset ( )

Resets initial state without contents.

◆ setCenterAndRadiusWS()

void SLAABBox::setCenterAndRadiusWS ( )

Calculates center & radius of the bounding sphere around the AABB.

◆ sqrViewDist() [1/2]

SLfloat SLAABBox::sqrViewDist ( )
inline

◆ sqrViewDist() [2/2]

void SLAABBox::sqrViewDist ( SLfloat  sqrVD)
inline

◆ updateAxisWS()

void SLAABBox::updateAxisWS ( const SLMat4f wm)

Updates the axis of the owning node.

◆ updateBoneWS()

void SLAABBox::updateBoneWS ( const SLMat4f parentWM,
SLbool  isRoot,
const SLMat4f nodeWM 
)

Updates joints axis and the bone line from the parent to us.

If the node has a skeleton assigned the method updates the axis and bone visualization lines of the joint. Note that joints bone line is drawn by its children. So the bone line in here is the bone from the parent to us. If this parent bone direction is not along the parents Y axis we interpret the connection not as a bone but as an offset displacement. Bones will be drawn in SLAABBox::drawBoneWS in yellow and displacements in magenta. If the joint has no parent (the root) no line is drawn.

Member Data Documentation

◆ _axis0WS

SLVec3f SLAABBox::_axis0WS
private

World space axis center point.

◆ _axisXWS

SLVec3f SLAABBox::_axisXWS
private

World space x-axis vector.

◆ _axisYWS

SLVec3f SLAABBox::_axisYWS
private

World space y-axis vector.

◆ _axisZWS

SLVec3f SLAABBox::_axisZWS
private

World space z-axis vector.

◆ _boneIsOffset

SLbool SLAABBox::_boneIsOffset
private

Flag if the connection parent to us is a bone or an offset.

◆ _centerOS

SLVec3f SLAABBox::_centerOS
private

Center of AABB in object space.

◆ _centerWS

SLVec3f SLAABBox::_centerWS
private

Center of AABB in world space.

◆ _isVisible

SLbool SLAABBox::_isVisible
private

Flag if AABB is in the view frustum.

◆ _maxOS

SLVec3f SLAABBox::_maxOS
private

Max. corner in object space.

◆ _maxWS

SLVec3f SLAABBox::_maxWS
private

Max. corner in world space.

◆ _minOS

SLVec3f SLAABBox::_minOS
private

Min. corner in object space.

◆ _minWS

SLVec3f SLAABBox::_minWS
private

Min. corner in world space.

◆ _parent0WS

SLVec3f SLAABBox::_parent0WS
private

World space vector to the parent position.

◆ _radiusOS

SLfloat SLAABBox::_radiusOS
private

Radius of sphere around AABB in OS.

◆ _radiusWS

SLfloat SLAABBox::_radiusWS
private

Radius of sphere around AABB in WS.

◆ _rectSS

SLRectf SLAABBox::_rectSS
private

Bounding rectangle in screen space.

◆ _sqrViewDist

SLfloat SLAABBox::_sqrViewDist
private

Squared dist. from center to viewpoint.

◆ _vao

SLGLVertexArrayExt SLAABBox::_vao
private

Vertex array object for rendering.


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