Package WildMagic.LibGraphics.SceneGraph
Class SphereBV
- java.lang.Object
-
- WildMagic.LibGraphics.ObjectSystem.GraphicsObject
-
- WildMagic.LibGraphics.SceneGraph.BoundingVolume
-
- WildMagic.LibGraphics.SceneGraph.SphereBV
-
- All Implemented Interfaces:
java.io.Serializable,StreamInterface
public class SphereBV extends BoundingVolume implements StreamInterface, java.io.Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class WildMagic.LibGraphics.SceneGraph.BoundingVolume
BoundingVolume.BVType
-
-
Field Summary
Fields Modifier and Type Field Description protected Sphere3fm_kSphereSphere in this bounding volume:private static longserialVersionUID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidComputeFromData(Vector3f[] pkVertices)Compute a sphere that contains all the points.voidComputeFromData(VertexBuffer pkVBuffer)Compute a sphere that contains all the points in the VertexBuffer.booleanContains(Vector3f rkPoint)Test for containment of a pointvoidCopyFrom(BoundingVolume pkInput)Make a copy of the bounding volume.voiddispose()Delete memory.BoundingVolume.BVTypeGetBVType()Get bounding volume type.Vector3fGetCenter()All bounding volumes must define a center and radiusintGetDiskUsed(StreamVersion rkVersion)Returns the size of this object and it's children on disk for the current StreamVersion parameter.floatGetRadius()All bounding volumes must define a center and radiusSphere3fGetSphere()Return bounding volume sphere object.voidGrowToContain(BoundingVolume pkInput)Change the current sphere so that it is the minimum volume sphere that contains the input sphere as well as its old sphere.voidLink(Stream rkStream, Stream.Link pkLink)Copies this objects children objects from the input Stream's HashTable, based on the LinkID of the child stored in the pkLink parameter.voidLoad(Stream rkStream, Stream.Link pkLink)Loads this object from the input parameter rkStream, using the input Stream.Link to store the IDs of children objects of this object for linking after all objects are loaded from the Stream.booleanRegister(Stream rkStream)Registers this object with the input Stream parameter.voidSave(Stream rkStream)Write this object and all it's children to the Stream.StringTreeSaveStrings(java.lang.String acTitle)Write this object into a StringTree for the scene-graph visualization.voidSetCenter(Vector3f rkCenter)All bounding volumes must define a center and radiusvoidSetRadius(float fRadius)All bounding volumes must define a center and radiusSphere3fSphere()Return bounding volume sphere object.booleanTestIntersection(Vector3f rkOrigin, Vector3f rkDirection, float fTMin, float fTMax)Test for intersection of linear component and bound (points of intersection not computed).booleanTestIntersection(BoundingVolume pkInput)Test for intersection of the two bounds.voidTransformBy(Transformation rkTransform, BoundingVolume pkResult)Transform the sphere (model-to-world conversion).intWhichSide(Plane3f rkPlane)Determine if the bounding volume is one side of the plane, the other side, or straddles the plane.-
Methods inherited from class WildMagic.LibGraphics.ObjectSystem.GraphicsObject
GetAllObjectsByName, GetID, GetName, GetNextID, GetObjectByID, GetObjectByIDBase, GetObjectByName, GetObjectByNameBase, SetName
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
m_kSphere
protected Sphere3f m_kSphere
Sphere in this bounding volume:
-
-
Constructor Detail
-
SphereBV
public SphereBV()
Default construction. Set sphere center (0,0,0), radius 0.
-
SphereBV
public SphereBV(Sphere3f rkSphere)
Set constructor- Parameters:
rkSphere- sphere to copy into this.
-
-
Method Detail
-
ComputeFromData
public void ComputeFromData(Vector3f[] pkVertices)
Compute a sphere that contains all the points.- Specified by:
ComputeFromDatain classBoundingVolume- Parameters:
pkVertices- points to contain.
-
ComputeFromData
public void ComputeFromData(VertexBuffer pkVBuffer)
Compute a sphere that contains all the points in the VertexBuffer.- Specified by:
ComputeFromDatain classBoundingVolume- Parameters:
pkVBuffer- VertexBuffer with points to contain.
-
Contains
public boolean Contains(Vector3f rkPoint)
Test for containment of a point- Specified by:
Containsin classBoundingVolume- Parameters:
rkPoint- point to test.- Returns:
- true if contained in bounding volume.
-
CopyFrom
public void CopyFrom(BoundingVolume pkInput)
Make a copy of the bounding volume.- Specified by:
CopyFromin classBoundingVolume- Parameters:
pkInput- bounding volume to copy.
-
dispose
public void dispose()
Delete memory.- Overrides:
disposein classGraphicsObject
-
GetBVType
public final BoundingVolume.BVType GetBVType()
Get bounding volume type.- Specified by:
GetBVTypein classBoundingVolume- Returns:
- bounding volume type BV_SPHERE.
-
GetCenter
public final Vector3f GetCenter()
All bounding volumes must define a center and radius- Specified by:
GetCenterin classBoundingVolume- Returns:
- bounding volume center.
-
GetDiskUsed
public int GetDiskUsed(StreamVersion rkVersion)
Returns the size of this object and it's children on disk for the current StreamVersion parameter.- Specified by:
GetDiskUsedin interfaceStreamInterface- Overrides:
GetDiskUsedin classBoundingVolume- Parameters:
rkVersion- the current version of the Stream file being created.- Returns:
- the size of this object on disk.
-
GetRadius
public final float GetRadius()
All bounding volumes must define a center and radius- Specified by:
GetRadiusin classBoundingVolume- Returns:
- bounding volume radius.
-
GetSphere
public final Sphere3f GetSphere()
Return bounding volume sphere object.- Returns:
- bounding volume sphere object.
-
GrowToContain
public void GrowToContain(BoundingVolume pkInput)
Change the current sphere so that it is the minimum volume sphere that contains the input sphere as well as its old sphere.- Specified by:
GrowToContainin classBoundingVolume- Parameters:
pkInput- bounding volume to contain.
-
Link
public void Link(Stream rkStream, Stream.Link pkLink)
Copies this objects children objects from the input Stream's HashTable, based on the LinkID of the child stored in the pkLink parameter.- Specified by:
Linkin interfaceStreamInterface- Overrides:
Linkin classBoundingVolume- Parameters:
rkStream- the Stream where the child objects are stored.pkLink- the Link class from which the child object IDs are read.
-
Load
public void Load(Stream rkStream, Stream.Link pkLink)
Loads this object from the input parameter rkStream, using the input Stream.Link to store the IDs of children objects of this object for linking after all objects are loaded from the Stream.- Specified by:
Loadin interfaceStreamInterface- Overrides:
Loadin classBoundingVolume- Parameters:
rkStream- the Stream from which this object is being read.pkLink- the Link class for storing the IDs of this object's children objects.
-
Register
public boolean Register(Stream rkStream)
Registers this object with the input Stream parameter. All objects streamed to disk are registered with the Stream so that a unique list of objects is maintained.- Specified by:
Registerin interfaceStreamInterface- Overrides:
Registerin classBoundingVolume- Parameters:
rkStream- the Stream where the child objects are stored.- Returns:
- true if this object is registered, false if the object has already been registered.
-
Save
public void Save(Stream rkStream)
Write this object and all it's children to the Stream.- Specified by:
Savein interfaceStreamInterface- Overrides:
Savein classBoundingVolume- Parameters:
rkStream- the Stream where the child objects are stored.
-
SaveStrings
public StringTree SaveStrings(java.lang.String acTitle)
Write this object into a StringTree for the scene-graph visualization.- Specified by:
SaveStringsin interfaceStreamInterface- Overrides:
SaveStringsin classBoundingVolume- Parameters:
acTitle- the header for this object in the StringTree.- Returns:
- StringTree containing a String-based representation of this object and it's children.
-
SetCenter
public final void SetCenter(Vector3f rkCenter)
All bounding volumes must define a center and radius- Specified by:
SetCenterin classBoundingVolume- Parameters:
rkCenter- bounding volume center.
-
SetRadius
public final void SetRadius(float fRadius)
All bounding volumes must define a center and radius- Specified by:
SetRadiusin classBoundingVolume- Parameters:
fRadius- bounding volume radius.
-
Sphere
public final Sphere3f Sphere()
Return bounding volume sphere object.- Returns:
- bounding volume sphere object.
-
TestIntersection
public boolean TestIntersection(BoundingVolume pkInput)
Test for intersection of the two bounds.- Specified by:
TestIntersectionin classBoundingVolume- Parameters:
pkInput- bounding volume to test.- Returns:
- true if this bounding volume intersects the input.
-
TestIntersection
public boolean TestIntersection(Vector3f rkOrigin, Vector3f rkDirection, float fTMin, float fTMax)
Test for intersection of linear component and bound (points of intersection not computed). The linear component is parameterized by P + t*D, where P is a point on the component and D is a unit-length direction. The interval [tmin,tmax] is line: tmin = -Mathf::MAX_REAL, tmax = Mathf::MAX_REAL ray: tmin = 0.0f, tmax = Mathf::MAX_REAL segment: tmin = 0.0f, tmax > 0.0f- Specified by:
TestIntersectionin classBoundingVolume- Parameters:
rkOrigin- origin.rkDirection- direction.fTMin- parameter t min-value.fTMax- parameter t max-value.- Returns:
- true if intersection, false otherwise.
-
TransformBy
public void TransformBy(Transformation rkTransform, BoundingVolume pkResult)
Transform the sphere (model-to-world conversion).- Specified by:
TransformByin classBoundingVolume- Parameters:
rkTransform- transformation for sphere.pkResult- bounding volume result.
-
WhichSide
public int WhichSide(Plane3f rkPlane)
Determine if the bounding volume is one side of the plane, the other side, or straddles the plane. If it is on the positive side (the side to which the normal points), the return value is +1. If it is on the negative side, the return value is -1. If it straddles the plane, the return value is 0.- Specified by:
WhichSidein classBoundingVolume- Parameters:
rkPlane- plane to test against bounding volume.- Returns:
- positive: +1; negative: -1; straddles: 0.
-
-