Class RectangleMesh

All Implemented Interfaces:
Savable, JmeCloneable, Cloneable

public class RectangleMesh extends Mesh
A static, indexed, Triangle-mode mesh that renders a rectangle or parallelogram, with customizable normals and texture coordinates.

It uses a Rectangle to locate its vertices, which are named as follows:

     C +----+ D
       |\   |
       | \  |
       |  \ |
       |   \|
     A +----+ B

In the vertex buffers, the order of the vertices is A, B, D, then C.

The default texture coordinates have:

  • U=0 at vertices A and C
  • U=1 at vertices B and D
  • V=0 at vertices A and B
  • V=1 at vertices C and D
  • Constructor Details

    • RectangleMesh

      public RectangleMesh()
      Instantiates a unit-square mesh in the X-Y plane, centered at (0.5, 0.5), with normals in the +Z direction.
    • RectangleMesh

      public RectangleMesh(Rectangle rectangle)
      Instantiates a rectangle or parallelogram mesh based on the specified Rectangle.
      rectangle - to locate the vertices and set the normals (not null, alias created)
    • RectangleMesh

      public RectangleMesh(Vector3f a, Vector3f b, Vector3f c)
      Instantiates a rectangle or parallelogram mesh based on 3 specified vertex positions.
      a - the mesh position of vertex A (not null, alias created)
      b - the mesh position of vertex B (not null, alias created)
      c - the mesh position of vertex C (not null, alias created)
  • Method Details

    • getRectangle

      public Rectangle getRectangle()
      Provides access to the internal Rectangle on which the mesh is based.
      the pre-existing instance (do not modify!)
    • setRectangle

      public void setRectangle(Rectangle rectangle)
      Sets the Rectangle and updates the mesh accordingly.
      rectangle - the desired Rectangle (not null, alias created)
    • getTexCoords

      public Vector2f[] getTexCoords()
      Provides access to the internal texture-coordinate array.
      the pre-existing array of length 4 (do not modify!)
    • setTexCoords

      public void setTexCoords(Vector2f[] texCoords) throws IllegalArgumentException
      Sets the texture coordinates and updates the mesh accordingly.
      texCoords - the desired texture coordinates for each vertex (not null, alias created)
      IllegalArgumentException - if the array length isn't exactly 4
    • getNormal

      public Vector3f getNormal()
      Provides access to the internal normal-direction vector.
      the pre-existing vector (do not modify!)
    • flip

      public void flip()
      Flips this mesh by reversing its normal vector direction and setting the flipped variable accordingly. This variable will be used by the updateMesh() method to rearrange the index buffer.
    • updateMesh

      protected void updateMesh()
    • cloneFields

      public void cloneFields(Cloner cloner, Object original)
      Called internally by com.jme3.util.clone.Cloner. Do not call directly.
      Specified by:
      cloneFields in interface JmeCloneable
      cloneFields in class Mesh
      cloner - The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.
      original - The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
    • read

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

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