Class AbstractBox
- All Implemented Interfaces:
Savable
,JmeCloneable
,Cloneable
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
for that.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final Vector3f[]
Gets the array or vectors representing the 8 vertices of the box.protected abstract void
Convert the indices into the list of vertices that define the box's geometry.protected abstract void
Update the normals of each of the box's planes.protected abstract void
Update the points that define the texture of the box.protected abstract void
Update the position of the vertices that define the box.final Vector3f
Get the center point of this box.final float
Get the x-axis size (extent) of this box.final float
Get the y-axis size (extent) of this box.final float
Get the z-axis size (extent) of this box.void
read
(JmeImporter importer) final void
Rebuilds the box after a property has been directly altered.final void
updateGeometry
(Vector3f center, float x, float y, float z) Rebuilds this box based on a new set of parameters.final 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.jme3.scene.Mesh
addMorphTarget, clearBuffer, clearCollisionData, clone, cloneFields, cloneForAnim, collideWith, createCollisionData, deepClone, extractVertexData, generateBindPose, generateBindPose, getBound, getBuffer, getBufferList, getBuffers, getElementLengths, getFloatBuffer, getId, getIndexBuffer, getIndicesAsList, getInstanceCount, getLineWidth, getLodLevel, getMaxNumWeights, getMode, getModeStart, getMorphIndex, getMorphTarget, getMorphTargetNames, getMorphTargets, getNumLodLevels, getPatchVertexCount, getPointSize, getShortBuffer, getTriangle, getTriangle, getTriangle, getTriangleCount, getTriangleCount, getVertexCount, hasMorphTargets, isAnimated, isAnimatedByBone, isAnimatedByJoint, jmeClone, prepareForAnim, removeMorphTarget, removeMorphTarget, scaleTextureCoordinates, setBound, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setBuffer, setDynamic, setElementLengths, setId, setInterleaved, setLineWidth, setLodLevels, setMaxNumWeights, setMode, setModeStart, setPatchVertexCount, setStatic, setStreamed, updateBound, updateCounts
-
Field Details
-
center
-
xExtent
public float xExtent -
yExtent
public float yExtent -
zExtent
public float zExtent
-
-
Constructor Details
-
AbstractBox
public AbstractBox()
-
-
Method Details
-
computeVertices
Gets the array or vectors representing the 8 vertices of the box.- Returns:
- a newly created array of vertex vectors.
-
doUpdateGeometryIndices
protected abstract void doUpdateGeometryIndices()Convert the indices into the list of vertices that define the box's geometry. -
doUpdateGeometryNormals
protected abstract void doUpdateGeometryNormals()Update the normals of each of the box's planes. -
doUpdateGeometryTextures
protected abstract void doUpdateGeometryTextures()Update the points that define the texture of the box.It's a one-to-one ratio, where each plane of the box has its own copy of the texture. That is, the texture is repeated one time for each face.
-
doUpdateGeometryVertices
protected abstract void doUpdateGeometryVertices()Update the position of the vertices that define the box.These eight points are determined from the minimum and maximum point.
-
getCenter
Get the center point of this box.- Returns:
- the pre-existing location vector (in mesh coordinates)
-
getXExtent
public final float getXExtent()Get the x-axis size (extent) of this box.- Returns:
- the radius parallel to the X axis (in mesh units)
-
getYExtent
public final float getYExtent()Get the y-axis size (extent) of this box.- Returns:
- the radius parallel to the Y axis (in mesh units)
-
getZExtent
public final float getZExtent()Get the z-axis size (extent) of this box.- Returns:
- the radius parallel to the Z axis (in mesh units)
-
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
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 direction.y
- the Y extent of the box in each direction.z
- the Z extent of the box in each direction.
-
updateGeometry
Rebuilds this box based on a new set of parameters.The box is updated so that the two opposite corners are
minPoint
andmaxPoint
, 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.
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classMesh
- Throws:
IOException
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classMesh
- Throws:
IOException
-