com.jme.widget.bounds
Class WidgetBoundingRectangle

java.lang.Object
  extended bycom.jme.widget.bounds.WidgetBoundingRectangle
All Implemented Interfaces:
BoundingVolume, java.io.Serializable
Direct Known Subclasses:
WidgetViewRectangle

public class WidgetBoundingRectangle
extends java.lang.Object
implements BoundingVolume

Author:
Gregg Patton To change the template for this generated type comment go to Window>Preferences>Java>Code Generation>Code and Comments
See Also:
Serialized Form

Field Summary
protected  Vector2f center
           
 int[] checkPlanes
           
protected  boolean lockMin
           
protected  Vector2f max
           
protected  Vector2f min
           
protected  Vector2f[] points
           
 
Constructor Summary
  WidgetBoundingRectangle()
          Constructor instantiates a new BoundingBox object.
  WidgetBoundingRectangle(boolean lockMin)
           
protected WidgetBoundingRectangle(Vector2f min, Vector2f max, Vector2f center)
          Constructor instantiates a new BoundingBox object.
  WidgetBoundingRectangle(WidgetBoundingRectangle r)
           
  WidgetBoundingRectangle(WidgetBoundingRectangle r, boolean lockMin)
           
 
Method Summary
 void addHeight(float height)
           
 void addMaxX(float x)
           
 void addMaxY(float y)
           
 void addMinX(float x)
           
 void addMinY(float y)
           
 void addWidth(float width)
           
 void axisAligned(Vector2f[] points)
          axisAligned creates a minimal box around all supplied points.
static WidgetBoundingRectangle clip(WidgetBoundingRectangle clip, WidgetBoundingRectangle clipTo)
           
 java.lang.Object clone(BoundingVolume store)
          clone creates a new BoundingSphere object containing the same data as this one.
protected  void computeFromPoints()
           
 void computeFromPoints(Vector2f[] points)
          computeFromPoints creates a new BoundingBox from a given set of points.
 void computeFromPoints(Vector3f[] points)
          computeFromPoints generates a bounding volume that encompasses a collection of points.
 boolean contains(WidgetBoundingRectangle rect)
           
 float distanceTo(Vector3f point)
          Find the distance from the center of this Bounding Volume to the given point.
 Vector2f getCenter()
           
 Vector3f getCenter(Vector3f store)
          Stores the current center of this BoundingRectangle into the store vector.
 int getCheckPlane(int index)
          get the value for a given index in the checkplanes
 float getHeight()
           
 Vector2f getMax()
           
 float getMaxX()
           
 float getMaxY()
           
 Vector2f getMin()
           
 float getMinX()
           
 float getMinY()
           
 Vector2f getSize()
           
 float getWidth()
           
 void initCheckPlanes()
          initCheckPlanes resets the checkplanes to their standard order.
 boolean inside(int x, int y)
           
 boolean insideX(float x)
           
 boolean insideY(float y)
           
 boolean intersects(BoundingVolume bv)
          determines if this bounding volume and a second given volume are intersecting.
 boolean intersects(Ray ray)
          determines if a ray intersects this bounding volume.
