Package snap.gfx3d

Class Polygon3D

All Implemented Interfaces:
Cloneable, PropChange.DoChange

public class Polygon3D extends FacetShape implements Cloneable
This class represents a polygon surface in 3D space.
  • Field Details

  • Constructor Details

    • Polygon3D

      public Polygon3D()
      Constructor.
  • Method Details

    • getPointArray

      public float[] getPointArray()
      Returns the vertex points components array.
    • getPointCount

      public int getPointCount()
      Returns the number of vertex points in array.
      Specified by:
      getPointCount in class FacetShape
    • getPoint

      public Point3D getPoint(int anIndex)
      Returns the Point3D at index.
      Specified by:
      getPoint in class FacetShape
    • getPoint

      public Point3D getPoint(Point3D aPoint, int anIndex)
      Returns the Point3D at index.
    • setPointXYZ

      public void setPointXYZ(int anIndex, double aX, double aY, double aZ)
      Returns the Point3D at index.
    • addPoint

      public void addPoint(double aVal1, double aVal2, double aVal3)
      Adds value triplet to array.
    • isTexCoordArraySet

      public boolean isTexCoordArraySet()
      Returns whether texture coords array is set.
    • getTexCoordArray

      public float[] getTexCoordArray()
      Returns the vertex texture coords array.
    • addTexCoord

      public void addTexCoord(double aU, double aV)
      Adds a texture coord to vertex texture coords array.
    • createNormal

      protected Vector3D createNormal()
      Returns the normal of the path3d. Right hand rule for clockwise/counter-clockwise defined polygons.
      Specified by:
      createNormal in class FacetShape
    • getShape2D

      public Shape getShape2D()
      Returns the 2D shape for the path3d (should only be called when path is facing Z).
      Specified by:
      getShape2D in class FacetShape
    • createTriangleArray

      protected VertexArray createTriangleArray()
      Creates a VertexArray of path triangles.
      Overrides:
      createTriangleArray in class FacetShape
    • getIndexArrayForTrianglePoints

      protected int[] getIndexArrayForTrianglePoints()
      Returns the array of indexes to points for triangles from polygon points.
    • getStrokeTriangleArray

      protected VertexArray getStrokeTriangleArray()
      Returns a VertexArray for path stroke.
      Overrides:
      getStrokeTriangleArray in class FacetShape
    • transformBy

      public void transformBy(Matrix3D xform)
      Transforms the path by the given transform matrix.
    • copyForMatrix

      public Polygon3D copyForMatrix(Matrix3D aTrans)
      Copies path for given transform matrix.
      Specified by:
      copyForMatrix in class FacetShape
    • reverse

      public void reverse()
      Reverses the polygon points.
      Specified by:
      reverse in class FacetShape
    • trim

      public void trim()
      Trims arrays.
    • createBounds3D

      protected Bounds3D createBounds3D()
      Returns the bounds.
      Specified by:
      createBounds3D in class Shape3D
    • clone

      public Polygon3D clone()
      Standard clone implementation.
      Overrides:
      clone in class FacetShape
    • toStringProps

      public String toStringProps()
      Standard toStringProps implementation.
      Overrides:
      toStringProps in class Shape3D
    • createFromShape

      public static Polygon3D createFromShape(Shape aShape, double aDepth)
      Creates a polygon from a given simple path. If Path has multiple MoveTos, this will return first polygon and complain.