[SML Overview]

class SMLSphereBound: public SMLBound

#include "smlbound.h" 

SMLSphereBound is a derivative class, inherits SMLBound class. SMLSphereBound class represents a spherical bounding region enclosing a set of other bounds or points. This object can be extended, transformed, checked to see if a point is inside, checked to see if a vector intersects it, and checked to see if it is outside or inside a set of culling planes.

Public Interface

constructors

Clone

Cull

operator=

around

extendBy

Contains

Transform

probe

SetRadius

GetRadius

copyFrom

CopySame

 

 


Public Data

float r;

Radius of this sphere.

[top]


SMLLIBENTRY SMLSphereBound(const SMLVec3f& smlvec, float initr);

Discussion

SMLSphereBound object constructor.

Parameters

smlvec - reference to SMLVec3f constant object.

initr - radius of sphere

[top]


SMLLIBENTRY SMLSphereBound(const SMLSphereBound& smlbound)

Discussion

SMLSphereBound object copy-constructor.

Parameters

smlbound - reference to SMLSphereBound constant object which copy to create.

[top]


SMLLIBENTRY SMLSphereBound();

Discussion

Default SMLSphereBound object constructor.

Parameters

No.

[top]


SMLLIBENTRY virtual SMLBound* Clone();

SMLLIBENTRY virtual const SMLBound* Clone() const;

Discussion

These two virtual methods create the copy of the SMLSphereBound-type object for which they are called.

Parameters

No.

Return Value

Methods return SMLBound-type pointer or const SMLBound-type pointer to new object.

[top]


SMLLIBENTRY virtual bool Cull(const SMLPlane* planes, int numPlane) const ;

Discussion

Method checks if this bound lies within frustum created by specified planes. Method checks the distance between the center of sphere and the planes given in array planes.

Parameters

planes - defines array of planes used for culling of current sphere (frustum).

numPlane - number of planes.

Return Value

Returns true if this sphere is culled. Otherwise, returns false.

[top]


SMLLIBENTRY const SMLSphereBound& operator =(const SMLSphereBound& s);

Discussion

Method is an overloaded operator-function. It nominates new coordinates of center of this sphere, changes its radius and makes these parameters equal to those of object s.

Parameters

s - object of SMLSphereBound type.

Return Value

Returns reference to the SMLSphereBound-type object to which it nominates new sphere center coordinates and radius.

[top]


SMLLIBENTRY virtual void around(const SMLSphereBound** spheres, int nspheres);

Discussion

Method creates new sphere, which surrounds all the spheres from array spheres.

Parameters

spheres - represents array of pointers to constant objects of SMLSphereBound type

nspheres - number of spheres.

[top]


SMLLIBENTRY virtual void around(const SMLVec3f* pts, int npoints);

Discussion

Method creates new sphere, which surrounds all the points from SMLVec3f-type array.

Parameters

pts - array of pointers to constant objects of SMLVec3f type.

npoints - number of points.

[top]


SMLLIBENTRY virtual void around(const SMLBoxBound** boxes, int nboxes);

Discussion

Method creates new sphere that surrounds all the boxes from SMLBoxBound-type array.

Parameters

boxes - array of pointers to constant objects of SMLBoxBound type

nboxes - number of boxes.

[top]


SMLLIBENTRY virtual void around(const SMLSphereBound* sphere);

Discussion

Method creates new sphere that coincides with the given sphere.

Parameters

sphere - pointer to a constant object of SMLSphereBound type

[top]


SMLLIBENTRY virtual void around(const SMLBoxBound* box);

Discussion

Method creates a new sphere which surrounds given box.

Parameters

sphere - pointer to a constant object of SMLSphereBound type

[top]


SMLLIBENTRY virtual void around(const SMLBound* bound);

Discussion

Method creates a new sphere, which surrounds an object of SMLBound type, i.e. box or sphere.

Parameters

bound - pointer to a constant object of SMLBound type

[top]


SMLLIBENTRY virtual void around(const SMLBound** bounds, int nbounds);

Discussion

Method creates a new sphere, which surrounds all the objects of SMLBound type, i.e. boxes or spheres.

Parameters

bound - specifies array of bounds

[top]


SMLLIBENTRY virtual void extendBy(const SMLVec3f& point);

Discussion

Method extends a spherical bound (changes its center coordinates and radius) to include given point.

Parameters

point - reference to constant object of SMLVec3f type.

[top]


SMLLIBENTRY virtual void extendBy(const SMLBoxBound* box);

Discussion

Method extends a spherical bound to include given box.

Parameters

box - pointer to a constant object of SMLBoxBound type.

[top]


SMLLIBENTRY virtual void extendBy(const SMLSphereBound* sphere);

