com.jme.scene.shape
Class AbstractBox

java.lang.Object
  extended by com.jme.scene.Spatial
      extended by com.jme.scene.Geometry
          extended by com.jme.scene.TriMesh
              extended by com.jme.scene.shape.AbstractBox
All Implemented Interfaces:
Savable, java.io.Serializable
Direct Known Subclasses:
Box, StripBox

public abstract class AbstractBox
extends TriMesh
implements Savable

An eight sided box.

A Box is defined by a minimal point and a maximal 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.

This class does not control how the geometry data is generated, see Box and StripBox for that.

Version:
$Revision: 4131 $, $Date: 2009-03-19 20:15:28 +0000 (Thu, 19 Mar 2009) $
Author:
Ian Phillips
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jme.scene.TriMesh
TriMesh.Mode
 
Nested classes/interfaces inherited from class com.jme.scene.Spatial
Spatial.CullHint, Spatial.LightCombineMode, Spatial.NormalsMode, Spatial.TextureCombineMode
 
Field Summary
 Vector3f center
           
 float xExtent
           
 float yExtent
           
 float zExtent
           
 
Fields inherited from class com.jme.scene.TriMesh
indexBuffer, mode, triangleQuantity
 
Fields inherited from class com.jme.scene.Geometry
binormalBuf, bound, castsShadows, colorBuf, compVect, defaultColor, displayListID, enabled, fogBuf, hasDirtyVertices, normBuf, states, tangentBuf, texBuf, vboInfo, vertBuf, vertQuantity
 
Fields inherited from class com.jme.scene.Spatial
cullHint, frustrumIntersects, geometricalControllers, isCollidable, lightCombineMode, localRotation, localScale, localTranslation, LOCKED_BOUNDS, LOCKED_BRANCH, LOCKED_MESH_DATA, LOCKED_NONE, LOCKED_SHADOWS, LOCKED_TRANSFORMS, lockedMode, name, normalsMode, parent, queueDistance, renderQueueMode, renderStateList, textureCombineMode, worldBound, worldRotation, worldScale, worldTranslation, zOrder
 
Constructor Summary
AbstractBox(java.lang.String name)
           
 
Method Summary
 Vector3f[] computeVertices()
          Deprecated. method will be made protected.
protected abstract  void duUpdateGeometryIndices()
          Convert the indices into the list of vertices that define the box's tri-mesh.
protected abstract  void duUpdateGeometryNormals()
          Update the normals of each of the box's planes.
protected abstract  void duUpdateGeometryTextures()
          Update the points that define the texture of the box.
protected abstract  void duUpdateGeometryVertices()
          Update the position of the vertices that define the box.
 Vector3f getCenter()
          Get the centre point of this box.
 float getXExtent()
          Get the x-axis size (extent) of this box.
 float getYExtent()
          Get the y-axis size (extent) of this box.
 float getZExtent()
          Get the z-axis size (extent) of this box.
 void read(JMEImporter e)
           
 void setCenter(Vector3f center)
          Deprecated. use updateGeometry(Vector3f, float, float, float).
 void setData(Vector3f center, float x, float y, float z)
          Deprecated. use updateGeometry(Vector3f, float, float, float).
 void setData(Vector3f minPoint, Vector3f maxPoint)
          Deprecated. use updateGeometry(Vector3f, Vector3f).
 void updateGeometry()
          Rebuilds the box after a property has been directly altered.
 void updateGeometry(Vector3f center, float x, float y, float z)
          Rebuilds this box based on a new set of parameters.
 void updateGeometry(Vector3f minPoint, Vector3f maxPoint)
          Rebuilds this box based on a new set of parameters.
 void write(JMEExporter e)
           
 
Methods inherited from class com.jme.scene.TriMesh
clearBuffers, draw, findCollisions, findTriangleCollision, findTrianglePick, getIndexBuffer, getMaxIndex, getMeshAsTriangles, getMeshAsTrianglesVertices, getMode, getTriangle, getTriangle, getTriangleCount, getTriangleIndices, getVertIndex, hasCollision, hasTriangleCollision, randomPointOnTriangles, recalcTriangleQuantity, reconstruct, setIndexBuffer, setMode, setTriangleQuantity
 
Methods inherited from class com.jme.scene.Geometry
addTextureCoordinates, addTextureCoordinates, applyRenderState, checkTextureCoordinates, clearTextureBuffers, copyTextureCoordinates, copyTextureCoordinates, findPick, getBinormalBuffer, getColorBuffer, getDefaultColor, getDisplayListID, getFogBuffer, getLightState, getModelBound, getNormalBuffer, getNumberOfUnits, getTangentBuffer, getTextureCoords, getTextureCoords, getVBOInfo, getVertexBuffer, getVertexCount, getWorldCoords, getWorldNormals, hasDirtyVertices, isCastsShadows, lockMeshes, postdraw, predraw, randomVertex, reconstruct, resizeTextureIds, rotateNormals, rotatePoints, scaleTextureCoordinates, scaleTextureCoordinates, setBinormalBuffer, setCastsShadows, setColorBuffer, setDefaultColor, setDisplayListID, setFogCoordBuffer, setHasDirtyVertices, setLightState, setModelBound, setNormalBuffer, setRandomColors, setSolidColor, setTangentBuffer, setTextureCoords, setTextureCoords, setTextureCoords, setVBOInfo, setVertexBuffer, setVertexCount, sortLights, translatePoints, translatePoints, unlockMeshes, updateModelBound, updateWorldBound
 
