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 Sphere3f
m_kSphere
Sphere in this bounding volume:private static long
serialVersionUID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
ComputeFromData(Vector3f[] pkVertices)
Compute a sphere that contains all the points.void
ComputeFromData(VertexBuffer pkVBuffer)
Compute a sphere that contains all the points in the VertexBuffer.boolean
Contains(Vector3f rkPoint)
Test for containment of a pointvoid
CopyFrom(BoundingVolume pkInput)
Make a copy of the bounding volume.void
dispose()
Delete memory.BoundingVolume.BVType
GetBVType()
Get bounding volume type.Vector3f
GetCenter()
All bounding volumes must define a center and radiusint
GetDiskUsed(StreamVersion rkVersion)
Returns the size of this object and it's children on disk for the current StreamVersion parameter.float
GetRadius()
All bounding volumes must define a center and radiusSphere3f
GetSphere()
Return bounding volume sphere object.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.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.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.boolean
Register(Stream rkStream)
Registers this object with the input Stream parameter.void
Save(Stream rkStream)
Write this object and all it's children to the Stream.StringTree
SaveStrings(java.lang.String acTitle)
Write this object into a StringTree for the scene-graph visualization.void
SetCenter(Vector3f rkCenter)
All bounding volumes must define a center and radiusvoid
SetRadius(float fRadius)
All bounding volumes must define a center and radiusSphere3f
Sphere()
Return bounding volume sphere object.boolean
TestIntersection(Vector3f rkOrigin, Vector3f rkDirection, float fTMin, float fTMax)
Test for intersection of linear component and bound (points of intersection not computed).boolean
TestIntersection(BoundingVolume pkInput)
Test for intersection of the two bounds.void
TransformBy(Transformation rkTransform, BoundingVolume pkResult)
Transform the sphere (model-to-world conversion).int
WhichSide(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:
ComputeFromData
in 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:
ComputeFromData
in classBoundingVolume
- Parameters:
pkVBuffer
- VertexBuffer with points to contain.
-
Contains
public boolean Contains(Vector3f rkPoint)
Test for containment of a point- Specified by:
Contains
in 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:
CopyFrom
in classBoundingVolume
- Parameters:
pkInput
- bounding volume to copy.
-
dispose
public void dispose()
Delete memory.- Overrides:
dispose
in classGraphicsObject
-
GetBVType
public final BoundingVolume.BVType GetBVType()
Get bounding volume type.- Specified by:
GetBVType
in classBoundingVolume
- Returns:
- bounding volume type BV_SPHERE.
-
GetCenter
public final Vector3f GetCenter()
All bounding volumes must define a center and radius- Specified by:
GetCenter
in 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:
GetDiskUsed
in interfaceStreamInterface
- Overrides:
GetDiskUsed
in 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:
GetRadius
in 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:
GrowToContain
in 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:
Link
in interfaceStreamInterface
- Overrides:
Link
in 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:
Load
in interfaceStreamInterface
- Overrides:
Load
in 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:
Register
in interfaceStreamInterface
- Overrides:
Register
in 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:
Save
in interfaceStreamInterface
- Overrides:
Save
in 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:
SaveStrings
in interfaceStreamInterface
- Overrides:
SaveStrings
in 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:
SetCenter
in classBoundingVolume
- Parameters:
rkCenter
- bounding volume center.
-
SetRadius
public final void SetRadius(float fRadius)
All bounding volumes must define a center and radius- Specified by:
SetRadius
in 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:
TestIntersection
in 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:
TestIntersection
in 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:
TransformBy
in 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:
WhichSide
in classBoundingVolume
- Parameters:
rkPlane
- plane to test against bounding volume.- Returns:
- positive: +1; negative: -1; straddles: 0.
-
-