Discussion

Method extends a spherical bound to include given sphere.

Parameters

sphere - pointer to a constant object of SMLSphereBound type.

[top]


SMLLIBENTRY virtual void extendBy(const SMLBound* bound);

Discussion

Method extends a spherical bound. If bound is a pointer to an object of SMLSphereBound type the method extends this spherical bound to include the sphere. If bound is a pointer to an object of SMLBoxBound type the method extends this spherical bound for to include given box.

Parameters

bound - pointer to constant object of SMLBound type.

[top]


SMLLIBENTRY virtual bool contains(const SMLVec3f& point) const;

Discussion

Method checks if the point is inside this spherical bound.

Parameters

point - reference to a constant object of SMLVec3f type.

Return Value

Returns true if the point is inside this sphere. Otherwise, returns false.

[top]


SMLLIBENTRY virtual bool contains(const SMLBoxBound* box) const;

Discussion

Method checks if a box is inside the shperical bound.

Parameters

box - pointer to a constant object of SMLBox Bound type.

Return Value

Returns true if the given box is inside this spherical bound. Otherwise, returns false.

[top]


SMLLIBENTRY virtual bool contains(const SMLSphereBound* sphere) const;

Discussion

Method checks if a sphere is inside this spherical bound.

Parameters

sphere - pointer to a constant object of SMLSphereBound type.

Return Value

Returns true if the given sphere is inside this spherical bound. Otherwise, returns false.

[top]


SMLLIBENTRY virtual bool contains(const SMLBound* bound) const;

Discussion

Method checks if an object of SMLBound type (sphere or box) is inside this spherical bound.

Parameters

bound - pointer to a constant object of SMLBound type.

Return Value

Returns true if the given sphere or box are inside this spherical bound. Otherwise, returns false.

[top]


SMLLIBENTRY virtual void Transform(const SMLBound* bound, const SMLMatrix4f& matrix);

Discussion

Method transforms the object bound. If bound is a sphere, the method transforms the coordinates of its center and radius in accordance with transformation matrix. If bound is a box, the method creates a new sphere, which surrounds this box and then transforms this sphere in accordance with matrix.

Parameters

bound - pointer to a constant object of SMLBound type.

matrix - transformation matrix.

[top]


SMLLIBENTRY virtual bool probe(const SMLVec3f& p1, const SMLVec3f& p2, float* closeDist, float* farDist);

Discussion

Method checks if segment, defined with its start p1 and end p2, crosses this sphere.

Parameters

p1 - reference to the start of the segment ( a constant object of SMLVec3f type).

p2 - reference to the end of the segment ( a constant object of SMLVec3f type).

Output

Parameters

closeDist - pointer to the close cross point.

farDist - pointer to the far cross point.

Return Value

Returns true if the segment crosses given sphere. Otherwise, returns false.

[top]


SMLLIBENTRY virtual bool probe(const SMLRay& ray, float* closeDist, float* farDist);

Discussion

Method checks if ray crosses this sphere.

Parameters

ray - reference to a constant object of SMLRay type.

Output

Parameters

closeDist - pointer to the close cross point.

farDist - pointer to the far cross point.

Computation of these distances is not realized.

Return Value

Returns true if the ray crosses given sphere. Otherwise, returns false.

[top]


SMLLIBENTRY virtual void Transform(const SMLSphereBound* src, const SMLMatrix4f& matrix);

Discussion

Method transforms a sphere. The method transforms the coordinates of its center and radius in accordance with object matrix.

Parameters

src - pointer to a constant object of SMLSphereBound type.

matrix - transformation matrix.

[top]


SMLLIBENTRY void SetRadius(float radius);

Discussion

Method sets new radius of this sphere.

Parameters

radius - new radius of this sphere.

[top]


SMLLIBENTRY void GetRadius();

Discussion

Method gets radius of this sphere.

Parameters

No.

Return Value

Returns value of current radius of this sphere.

[top]


virtual void copyFrom(const SMLBound& bound);

Discussion

Method sets new radius and coordinates of center of this sphere equal to those of object bound.

Parameters

bound - reference to object of SMLBound type.

[top]


virtual void copySame(const SMLSphereBound* bound);

Discussion

Method creates new sphere with radius and coordinates of center equal to those of spherical bound.

Parameters

bound - poiner to object of SMLSphereBound type.

[top]


SMLLIBENTRY virtual bool containsRelativeCoordinates(float px, float py, float pz) const;

Discussion

Method checks if the point defined by px, py, pz is inside this sphere.

Parameters

px, py, pz - coordinates of the point.

Return Value

Returns true if the point is inside this sphere. Otherwise, returns false.

[top]