static boolean intersects(WidgetBoundingRectangle r1, WidgetBoundingRectangle r2)
           
 boolean intersectsBoundingBox(BoundingBox bb)
          determines if this bounding volume and a given bounding box are intersecting.
 boolean intersectsOBB2(OBB2 obb)
          determines if this bounding volume and a given oriented bounding box are intersecting.
 boolean intersectsOrientedBoundingBox(OrientedBoundingBox obb)
          determines if this bounding volume and a given oriented bounding box are intersecting.
 boolean intersectsSphere(BoundingSphere bs)
          determines if this bounding volume and a given bounding sphere are intersecting.
 boolean isLockMin()
           
 BoundingVolume merge(BoundingVolume bound)
          merge combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume.
 BoundingVolume mergeLocal(BoundingVolume bound)
          mergeLocal combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume.
 void recomputeMesh()
          Reconstruct a visible mesh for the bound.
 void set(WidgetBoundingRectangle r)
           
 void setCheckPlane(int index, int value)
          set the value for a given index in the checkplanes
 void setHeight(float height)
           
 void setLockMin(boolean b)
           
 void setMax(float x, float y)
           
 void setMax(Vector2f max)
           
 void setMaxX(float x)
           
 void setMaxY(float y)
           
 void setMin(float x, float y)
           
 void setMin(Vector2f min)
           
 void setMinPreserveSize(float x, float y)
           
 void setMinPreserveSize(Vector2f at)
           
 void setMinX(float x)
           
 void setMinXPreserveSize(float x)
           
 void setMinY(float y)
           
 void setMinYPreserveSize(float y)
           
 void setSize(Vector2f size)
           
 void setWidth(float width)
           
 void setWidthHeight(float width, float height)
           
 void subtractHeight(float height)
           
 void subtractMaxX(float x)
           
 void subtractMaxY(float y)
           
 void subtractMinX(float x)
           
 void subtractMinY(float y)
           
 void subtractWidth(float width)
           
 java.lang.String toString()
           
 BoundingVolume transform(Quaternion rotate, Vector3f translate, Vector3f scale)
          transform alters the location of the bounding volume by a rotation, translation and a scalar.
 BoundingVolume transform(Quaternion rotate, Vector3f translate, Vector3f scale, BoundingVolume bv)
          transform alters the location of the bounding volume by a rotation, translation and a scalar.
 int whichSide(Plane plane)
          whichSide returns the side on which the bounding volume lies on a plane.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

checkPlanes

public int[] checkPlanes

min

protected Vector2f min

max

protected Vector2f max

center

protected Vector2f center

points

protected Vector2f[] points

lockMin

protected boolean lockMin
Constructor Detail

WidgetBoundingRectangle

public WidgetBoundingRectangle()
Constructor instantiates a new BoundingBox object.


WidgetBoundingRectangle

public WidgetBoundingRectangle(boolean lockMin)

WidgetBoundingRectangle

public WidgetBoundingRectangle(WidgetBoundingRectangle r)

WidgetBoundingRectangle

public WidgetBoundingRectangle(WidgetBoundingRectangle r,
                               boolean lockMin)

WidgetBoundingRectangle

protected WidgetBoundingRectangle(Vector2f min,
                                  Vector2f max,
                                  Vector2f center)
Constructor instantiates a new BoundingBox object. The box is defined by a minimum and maximum point.

Parameters:
center - the center of the box.
min - the minimum point of the box.
max - the maximum point of the box.
Method Detail

initCheckPlanes

public void initCheckPlanes()
Description copied from interface: BoundingVolume
initCheckPlanes resets the checkplanes to their standard order.

Specified by:
initCheckPlanes in interface BoundingVolume

set

public void set(WidgetBoundingRectangle r)

getMin

public Vector2f getMin()

getMinX

public float getMinX()

setMinX

public void setMinX(float x)

getMinY

public float getMinY()

setMinY

public void setMinY(float y)

getMax

public Vector2f getMax()

setMaxX

public void setMaxX(float x)

getMaxX

public float getMaxX()

getMaxY

public float getMaxY()

setMaxY

public void setMaxY(float y)

getCenter

public Vector2f getCenter()

computeFromPoints

public void computeFromPoints(Vector2f[] points)
computeFromPoints creates a new BoundingBox from a given set of points. It uses the axisAligned method as default.

Parameters:
points - the points to contain.

axisAligned

public void axisAligned(Vector2f[] points)
axisAligned creates a minimal box around all supplied points. The orientation is always aligned with the local entity's coordinate system and therefore is axis aligned.

Parameters:
points - the list of points to contain.

contains

public boolean contains(WidgetBoundingRectangle rect)

merge

