Class AbstractBox

java.lang.Object
com.jme3.scene.Mesh
com.jme3.scene.shape.AbstractBox
All Implemented Interfaces:
Savable, JmeCloneable, Cloneable
Direct Known Subclasses:
Box, StripBox

public abstract class AbstractBox extends Mesh
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 for that.

  • Field Details

    • center

      public final Vector3f center
    • xExtent

      public float xExtent
    • yExtent

      public float yExtent
    • zExtent

      public float zExtent
  • Constructor Details

    • AbstractBox

      public AbstractBox()
  • Method Details

    • computeVertices

      protected final Vector3f[] 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

      public final Vector3f 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

      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 direction.
      y - the Y extent of the box in each direction.
      z - the Z extent of the box in each direction.
    • 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.
    • read

      public void read(JmeImporter importer) throws IOException
      Specified by:
      read in interface Savable
      Overrides:
      read in class Mesh
      Throws:
      IOException
    • write

      public void write(JmeExporter e) throws IOException
      Specified by:
      write in interface Savable
      Overrides:
      write in class Mesh
      Throws:
      IOException