Methods inherited from class com.jme.scene.Spatial
addController, calculateCollisions, calculatePick, clearControllers, clearRenderState, clearRenderState, getClassTag, getController, getControllerCount, getControllers, getCullHint, getLastFrustumIntersection, getLightCombineMode, getLocalCullHint, getLocalLightCombineMode, getLocalNormalsMode, getLocalRenderQueueMode, getLocalRotation, getLocalScale, getLocalTextureCombineMode, getLocalToWorldMatrix, getLocalTranslation, getLocks, getName, getNormalsMode, getParent, getRenderQueueMode, getRenderState, getRenderState, getTextureCombineMode, getUserData, getWorldBound, getWorldRotation, getWorldScale, getWorldTranslation, getZOrder, hasAncestor, isCollidable, localToWorld, lock, lock, lockBounds, lockBranch, lockMeshes, lockShadows, lockTransforms, lookAt, onDraw, propagateBoundToRoot, propagateStatesFromRoot, removeController, removeController, removeFromParent, removeUserData, rotateUpTo, setCullHint, setIsCollidable, setLastFrustumIntersection, setLightCombineMode, setLocalRotation, setLocalRotation, setLocalScale, setLocalScale, setLocalTranslation, setLocalTranslation, setLocks, setLocks, setName, setNormalsMode, setParent, setRenderQueueMode, setRenderState, setTextureCombineMode, setUserData, setZOrder, setZOrder, toString, unlock, unlock, unlockBounds, unlockBranch, unlockMeshes, unlockShadows, unlockTransforms, updateGeometricState, updateRenderState, updateRenderState, updateWorldData, updateWorldRotation, updateWorldScale, updateWorldTranslation, updateWorldVectors, updateWorldVectors, worldToLocal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jme.util.export.Savable
getClassTag
 

Field Detail

center

public final Vector3f center

xExtent

public float xExtent

yExtent

public float yExtent

zExtent

public float zExtent
Constructor Detail

AbstractBox

public AbstractBox(java.lang.String name)
Method Detail

computeVertices

public final Vector3f[] computeVertices()
Deprecated. method will be made protected.

Gets the array or vectors representing the 8 vertices of the box.

Returns:
a newly created array of vertex vectors.

duUpdateGeometryIndices

protected abstract void duUpdateGeometryIndices()
Convert the indices into the list of vertices that define the box's tri-mesh.


duUpdateGeometryNormals

protected abstract void duUpdateGeometryNormals()
Update the normals of each of the box's planes.


duUpdateGeometryTextures

protected abstract void duUpdateGeometryTextures()
Update the points that define the texture of the box.

It's a one-to-one ratio, where each plane of the box has it's own copy of the texture. That is, the texture is repeated one time for each face.


duUpdateGeometryVertices

protected abstract void duUpdateGeometryVertices()
Update the position of the vertices that define the box.

These eight points are determined from the minimum and maximum point.


getCenter

public final Vector3f getCenter()
Get the centre point of this box.


getXExtent

public final float getXExtent()
Get the x-axis size (extent) of this box.


getYExtent

public final float getYExtent()
Get the y-axis size (extent) of this box.


getZExtent

public final float getZExtent()
Get the z-axis size (extent) of this box.


read

public void read(JMEImporter e)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class TriMesh
Throws:
java.io.IOException

setCenter

public final void setCenter(Vector3f center)
Deprecated. use updateGeometry(Vector3f, float, float, float).

Set the centre point of this box.

Note that this does not update the geometry information, in most cases you will want to use setData(Vector3f, float, float, float) instead.

Parameters:
center - the new center.

setData

public final void setData(Vector3f center,
                          float x,
                          float y,
                          float z)
Deprecated. use updateGeometry(Vector3f, float, float, float).


setData

public final void setData(Vector3f minPoint,
                          Vector3f maxPoint)
Deprecated. use updateGeometry(Vector3f, Vector3f).


updateGeometry

public final void updateGeometry()
Rebuilds the box after a property has been directly altered.

For example, if you call getXExtent().x = 5.0f then you will need to call this method afterwards in order to update the box.


updateGeometry

public final void updateGeometry(Vector3f center,
                                 float x,
                                 float y,
                                 float z)
Rebuilds this box based on a new set of parameters.

Note that the actual sides will be twice the given extent values because the box extends in both directions from the center for each extent.

Parameters:
center - the center of the box.
x - the x extent of the box, in each directions.
y - the y extent of the box, in each directions.
z - the z extent of the box, in each directions.

updateGeometry

public final void updateGeometry(Vector3f minPoint,
                                 Vector3f maxPoint)
Rebuilds this box based on a new set of parameters.

The box is updated so that the two opposite corners are minPoint and maxPoint, the other corners are created from those two positions.

Parameters:
minPoint - the new minimum point of the box.
maxPoint - the new maximum point of the box.

write

public void write(JMEExporter e)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class TriMesh
Throws:
java.io.IOException