public BoundingVolume merge(BoundingVolume bound)
Description copied from interface: BoundingVolume
merge combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume.

Specified by:
merge in interface BoundingVolume
Parameters:
bound - the volume to combine.
Returns:
the new merged bounding volume.

mergeLocal

public BoundingVolume mergeLocal(BoundingVolume bound)
Description copied from interface: BoundingVolume
mergeLocal combines two bounding volumes into a single bounding volume that contains both this bounding volume and the parameter volume. The result is stored locally.

Specified by:
mergeLocal in interface BoundingVolume
Parameters:
bound - the volume to combine.
Returns:
this

clone

public java.lang.Object clone(BoundingVolume store)
clone creates a new BoundingSphere object containing the same data as this one.

Specified by:
clone in interface BoundingVolume
Parameters:
store - where to store the cloned information. if null or wrong class, a new store is created.
Returns:
the new WidgetBoundingRectangle

setMin

public void setMin(Vector2f min)

setMin

public void setMin(float x,
                   float y)

setMinPreserveSize

public void setMinPreserveSize(float x,
                               float y)

setMinPreserveSize

public void setMinPreserveSize(Vector2f at)

setMinXPreserveSize

public void setMinXPreserveSize(float x)

setMinYPreserveSize

public void setMinYPreserveSize(float y)

addMinX

public void addMinX(float x)

subtractMinX

public void subtractMinX(float x)

addMinY

public void addMinY(float y)

subtractMinY

public void subtractMinY(float y)

setMax

public void setMax(Vector2f max)

setMax

public void setMax(float x,
                   float y)

addMaxX

public void addMaxX(float x)

subtractMaxX

public void subtractMaxX(float x)

addMaxY

public void addMaxY(float y)

subtractMaxY

public void subtractMaxY(float y)

setSize

public void setSize(Vector2f size)

getSize

public Vector2f getSize()

setWidthHeight

public void setWidthHeight(float width,
                           float height)

setWidth

public void setWidth(float width)

getWidth

public float getWidth()

setHeight

public void setHeight(float height)

getHeight

public float getHeight()

addWidth

public void addWidth(float width)

subtractWidth

public void subtractWidth(float width)

addHeight

public void addHeight(float height)

subtractHeight

public void subtractHeight(float height)

inside

public boolean inside(int x,
                      int y)

insideX

public boolean insideX(float x)

insideY

public boolean insideY(float y)

computeFromPoints

protected void computeFromPoints()

intersects

public static boolean intersects(WidgetBoundingRectangle r1,
                                 WidgetBoundingRectangle r2)

clip

public static WidgetBoundingRectangle clip(WidgetBoundingRectangle clip,
                                           WidgetBoundingRectangle clipTo)

isLockMin

public boolean isLockMin()

setLockMin

public void setLockMin(boolean b)

transform

public BoundingVolume transform(Quaternion rotate,
                                Vector3f translate,
                                Vector3f scale)
Description copied from interface: BoundingVolume
transform alters the location of the bounding volume by a rotation, translation and a scalar.

Specified by:
transform in interface BoundingVolume
Parameters:
rotate - the rotation to affect the bound.
translate - the translation to affect the bound.
scale - the scale to resize the bound.
Returns:
the new bounding volume.

transform

public BoundingVolume transform(Quaternion rotate,
                                Vector3f translate,
                                Vector3f scale,
                                BoundingVolume bv)
Description copied from interface: BoundingVolume
transform alters the location of the bounding volume by a rotation, translation and a scalar.

Specified by:
transform in interface BoundingVolume
Parameters:
rotate - the rotation to affect the bound.
translate - the translation to affect the bound.
scale - the scale to resize the bound.
bv - sphere to store result in
Returns:
the new bounding volume.

whichSide

public int whichSide(Plane plane)
Description copied from interface: BoundingVolume
whichSide returns the side on which the bounding volume lies on a plane. Possible values are POSITIVE_SIDE, NEGATIVE_SIDE, and NO_SIDE.

