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 ( )
const RED::Vector3 &GetCenter ( ) const
doubleGetRadius ( ) const
doubleGetRadius2 ( ) const
RED_RCSet ( const RED::Vector< RED::BoundingSphere * > & iSphereList )
RED_RCSet ( const void * iVertexArray, int iVertexSize, RED::MESH_FORMAT iFormat, int iNbVertices )
RED_RCSet ( float * iVertexArray, int iSize )
RED_RCSet ( const RED::Vector3 & iCenter, double iRadius )
RED_RCSet ( const RED::Vector< RED::Vector3 > & iVertexArray )
voidSetCenter ( const RED::Vector3 & iCenter )
voidSetRadius ( double iRadius )

Public static functions:

static RED::CIDGetClassID ( )

Protected variables:

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

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.

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.

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.

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.

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.

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.

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

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

Model coordinates of the sphere center.

Model unit radius of the sphere.

Square value of _radius.