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_RCAdd ( const RED::Vector< RED::Vector3 > & iVertexArray )
RED_RCAdd ( float * iVertexArray, int iSize )
RED_RCAdd ( const void * iVertexArray, int iVertexSize, RED::MESH_FORMAT iFormat, int iNbVertices )
RED_RCAdd ( 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 ( )
voidGetAABB ( double oAABB[6] ) const
const RED::Vector3 &GetCenter ( ) const
doubleGetRadius ( ) const
doubleGetRadius2 ( ) const
boolIsAABB ( ) const
RED_RCSet ( float * iVertexArray, int iSize )
RED_RCSet ( const RED::Vector< RED::BoundingSphere * > & iSphereList )
RED_RCSet ( const RED::Vector< RED::Vector3 > & iVertexArray )
RED_RCSet ( const RED::Vector3 & iCenter, double iRadius )
RED_RCSet ( const void * iVertexArray, int iVertexSize, RED::MESH_FORMAT iFormat, int iNbVertices )
RED_RCSetAABB ( const double iAABB[6], bool iOverrideSphere = false )
RED_RCSetAABB ( const RED::Vector< RED::Vector3 > & iVertex, bool iOverrideSphere = false )
RED_RCSetAABB ( const float * iVertex, int iVerticesCount, bool iOverrideSphere = false )
voidSetCenter ( const RED::Vector3 & iCenter )
voidSetRadius ( double iRadius )

Public static functions:

static RED::CIDGetClassID ( )

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,
intiSize
)

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).

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,
doubleiRadius
)

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.

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.

BoundingSphere destruction method.

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:

RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.
public RED_RC RED::BoundingSphere::Add(float *iVertexArray,
intiSize
)

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,
intiVertexSize,
RED::MESH_FORMATiFormat,
intiNbVertices
)

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:

RED_OK if the method has succeeded,
RED_BAD_PARAM if the method has received invalid parameters.

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:

RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.
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:

An object pointer of the given class on success, NULL otherwise.

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:

A pointer to a const instance of class T on success, NULL otherwise.

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:

An object pointer of the given class on success, NULL otherwise.

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:

A pointer to an instance of class T on success, NULL otherwise.

Reimplements: RED::Object::As.

public void RED::BoundingSphere::GetAABB(doubleoAABB[6]) const

Access the AABB information stored in the class.

Parameters:

oAABB:Returned AABB information [ xmin, xmax, ymin, ymax, zmin, zmax ].

Gets the center of the bounding sphere.

Returns:

the bounding sphere center.
public double RED::BoundingSphere::GetRadius() const

Gets the radius of the bounding sphere.

Returns:

The bounding sphere radius.
public double RED::BoundingSphere::GetRadius2() const

Gets the square radius of the bounding sphere.

Returns:

The square value of the sphere's radius.
public bool RED::BoundingSphere::IsAABB() const

Returns:

true if a valid AABB has been set.
public RED_RC RED::BoundingSphere::Set(float *iVertexArray,
intiSize
)

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:

RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.

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:

RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.

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:

RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.
public RED_RC RED::BoundingSphere::Set(const RED::Vector3 &iCenter,
doubleiRadius
)

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:

RED_OK when the assignment succeeded,
RED_BAD_PARAM if the method received an invalid parameter.
public RED_RC RED::BoundingSphere::Set(const void *iVertexArray,
intiVertexSize,
RED::MESH_FORMATiFormat,
intiNbVertices
)

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:

RED_OK if the method has succeeded,
RED_BAD_PARAM if the method has received invalid parameters.
public RED_RC RED::BoundingSphere::SetAABB(const doubleiAABB[6],
booliOverrideSphere = 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_OK if the operation has succeeded,
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,
booliOverrideSphere = 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:

RED_OK if the operation has succeeded, RED_FAIL otherwise.
public RED_RC RED::BoundingSphere::SetAABB(const float *iVertex,
intiVerticesCount,
booliOverrideSphere = 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:

RED_OK if the operation has succeeded, RED_FAIL otherwise.
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(doubleiRadius)

Sets the radius of the bounding sphere.

Parameters:

iRadius:New radius of the bounding sphere.

Variables documentation

protected double RED::BoundingSphere::_aabb[6]

AABB data [ xmin, xmax, ymin, ymax, zmin, zmax ].

Model coordinates of the sphere center.

Model unit radius of the sphere.

Square value of _radius.