Specified by:
whichSide in interface BoundingVolume
Parameters:
plane - the plane to check against this bounding volume.
Returns:
the side on which this bounding volume lies.
See Also:
Point

computeFromPoints

public void computeFromPoints(Vector3f[] points)
Description copied from interface: BoundingVolume
computeFromPoints generates a bounding volume that encompasses a collection of points.

Specified by:
computeFromPoints in interface BoundingVolume
Parameters:
points - the points to contain.

getCheckPlane

public int getCheckPlane(int index)
Description copied from interface: BoundingVolume
get the value for a given index in the checkplanes

Specified by:
getCheckPlane in interface BoundingVolume
Parameters:
index -
Returns:

setCheckPlane

public void setCheckPlane(int index,
                          int value)
Description copied from interface: BoundingVolume
set the value for a given index in the checkplanes

Specified by:
setCheckPlane in interface BoundingVolume
Parameters:
index -
value -

recomputeMesh

public void recomputeMesh()
Description copied from interface: BoundingVolume
Reconstruct a visible mesh for the bound.

Specified by:
recomputeMesh in interface BoundingVolume

distanceTo

public float distanceTo(Vector3f point)
Find the distance from the center of this Bounding Volume to the given point.

Specified by:
distanceTo in interface BoundingVolume
Parameters:
point - The point to get the distance to
Returns:
distance

getCenter

public Vector3f getCenter(Vector3f store)
Stores the current center of this BoundingRectangle into the store vector. The z component of the store is simply set to 0 because this object's center is just 2D.

Specified by:
getCenter in interface BoundingVolume
Parameters:
store - The vector to store the center into.
Returns:
The store vector, after setting it's contents to the center

toString

public java.lang.String toString()

intersects

public boolean intersects(BoundingVolume bv)
Description copied from interface: BoundingVolume
determines if this bounding volume and a second given volume are intersecting. Intersecting being: one volume contains another, one volume overlaps another or one volume touches another.

Specified by:
intersects in interface BoundingVolume
Parameters:
bv - the second volume to test against.
Returns:
true if this volume intersects the given volume.

intersectsSphere

public boolean intersectsSphere(BoundingSphere bs)
Description copied from interface: BoundingVolume
determines if this bounding volume and a given bounding sphere are intersecting.

Specified by:
intersectsSphere in interface BoundingVolume
Parameters:
bs - the bounding sphere to test against.
Returns:
true if this volume intersects the given bounding sphere.

intersectsBoundingBox

public boolean intersectsBoundingBox(BoundingBox bb)
Description copied from interface: BoundingVolume
determines if this bounding volume and a given bounding box are intersecting.

Specified by:
intersectsBoundingBox in interface BoundingVolume
Parameters:
bb - the bounding box to test against.
Returns:
true if this volume intersects the given bounding box.

intersectsOrientedBoundingBox

public boolean intersectsOrientedBoundingBox(OrientedBoundingBox obb)
Description copied from interface: BoundingVolume
determines if this bounding volume and a given oriented bounding box are intersecting.

Specified by:
intersectsOrientedBoundingBox in interface BoundingVolume
Parameters:
obb - the bounding box to test against.
Returns:
true if this volume intersects the given oriented bounding box.

intersectsOBB2

public boolean intersectsOBB2(OBB2 obb)
Description copied from interface: BoundingVolume
determines if this bounding volume and a given oriented bounding box are intersecting.

Specified by:
intersectsOBB2 in interface BoundingVolume
Parameters:
obb - the bounding box to test against.
Returns:
true if this volume intersects the given oriented bounding box.

intersects

public boolean intersects(Ray ray)
Description copied from interface: BoundingVolume
determines if a ray intersects this bounding volume.

Specified by:
intersects in interface BoundingVolume
Parameters:
ray - the ray to test.
Returns:
true if this volume is intersected by a given ray.