Package snap.gfx3d
Class Polygon3D
java.lang.Object
snap.props.PropObject
snap.gfx3d.Shape3D
snap.gfx3d.FacetShape
snap.gfx3d.Polygon3D
- All Implemented Interfaces:
Cloneable
,PropChange.DoChange
This class represents a polygon surface in 3D space.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
PathIter for PointArray. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
Fields inherited from class snap.gfx3d.FacetShape
_triangleArray
Fields inherited from class snap.gfx3d.Shape3D
_smoothSides
Fields inherited from class snap.props.PropObject
_pcs, EMPTY_OBJECT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPoint
(double aVal1, double aVal2, double aVal3) Adds value triplet to array.void
addTexCoord
(double aU, double aV) Adds a texture coord to vertex texture coords array.clone()
Standard clone implementation.copyForMatrix
(Matrix3D aTrans) Copies path for given transform matrix.protected Bounds3D
Returns the bounds.static Polygon3D
createFromShape
(Shape aShape, double aDepth) Creates a polygon from a given simple path.protected Vector3D
Returns the normal of the path3d.protected VertexArray
Creates a VertexArray of path triangles.protected int[]
Returns the array of indexes to points for triangles from polygon points.getPoint
(int anIndex) Returns the Point3D at index.Returns the Point3D at index.float[]
Returns the vertex points components array.int
Returns the number of vertex points in array.Returns the 2D shape for the path3d (should only be called when path is facing Z).protected VertexArray
Returns a VertexArray for path stroke.float[]
Returns the vertex texture coords array.boolean
Returns whether texture coords array is set.void
reverse()
Reverses the polygon points.void
setPointXYZ
(int anIndex, double aX, double aY, double aZ) Returns the Point3D at index.Standard toStringProps implementation.void
transformBy
(Matrix3D xform) Transforms the path by the given transform matrix.void
trim()
Trims arrays.Methods inherited from class snap.gfx3d.FacetShape
clearCachedValues, createVertexArrays, getNormal, getPainter, getPainterToLocal, getPainterVertexArray, getTexture, getTransformToAlignToVector, getTriangleArray, setPainter, setTexture
Methods inherited from class snap.gfx3d.Shape3D
getBounds3D, getBoundsCenter, getColor, getMaxX, getMaxY, getMaxZ, getMinX, getMinY, getMinZ, getName, getOpacity, getParent, getStroke, getStrokeColor, isDoubleSided, isVisible, setBounds3D, setColor, setDoubleSided, setName, setOpacity, setParent, setSmoothSides, setStroke, setStroke, setStrokeColor, setVisible
Methods inherited from class snap.props.PropObject
addDeepChangeListener, addPropChangeListener, addPropChangeListener, firePropChange, firePropChange, firePropChange, getPropDefault, getPropForName, getPropParent, getPropSet, getPropsForArchival, getPropsForArchivalExtra, getPropsString, getPropValue, initProps, isPropDefault, processPropChange, removeDeepChangeListener, removePropChangeListener, removePropChangeListener, setPropsString, setPropValue, setPropValues, toString
-
Field Details
-
POINT_COMP_COUNT
public static final int POINT_COMP_COUNT- See Also:
-
TEX_COORD_COMP_COUNT
public static final int TEX_COORD_COMP_COUNT- See Also:
-
-
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 classFacetShape
-
getPoint
Returns the Point3D at index.- Specified by:
getPoint
in classFacetShape
-
getPoint
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
Returns the normal of the path3d. Right hand rule for clockwise/counter-clockwise defined polygons.- Specified by:
createNormal
in classFacetShape
-
getShape2D
Returns the 2D shape for the path3d (should only be called when path is facing Z).- Specified by:
getShape2D
in classFacetShape
-
createTriangleArray
Creates a VertexArray of path triangles.- Overrides:
createTriangleArray
in classFacetShape
-
getIndexArrayForTrianglePoints
protected int[] getIndexArrayForTrianglePoints()Returns the array of indexes to points for triangles from polygon points. -
getStrokeTriangleArray
Returns a VertexArray for path stroke.- Overrides:
getStrokeTriangleArray
in classFacetShape
-
transformBy
Transforms the path by the given transform matrix. -
copyForMatrix
Copies path for given transform matrix.- Specified by:
copyForMatrix
in classFacetShape
-
reverse
public void reverse()Reverses the polygon points.- Specified by:
reverse
in classFacetShape
-
trim
public void trim()Trims arrays. -
createBounds3D
Returns the bounds.- Specified by:
createBounds3D
in classShape3D
-
clone
Standard clone implementation.- Overrides:
clone
in classFacetShape
-
toStringProps
Standard toStringProps implementation.- Overrides:
toStringProps
in classShape3D
-
createFromShape
Creates a polygon from a given simple path. If Path has multiple MoveTos, this will return first polygon and complain.
-