SLProject 4.0.000
|
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 () |
SLRectf & | rectSS () |
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... | |
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.
SLAABBox::SLAABBox | ( | ) |
Default constructor with default zero vector initialization.
void SLAABBox::calculateRectSS | ( | ) |
Calculates the AABBs min. and max. corners in screen space.
|
inline |
|
inline |
void SLAABBox::drawAxisWS | ( | ) |
Draws the axis in world space with lines in a color.
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.
void SLAABBox::drawWS | ( | const SLCol4f & | color | ) |
Draws the AABB in world space with lines in a color.
Recalculate min and max after transformation in world coords.
Recalculate min and max before transformation in object coords.
void SLAABBox::generateVAO | ( | ) |
Generates the vertex buffer for the line visualization.
SLAABBox::isHitInWS: Ray - AABB Intersection Test in object space.
SLAABBox::isHitInWS: Ray - AABB Intersection Test in world space.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void SLAABBox::mergeWS | ( | SLAABBox & | bb | ) |
Merges the bounding box bb to this one by extending this one axis aligned.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
SLfloat SLAABBox::rectCoverageInSS | ( | ) |
Calculates the bounding rectangle in screen space and returns coverage in SS.
|
inline |
void SLAABBox::reset | ( | ) |
Resets initial state without contents.
void SLAABBox::setCenterAndRadiusWS | ( | ) |
Calculates center & radius of the bounding sphere around the AABB.
|
inline |
|
inline |
void SLAABBox::updateAxisWS | ( | const SLMat4f & | wm | ) |
Updates the axis of the owning node.
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.
|
private |
World space axis center point.
|
private |
World space x-axis vector.
|
private |
World space y-axis vector.
|
private |
World space z-axis vector.
|
private |
Flag if the connection parent to us is a bone or an offset.
|
private |
Center of AABB in object space.
|
private |
Center of AABB in world space.
|
private |
Flag if AABB is in the view frustum.
|
private |
Max. corner in object space.
|
private |
Max. corner in world space.
|
private |
Min. corner in object space.
|
private |
Min. corner in world space.
|
private |
World space vector to the parent position.
|
private |
Radius of sphere around AABB in OS.
|
private |
Radius of sphere around AABB in WS.
|
private |
Bounding rectangle in screen space.
|
private |
Squared dist. from center to viewpoint.
|
private |
Vertex array object for rendering.