73 for (i = 0; i < 8; ++i)
74 vCorner[i] = wm.
multVec(vCorner[i]);
79 for (i = 1; i < 8; ++i)
119 for (i = 0; i < 8; ++i)
120 vCorner[i] = wmI.
multVec(vCorner[i]);
125 for (i = 1; i < 8; ++i)
170 SLfloat axisScaleFactor = 0.03f;
179 axisScaleFactor = std::max(parentToMe.
length() / 10.0f, axisScaleFactor);
339 SLfloat tymin, tymax, tzmin, tzmax;
346 if ((ray->
tmin > tymax) || (tymin > ray->
tmax))
return false;
347 if (tymin > ray->
tmin) ray->
tmin = tymin;
348 if (tymax < ray->tmax) ray->
tmax = tymax;
353 if ((ray->
tmin > tzmax) || (tzmin > ray->
tmax))
return false;
354 if (tzmin > ray->
tmin) ray->
tmin = tzmin;
355 if (tzmax < ray->tmax) ray->
tmax = tzmax;
368 SLfloat tymin, tymax, tzmin, tzmax;
375 if ((ray->
tmin > tymax) || (tymin > ray->
tmax))
return false;
376 if (tymin > ray->
tmin) ray->
tmin = tymin;
377 if (tymax < ray->tmax) ray->
tmax = tymax;
382 if ((ray->
tmin > tzmax) || (tzmin > ray->
tmax))
return false;
383 if (tzmin > ray->
tmin) ray->
tmin = tzmin;
384 if (tzmax < ray->tmax) ray->
tmax = tzmax;
423 for (
SLint i = 0; i < 8; ++i)
424 corners[i] = vpvpMat.
multVec(corners[i]);
427 SLVec2f minSS(FLT_MAX, FLT_MAX);
428 SLVec2f maxSS(FLT_MIN, FLT_MIN);
430 for (
SLint i = 0; i < 8; ++i)
432 minSS.
x = std::min(minSS.
x, corners[i].
x);
433 minSS.
y = std::min(minSS.
y, corners[i].
y);
434 maxSS.
x = std::max(maxSS.
x, corners[i].
x);
435 maxSS.
y = std::max(maxSS.
y, corners[i].
y);
453 SLfloat areaFullScreen = (float)vp.
z * (
float)vp.
w;
454 SLfloat coverage = areaSS / areaFullScreen;
Singleton class for global render state.
vector< SLVec3f > SLVVec3f
SLVec3< SLfloat > SLVec3f
Defines an axis aligned bounding box.
SLfloat rectCoverageInSS()
Calculates the bounding rectangle in screen space and returns coverage in SS.
SLGLVertexArrayExt _vao
Vertex array object for rendering.
void generateVAO()
Generates the vertex buffer for the line visualization.
SLVec3f _centerOS
Center of AABB in object space.
void reset()
Resets initial state without contents.
SLVec3f _minOS
Min. corner in object space.
SLVec3f _axisZWS
World space z-axis vector.
SLfloat _radiusWS
Radius of sphere around AABB in WS.
void mergeWS(SLAABBox &bb)
Merges the bounding box bb to this one by extending this one axis aligned.
SLVec3f _parent0WS
World space vector to the parent position.
SLbool isHitInWS(SLRay *ray)
SLAABBox::isHitInWS: Ray - AABB Intersection Test in world space.
SLRectf _rectSS
Bounding rectangle in screen space.
SLVec3f _maxWS
Max. corner in world space.
SLVec3f _axisXWS
World space x-axis vector.
SLAABBox()
Default constructor with default zero vector initialization.
void fromOStoWS(const SLVec3f &minOS, const SLVec3f &maxOS, const SLMat4f &wm)
Recalculate min and max after transformation in world coords.
void calculateRectSS()
Calculates the AABBs min. and max. corners in screen space.
SLVec3f _maxOS
Max. corner in object space.
SLfloat _sqrViewDist
Squared dist. from center to viewpoint.
SLVec3f _axisYWS
World space y-axis vector.
SLVec3f _centerWS
Center of AABB in world space.
void minWS(const SLVec3f &minC)
void drawAxisWS()
Draws the axis in world space with lines in a color.
SLVec3f _axis0WS
World space axis center point.
SLfloat _radiusOS
Radius of sphere around AABB in OS.
void drawWS(const SLCol4f &color)
Draws the AABB in world space with lines in a color.
void fromWStoOS(const SLVec3f &minWS, const SLVec3f &maxWS, const SLMat4f &wmI)
Recalculate min and max before transformation in object coords.
void maxWS(const SLVec3f &maxC)
void updateAxisWS(const SLMat4f &wm)
Updates the axis of the owning node.
void updateBoneWS(const SLMat4f &parentWM, SLbool isRoot, const SLMat4f &nodeWM)
Updates joints axis and the bone line from the parent to us.
SLbool _boneIsOffset
Flag if the connection parent to us is a bone or an offset.
void drawBoneWS()
Draws the joint axis and the parent bone in world space.
SLbool isHitInOS(SLRay *ray)
SLAABBox::isHitInWS: Ray - AABB Intersection Test in object space.
SLbool _isVisible
Flag if AABB is in the view frustum.
void setCenterAndRadiusWS()
Calculates center & radius of the bounding sphere around the AABB.
SLVec3f _minWS
Min. corner in world space.
Singleton class holding all OpenGL states.
void viewport(SLint x, SLint y, SLsizei width, SLsizei height)
static SLGLState * instance()
Public static instance getter for singleton pattern.
SLMat4f viewMatrix
matrix for the active cameras view transform
SLMat4f projectionMatrix
matrix for projection transform
void generateVertexPos(SLVVec2f *p)
Adds or updates & generates a position vertex attribute for colored line or point drawing.
void drawArrayAsColored(SLGLPrimitiveType primitiveType, SLCol4f color, SLfloat lineOrPointSize=1.0f, SLuint indexFirstVertex=0, SLuint countVertices=0)
Draws the array as the specified primitive with the color.
void clearAttribs()
Clears the attribute definition.
SLuint vaoID() const
Returns either the VAO id or the VBO id.
SLVec3< T > axisY() const
SLVec3< T > multVec(SLVec3< T > v) const
Ray class with ray and intersection properties.
SLfloat tmax
max. dist. of last AABB intersection
SLint sign[3]
Sign of invDir for fast AABB hit in WS.
SLVec3f origin
Vector to the origin of ray in WS.
SLVec3f invDirOS
Inverse ray dir for fast AABB hit in OS.
SLfloat tmin
min. dist. of last AABB intersection
SLfloat length
length from origin to an intersection
SLint signOS[3]
Sign of invDir for fast AABB hit in OS.
SLVec3f invDir
Inverse ray dir for fast AABB hit in WS.
SLVec3f originOS
Vector to the origin of ray in OS.
void set(const T X, const T Y, const T WIDTH, const T HEIGHT)
void setMax(const SLVec3 &v)
void set(const T X, const T Y, const T Z)
T dot(const SLVec3 &v) const
void setMin(const SLVec3 &v)