com.jme.scene.shape
Class Box

java.lang.Object
  extended bycom.jme.scene.Spatial
      extended bycom.jme.scene.Geometry
          extended bycom.jme.scene.TriMesh
              extended bycom.jme.scene.shape.Box
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BoundingBox

public class Box
extends TriMesh

Box provides an extension of TriMesh. A Box is defined by a minimal point and a maximum point. The eight vertices that make the box are then computed. They are computed in such a way as to generate an axis-aligned box.

Version:
$Id: Box.java,v 1.10 2004/11/13 01:23:31 cep21 Exp $
Author:
Mark Powell
See Also:
Serialized Form

Field Summary
static Vector3f AXIS_X
           
static Vector3f AXIS_Y
           
static Vector3f AXIS_Z
           
 Vector3f center
           
 float xExtent
           
 float yExtent
           
 float zExtent
           
 
Fields inherited from class com.jme.scene.TriMesh
indices, triangleQuantity
 
Fields inherited from class com.jme.scene.Geometry
bound, color, colorBuf, normal, normBuf, texBuf, texture, vertBuf, vertex, vertQuantity
 
Fields inherited from class com.jme.scene.Spatial
currentStates, defaultStateList, forceCull, forceView, frustrumIntersects, geometricalControllers, lightCombineMode, localRotation, localScale, localTranslation, name, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
Box()
          instantiates a new Box object.
Box(java.lang.String name)
          Constructor instantiates a new Box object.
Box(java.lang.String name, Vector3f center, float xExtent, float yExtent, float zExtent)
          Constructs a new box.
Box(java.lang.String name, Vector3f min, Vector3f max)
          Constructor instantiates a new Box object.
 
Method Summary
 java.lang.Object clone()
          clone creates a new Box object containing the same data as this one.
 Vector3f[] computeVertices()
           
 Vector3f getCenter()
          Returns the current center of the box.
 void setCenter(Vector3f aCenter)
          Sets the center of the box.
 void setData(Vector3f center, float xExtent, float yExtent, float zExtent, boolean updateBuffers)
          Changes the data of the box so that its center is center and it extends in the x, y, and z directions by the given extent.
 void setData(Vector3f minPoint, Vector3f maxPoint, boolean updateBuffers)
          Changes the data of the box so that the two opposite corners are minPoint and maxPoint.
 
Methods inherited from class com.jme.scene.TriMesh
clearBuffers, draw, drawBounds, findCollisions, findTriangleCollision, findTrianglePick, findWorldRotMat, getIndexAsBuffer, getIndices, getMeshAsTriangles, getTriangle, getTriangle, getTriangleQuantity, hasCollision, hasTriangleCollision, putClone, reconstruct, setIndexBuffer, setIndices, updateCollisionTree, updateIndexBuffer
 
Methods inherited from class com.jme.scene.Geometry
applyRenderState, applyStates, copyTextureCoords, findPick, getAllTextures, getCloneID, getColorAsFloatBuffer, getColors, getModelBound, getNormalAsFloatBuffer, getNormals, getNumberOfUnits, getTextureAsFloatBuffer, getTextureAsFloatBuffer, getTextures, getTextures, getVBOColorID, getVBONormalID, getVBOTextureID, getVBOVertexID, getVerticeAsFloatBuffer, getVertices, getVertQuantity, isVBOColorEnabled, isVBONormalEnabled, isVBOTextureEnabled, isVBOVertexEnabled, randomVertice, reconstruct, setAllTextures, setColor, setColors, setFloatBuffer, setForceView, setModelBound, setNormal, setNormalBuffer, setNormals, setRandomColors, setSolidColor, setTexture, setTexture, setTextureBuffer, setTextureCoord, setTextures, setTextures, setVBOColorEnabled, setVBOColorID, setVBONormalEnabled, setVBONormalID, setVBOTextureEnabled, setVBOTextureID, setVBOVertexEnabled, setVBOVertexID, setVertex, setVertexBuffer, setVertices, updateColorBuffer, updateColorBuffer, updateModelBound, updateNormalBuffer, updateNormalBuffer, updateTextureBuffer, updateTextureBuffer, updateTextureBuffer, updateVertexBuffer, updateVertexBuffer, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, applyDefaultStates, calculateCollisions, calculatePick, clearCurrentState, clearCurrentStates, clearRenderState, getController, getControllers, getCurrentState, getLastFrustumIntersection, getLightCombineMode, getLocalRotation, getLocalScale, getLocalTranslation, getName, getParent, getRenderQueueMode, getRenderStateList, getTextureCombineMode, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, isForceCulled, isForceView, onDraw, onDrawBounds, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeFromParent, setForceCull, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setName, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setWorldBound, setZOrder, toString, updateGeometricState, updateRenderState, updateRenderState, updateWorldData
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

xExtent

public float xExtent

yExtent

public float yExtent

zExtent

public float zExtent

center

public final Vector3f center

AXIS_X

public static final Vector3f AXIS_X

AXIS_Y

public static final Vector3f AXIS_Y

AXIS_Z

public static final Vector3f AXIS_Z
Constructor Detail

Box

public Box()
instantiates a new Box object. All information must be applies later. For internal usage only


Box

public Box(java.lang.String name)
Constructor instantiates a new Box object. Center and vertice information must be supplied later.

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.

Box

public Box(java.lang.String name,
           Vector3f min,
           Vector3f max)
Constructor instantiates a new Box object. The minimum and maximum point are provided. These two points define the shape and size of the box, but not it's orientation or position. You should use the setLocalTranslation and setLocalRotation for those attributes.

Parameters:
name - the name of the scene element. This is required for identification and comparision purposes.
min - the minimum point that defines the box.
max - the maximum point that defines the box.

Box

public Box(java.lang.String name,
           Vector3f center,
           float xExtent,
           float yExtent,
           float zExtent)
Constructs a new box. The box has the given center and extends in the x, y, and z out from the center (+ and -) by the given amounts. So, for example, a box with extent of .5 would be the unit cube.

Parameters:
name - Name of the box.
center - Center of the box.
xExtent - x extent of the box, in both directions.
yExtent - y extent of the box, in both directions.
zExtent - z extent of the box, in both directions.
Method Detail

setData

public void setData(Vector3f minPoint,
                    Vector3f maxPoint,
                    boolean updateBuffers)
Changes the data of the box so that the two opposite corners are minPoint and maxPoint. The other corners are created from those two poitns. If update buffers is flagged as true, the vertex/normal/texture/color/index buffers are updated when the data is changed.

Parameters:
minPoint - The new minPoint of the box.
maxPoint - The new maxPoint of the box.
updateBuffers - If true, buffers are updated.

setData

public void setData(Vector3f center,
                    float xExtent,
                    float yExtent,
                    float zExtent,
                    boolean updateBuffers)
Changes the data of the box so that its center is center and it extends in the x, y, and z directions by the given extent. Note that the actual sides will be 2x the given extent values because the box extends in + & - from the center for each extent.

Parameters:
center - The center of the box.
xExtent - x extent of the box, in both directions.
yExtent - y extent of the box, in both directions.
zExtent - z extent of the box, in both directions.
updateBuffers - If true, buffers are updated.

clone

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

Returns:
the new Box

computeVertices

public Vector3f[] computeVertices()
Returns:
a size 8 array of Vectors representing the 8 points of the box.

getCenter

public Vector3f getCenter()
Returns the current center of the box.

Returns:
The box's center.

setCenter

public void setCenter(Vector3f aCenter)
Sets the center of the box. Note that even though the center is set, Geometry information is not updated. In most cases, you'll want to use setData()

Parameters:
aCenter - The new center.