Package com.jme3.math

Class Triangle

java.lang.Object
com.jme3.math.Triangle

public class Triangle extends Object
Describes a triangle in terms of its vertex locations, with auxiliary storage for its normal vector.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiate a zero-size triangle at the origin.
    Instantiates a triangle with the specified vertex locations.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Recalculates the stored normal based on the current vertex locations.
    get(int i)
    Accesses the location of the indexed vertex.
    Accesses the location of the first vertex.
    Accesses the location of the 2nd vertex.
    Accesses the location of the 3rd vertex.
    Accesses the stored normal, updating it if it is null.
    void
    set(int i, Vector3f point)
    Alters the location of the indexed vertex and deletes the stored normal.
    void
    set(Vector3f v1, Vector3f v2, Vector3f v3)
    Alters the locations of all 3 vertices and deletes the stored normal.
    void
    Alters the location of the first vertex and deletes the stored normal.
    void
    Alters the location of the 2nd vertex and deletes the stored normal.
    void
    Alters the location of the 3rd vertex and deletes the stored normal.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Triangle

      public Triangle()
      Instantiate a zero-size triangle at the origin.
    • Triangle

      public Triangle(Vector3f p1, Vector3f p2, Vector3f p3)
      Instantiates a triangle with the specified vertex locations. Vertices should be listed in the desired winding order, typically counter-clockwise.
      Parameters:
      p1 - the location of the first vertex (not null, unaffected)
      p2 - the location of the 2nd vertex (not null, unaffected)
      p3 - the location of the 3rd vertex (not null, unaffected)
  • Method Details

    • get

      public Vector3f get(int i)
      Accesses the location of the indexed vertex.
      Parameters:
      i - the index of the vertex to access (0, 1, or 2)
      Returns:
      a pre-existing location vector, or null if the index is invalid
    • get1

      public Vector3f get1()
      Accesses the location of the first vertex.
      Returns:
      the pre-existing location vector (not null)
    • get2

      public Vector3f get2()
      Accesses the location of the 2nd vertex.
      Returns:
      the pre-existing location vector (not null)
    • get3

      public Vector3f get3()
      Accesses the location of the 3rd vertex.
      Returns:
      the pre-existing location vector (not null)
    • set

      public void set(int i, Vector3f point)
      Alters the location of the indexed vertex and deletes the stored normal.
      Parameters:
      i - the index of the vertex to alter (0, 1, or 2)
      point - the desired location (not null, unaffected)
    • set1

      public void set1(Vector3f v)
      Alters the location of the first vertex and deletes the stored normal.
      Parameters:
      v - the desired location (not null, unaffected)
    • set2

      public void set2(Vector3f v)
      Alters the location of the 2nd vertex and deletes the stored normal.
      Parameters:
      v - the desired location (not null, unaffected)
    • set3

      public void set3(Vector3f v)
      Alters the location of the 3rd vertex and deletes the stored normal.
      Parameters:
      v - the desired location (not null, unaffected)
    • set

      public void set(Vector3f v1, Vector3f v2, Vector3f v3)
      Alters the locations of all 3 vertices and deletes the stored normal.
      Parameters:
      v1 - the desired location of the first vertex (not null, unaffected)
      v2 - the desired location of the 2nd vertex (not null, unaffected)
      v3 - the desired location of the 3rd vertex (not null, unaffected)
    • calculateNormal

      public void calculateNormal()
      Recalculates the stored normal based on the current vertex locations.
    • getNormal

      public Vector3f getNormal()
      Accesses the stored normal, updating it if it is null.
      Returns:
      unit normal vector (an internal vector subject to re-use)