SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
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.
Definition at line 33 of file SLAABBox.h.
SLAABBox::SLAABBox | ( | ) |
Default constructor with default zero vector initialization.
Definition at line 17 of file SLAABBox.cpp.
void SLAABBox::calculateRectSS | ( | ) |
Calculates the AABBs min. and max. corners in screen space.
Definition at line 400 of file SLAABBox.cpp.
|
inline |
Definition at line 54 of file SLAABBox.h.
|
inline |
Definition at line 50 of file SLAABBox.h.
void SLAABBox::drawAxisWS | ( | ) |
Draws the axis in world space with lines in a color.
Definition at line 271 of file SLAABBox.cpp.
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.
Definition at line 296 of file SLAABBox.cpp.
Recalculate min and max after transformation in world coords.
Definition at line 46 of file SLAABBox.cpp.
Recalculate min and max before transformation in object coords.
Definition at line 96 of file SLAABBox.cpp.
void SLAABBox::generateVAO | ( | ) |
Generates the vertex buffer for the line visualization.
Definition at line 212 of file SLAABBox.cpp.
SLAABBox::isHitInWS: Ray - AABB Intersection Test in object space.
Definition at line 331 of file SLAABBox.cpp.
SLAABBox::isHitInWS: Ray - AABB Intersection Test in world space.
Definition at line 361 of file SLAABBox.cpp.
|
inline |
Definition at line 56 of file SLAABBox.h.
Definition at line 44 of file SLAABBox.h.
|
inline |
Definition at line 53 of file SLAABBox.h.
Definition at line 42 of file SLAABBox.h.
|
inline |
Definition at line 49 of file SLAABBox.h.
Definition at line 40 of file SLAABBox.h.
Merges the bounding box bb to this one by extending this one axis aligned.
Definition at line 390 of file SLAABBox.cpp.
|
inline |
Definition at line 52 of file SLAABBox.h.
Definition at line 41 of file SLAABBox.h.
|
inline |
Definition at line 48 of file SLAABBox.h.
Definition at line 39 of file SLAABBox.h.
|
inline |
Definition at line 55 of file SLAABBox.h.
|
inline |
Definition at line 51 of file SLAABBox.h.
SLfloat SLAABBox::rectCoverageInSS | ( | ) |
Calculates the bounding rectangle in screen space and returns coverage in SS.
Definition at line 446 of file SLAABBox.cpp.
|
inline |
Definition at line 58 of file SLAABBox.h.
void SLAABBox::reset | ( | ) |
Resets initial state without contents.
Definition at line 23 of file SLAABBox.cpp.
void SLAABBox::setCenterAndRadiusWS | ( | ) |
|
inline |
Definition at line 57 of file SLAABBox.h.
Definition at line 45 of file SLAABBox.h.
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.
Definition at line 162 of file SLAABBox.cpp.
|
private |
World space axis center point.
Definition at line 93 of file SLAABBox.h.
|
private |
World space x-axis vector.
Definition at line 94 of file SLAABBox.h.
|
private |
World space y-axis vector.
Definition at line 95 of file SLAABBox.h.
|
private |
World space z-axis vector.
Definition at line 96 of file SLAABBox.h.
|
private |
Flag if the connection parent to us is a bone or an offset.
Definition at line 97 of file SLAABBox.h.
|
private |
Center of AABB in object space.
Definition at line 89 of file SLAABBox.h.
|
private |
Center of AABB in world space.
Definition at line 88 of file SLAABBox.h.
|
private |
Flag if AABB is in the view frustum.
Definition at line 99 of file SLAABBox.h.
|
private |
Max. corner in object space.
Definition at line 87 of file SLAABBox.h.
|
private |
Max. corner in world space.
Definition at line 86 of file SLAABBox.h.
|
private |
Min. corner in object space.
Definition at line 85 of file SLAABBox.h.
|
private |
Min. corner in world space.
Definition at line 84 of file SLAABBox.h.
|
private |
World space vector to the parent position.
Definition at line 98 of file SLAABBox.h.
|
private |
Radius of sphere around AABB in OS.
Definition at line 91 of file SLAABBox.h.
|
private |
Radius of sphere around AABB in WS.
Definition at line 90 of file SLAABBox.h.
|
private |
Bounding rectangle in screen space.
Definition at line 100 of file SLAABBox.h.
|
private |
Squared dist. from center to viewpoint.
Definition at line 92 of file SLAABBox.h.
|
private |
Vertex array object for rendering.
Definition at line 101 of file SLAABBox.h.