BoundingSphere
Functions
|
|
void |
|
void |
|
const Vector3 & |
|
double |
|
double |
Detailed Description
-
class BoundingSphere : public RED::Object
Standard bounding element of all RED shapes.
@related Shape Attributes in a Scene Graph, class RED::IShape
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.
Public Functions
- SET_CID (CID_class_REDBoundingSphere) IMPLEMENT_AS()
-
BoundingSphere()
BoundingSphere construction method.
Construct a bounding sphere with a RED_TOL2 radius, located at the shape space origin. No AABB.
-
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.
-
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.
-
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).
-
virtual ~BoundingSphere()
BoundingSphere destruction method.
-
inline void SetCenter(const RED::Vector3 &iCenter)
Sets the center of the bounding sphere.
- Parameters
iCenter – New bounding sphere center.
-
inline void SetRadius(double iRadius)
Sets the radius of the bounding sphere.
- Parameters
iRadius – New radius of the bounding sphere.
-
RED_RC 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
RED_OK when the assignment succeeded,
RED_BAD_PARAM if the method received an invalid parameter.
-
RED_RC 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
RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.
-
RED_RC 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
RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.
-
RED_RC 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
RED_OK if the method has succeeded,
RED_BAD_PARAM if the method has received invalid parameters.
-
RED_RC 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
RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.
-
RED_RC 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).
-
RED_RC 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
RED_OK if the method has succeeded,
RED_BAD_PARAM if the method has received invalid parameters.
-
RED_RC 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
RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.
-
RED_RC 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
RED_OK when the computation succeeded,
RED_BAD_PARAM if the method received invalid parameters.
-
inline const RED::Vector3 &GetCenter() const
Gets the center of the bounding sphere.
- Returns
the bounding sphere center.
-
inline double GetRadius() const
Gets the radius of the bounding sphere.
- Returns
The bounding sphere radius.
-
inline double GetRadius2() const
Gets the square radius of the bounding sphere.
- Returns
The square value of the sphere’s radius.