class RED::BoundingSphere
Standard bounding element of all RED shapes. More...
#include <REDBoundingSphere.h>
Inherits: Object.
Public functions:
BoundingSphere ( float * iVertexArray, int iSize ) | |
BoundingSphere ( ) | |
BoundingSphere ( const RED::Vector3 & iCenter, double iRadius ) | |
BoundingSphere ( const RED::Vector< RED::Vector3 > & iVertexArray ) | |
virtual | ~BoundingSphere ( ) |
RED_RC | Add ( const RED::Vector< RED::Vector3 > & iVertexArray ) |
RED_RC | Add ( float * iVertexArray, int iSize ) |
RED_RC | Add ( const void * iVertexArray, int iVertexSize, RED::MESH_FORMAT iFormat, int iNbVertices ) |
RED_RC | Add ( const RED::Vector< RED::BoundingSphere * > & iSphereList ) |
virtual const void * | As ( const RED::CID & iCID ) const |
template< class T_As > const T_As * | As ( ) const |
virtual void * | As ( const RED::CID & iCID ) |
template< class T_As > T_As * | As ( ) |
void | GetAABB ( double oAABB[6] ) const |
const RED::Vector3 & | GetCenter ( ) const |
double | GetRadius ( ) const |
double | GetRadius2 ( ) const |
bool | IsAABB ( ) const |
RED_RC | Set ( float * iVertexArray, int iSize ) |
RED_RC | Set ( const RED::Vector< RED::BoundingSphere * > & iSphereList ) |
RED_RC | Set ( const RED::Vector< RED::Vector3 > & iVertexArray ) |
RED_RC | Set ( const RED::Vector3 & iCenter, double iRadius ) |
RED_RC | Set ( const void * iVertexArray, int iVertexSize, RED::MESH_FORMAT iFormat, int iNbVertices ) |
RED_RC | SetAABB ( const double iAABB[6], bool iOverrideSphere = false ) |
RED_RC | SetAABB ( const RED::Vector< RED::Vector3 > & iVertex, bool iOverrideSphere = false ) |
RED_RC | SetAABB ( const float * iVertex, int iVerticesCount, bool iOverrideSphere = false ) |
void | SetCenter ( const RED::Vector3 & iCenter ) |
void | SetRadius ( double iRadius ) |
Public static functions:
static RED::CID | GetClassID ( ) |
Protected variables:
double | _aabb [6] |
RED::Vector3 | _center |
double | _radius |
double | _radius2 |
Detailed description:
Standard bounding element of all RED shapes.
Shape geometry in space is limited using a bounding sphere, that is a sphere spatially enclosing all shape geometry, or that can be manually defined for any culling purpose. A parent/children hierarchy is kept with the bounding spheres of a DAG. This does not necessarily imply that a parent bounding sphere will contain the spheres of all it's children, but it implies that a parent bounding sphere will contain it's children true geometry at least.
A bounding sphere is defined in the space of the shape it's linked with.
The class can also contain an Axis Aligned Bounding Box information (AABB). This AABB is only informative and it's not used in any engine calculation. A valid bounding sphere can be automatically setup when filling an AABB information. Unless specified otherwise, any method manipulating the bounding sphere parameters in the class has no effect on the AABB that remain unchanged.
Functions documentation
public RED::BoundingSphere::BoundingSphere | ( | float * | iVertexArray, |
int | iSize | ||
) |
BoundingSphere construction method from a list of vertices.
Constructs a bounding sphere enclosing the provided vertex array. No AABB.
Parameters:
iVertexArray: | List of vertices (XYZ XYZ XYZ in memory). |
iSize: | Size of iVertexArray in floats (= 3*nb_vertices). |
public RED::BoundingSphere::BoundingSphere | ( | ) |
BoundingSphere construction method.
Construct a bounding sphere with a RED_TOL2 radius, located at the shape space origin. No AABB.
public RED::BoundingSphere::BoundingSphere | ( | const RED::Vector3 & | iCenter, |
double | iRadius | ||
) |
BoundingSphere construction method provided a center and a radius.
Coordinates are local to the shape that'll use this sphere. No AABB.
Parameters:
iCenter: | RED::Vector3 center coordinates. |
iRadius: | Radius of the sphere. |
public RED::BoundingSphere::BoundingSphere | ( | const RED::Vector< RED::Vector3 > & | iVertexArray | ) |
BoundingSphere construction method from a list of vertices.
Constructs a bounding sphere that encloses all given vertices. No AABB.
Parameters:
iVertexArray: | List of vertices to enclose. |
public virtual RED::BoundingSphere::~BoundingSphere | ( | ) |
BoundingSphere destruction method.
public static RED::CID RED::BoundingSphere::GetClassID | ( | ) |
Reimplements: RED::Object::GetClassID.
public RED_RC RED::BoundingSphere::Add | ( | const RED::Vector< RED::Vector3 > & | iVertexArray | ) |
Adds new vertex geometry to an already defined bounding sphere.
This method merges the currently defined object bounding sphere with the provided vertices. The result of this call may extends the size of the current bounding sphere.
Note:
Repeated usage of this method causes erosion, and accumulation of inaccuracies.
Parameters:
iVertexArray: | Added vertices. |
Returns:
public RED_RC RED::BoundingSphere::Add | ( | float * | iVertexArray, |
int | iSize | ||
) |
Adds new vertex geometry to an already defined bounding sphere.
Same as RED::BoundingSphere::Add, using 3 floats per vertex.
Parameters:
iVertexArray: | List of vertices (XYZ XYZ XYZ in memory). |
iSize: | Size of iVertexArray in floats (= 3*nb_vertices). |
public RED_RC RED::BoundingSphere::Add | ( | const void * | iVertexArray, |
int | iVertexSize, | ||
RED::MESH_FORMAT | iFormat, | ||
int | iNbVertices | ||
) |
Adds new vertex geometry to an already defined bounding sphere.
Same as RED::BoundingSphere::Add, using all possible vertex formats and sizes.
Parameters:
iVertexArray: | The array of vertices. |
iVertexSize: | The number of coordinates for each vertex (1 = x; 2 = xy; 3 = xyz; 4 = xyzw). |
iFormat: | The vertex array format. |
iNbVertices: | The number of vertices to consider. |
Returns:
public RED_RC RED::BoundingSphere::Add | ( | const RED::Vector< RED::BoundingSphere * > & | iSphereList | ) |
Adds new spheres to the already defined bounding sphere.
This method merges the currently defined object bounding sphere with the provided spheres. The result of this call may extends the size of the current bounding sphere.
Note:
Repeated usage of this method causes erosion, and accumulation of inaccuracies.
Parameters:
iSphereList: | List of spheres to merge with. |
Returns:
public virtual const void * RED::BoundingSphere::As | ( | const RED::CID & | iCID | ) const |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::As.
template< class T_As > public const T_As * RED::BoundingSphere::As | ( | ) const |
Template version of the as const method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Object::As.
public virtual void * RED::BoundingSphere::As | ( | const RED::CID & | iCID | ) |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::As.
template< class T_As > public T_As * RED::BoundingSphere::As | ( | ) |
Template version of the as method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Object::As.
public void RED::BoundingSphere::GetAABB | ( | double | oAABB[6] | ) const |
Access the AABB information stored in the class.
Parameters:
oAABB: | Returned AABB information [ xmin, xmax, ymin, ymax, zmin, zmax ]. |
public const RED::Vector3 & RED::BoundingSphere::GetCenter | ( | ) const |
Gets the center of the bounding sphere.
Returns:
public double RED::BoundingSphere::GetRadius | ( | ) const |
Gets the radius of the bounding sphere.
Returns:
public double RED::BoundingSphere::GetRadius2 | ( | ) const |
Gets the square radius of the bounding sphere.
Returns:
public bool RED::BoundingSphere::IsAABB | ( | ) const |
Returns:
public RED_RC RED::BoundingSphere::Set | ( | float * | iVertexArray, |
int | iSize | ||
) |
Defines a bounding sphere that encloses a list of vertices.
Same as RED::BoundingSphere::Set, using 3 floats per vertex.
Parameters:
iVertexArray: | List of vertices (XYZ XYZ XYZ in memory). |
iSize: | Size of iVertexArray in floats (= 3*nb_vertices). |
Returns:
public RED_RC RED::BoundingSphere::Set | ( | const RED::Vector< RED::BoundingSphere * > & | iSphereList | ) |
Encloses a list of bounding spheres.
This method sets the sphere parameters so that they define a sphere enclosing the provided list of spheres.
Parameters:
iSphereList: | List of spheres to merge with. |
Returns:
public RED_RC RED::BoundingSphere::Set | ( | const RED::Vector< RED::Vector3 > & | iVertexArray | ) |
Defines a bounding sphere that encloses a list of vertices.
Computes a bounding sphere as small as possible that encloses the given vertex array.
Parameters:
iVertexArray: | List of vertices to enclose. |
Returns:
public RED_RC RED::BoundingSphere::Set | ( | const RED::Vector3 & | iCenter, |
double | iRadius | ||
) |
Sets the bounding sphere according to provided center and radius.
Parameters:
iCenter: | Center coordinates of the sphere. |
iRadius: | Radius to assign to the sphere. |
Returns:
public RED_RC RED::BoundingSphere::Set | ( | const void * | iVertexArray, |
int | iVertexSize, | ||
RED::MESH_FORMAT | iFormat, | ||
int | iNbVertices | ||
) |
Defines a bounding sphere that encloses a list of vertices.
This method behaves similarly to all other RED::BoundingSphere::Set methods except that it's using a more generic format. The iVertexArray parameter can be retrieved from a RED::IMeshShape::GetVertexArray for instance (as well as from a RED::ILineShape or RED::IPointShape). The method uses the same size and format parameters as the GetVertexArray call does. In addition, the number of vertices has to be supplied.
Note that .w coordinates are ignored for the calculation of 3d
Parameters:
iVertexArray: | The array of vertices. |
iVertexSize: | The number of coordinates for each vertex (1 = x; 2 = xy; 3 = xyz; 4 = xyzw). |
iFormat: | The vertex array format. |
iNbVertices: | The number of vertices to consider. |
Returns:
public RED_RC RED::BoundingSphere::SetAABB | ( | const double | iAABB[6], |
bool | iOverrideSphere = false | ||
) |
Add an AABB information to the class.
The specified AABB is informative only and does not modify the behavior of the engine. If iOverrideSphere is true, the bounding sphere is redefined from the box, which can lead to erosion.
Parameters:
iAABB: | The Axis Aligned Bounding Box parameters in that order [ xmin, xmax, ymin, ymax, zmin, zmax ]. It's valid to set a zero AABB to reset it. |
iOverrideSphere: | If true, the sphere is overriden by a sphere calculated from the specified box. |
Returns:
RED_BAD_PARAM if iAABB is invalid ( xmax < xmin or ymax < ymin or zmax < zmin ).
public RED_RC RED::BoundingSphere::SetAABB | ( | const RED::Vector< RED::Vector3 > & | iVertex, |
bool | iOverrideSphere = false | ||
) |
Add an AABB information to the class.
The specified AABB is informative only and does not modify the behavior of the engine. If iOverrideSphere is true, the bounding sphere is redefined from the box, which can lead to erosion.
Parameters:
iVertex: | The vertex array to enclose. If empty, the AABB is reset to zero. |
iOverrideSphere: | If true, the sphere is overriden by a sphere calculated from the specified box. |
Returns:
public RED_RC RED::BoundingSphere::SetAABB | ( | const float * | iVertex, |
int | iVerticesCount, | ||
bool | iOverrideSphere = false | ||
) |
Add an AABB information to the class.
The specified AABB is informative only and does not modify the behavior of the engine. If iOverrideSphere is true, the bounding sphere is redefined from the box, which can lead to erosion.
Parameters:
iVertex: | The vertex array to enclose (XYZ, float). |
iVerticesCount: | The number of vertices. |
iOverrideSphere: | If true, the sphere is overriden by a sphere calculated from the specified box. |
Returns:
public void RED::BoundingSphere::SetCenter | ( | const RED::Vector3 & | iCenter | ) |
Sets the center of the bounding sphere.
Parameters:
iCenter: | New bounding sphere center. |
public void RED::BoundingSphere::SetRadius | ( | double | iRadius | ) |
Sets the radius of the bounding sphere.
Parameters:
iRadius: | New radius of the bounding sphere. |
Variables documentation
AABB data [ xmin, xmax, ymin, ymax, zmin, zmax ].
Model coordinates of the sphere center.
Model unit radius of the sphere.
Square value of _radius.