Polygon2D
Draws a polygon with color, texture and optional bone skinning.
Polygon2D stores vertices in local coordinates. UV uses texture pixels. For a subdivided mesh, Polygons contains the indices of its parts; InternalVertexCount marks internal vertices.
For skinning, assign Skeleton and add weights with AddBone(). The skeleton path is relative to the polygon; a bone path is relative to the skeleton. Rendering uses the four largest weights per vertex and normalizes them. Visible skinning does not overwrite the Polygon array.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
Polygon2DConstructor
public Polygon2D();Properties16
AntialiasedProperty
public bool Antialiased { get; set; }If true, polygon edges will be anti-aliased.
BonesProperty
public Reckfell.Collections.Array Bones { get; set; }ColorProperty
public Color Color { get; set; }The polygon's fill color. If Polygon2D.Texture is set, it will be multiplied by this color. It will also be the default color for vertices not set in Polygon2D.VertexColors.
InternalVertexCountProperty
public int InternalVertexCount { get; set; }Number of internal vertices, used for UV mapping.
InvertBorderProperty
public float InvertBorder { get; set; }Added padding applied to the bounding box when Polygon2D.InvertEnabled is set to true. Setting this value too small may result in a "Bad Polygon" error.
InvertEnabledProperty
public bool InvertEnabled { get; set; }If true, the polygon will be inverted, containing the area outside the defined points and extending to the Polygon2D.InvertBorder.
OffsetProperty
public Vector2 Offset { get; set; }The offset applied to each vertex.
PolygonProperty
public Vector2[] Polygon { get; set; }The polygon's list of vertices. The final point will be connected to the first.
PolygonsProperty
public Reckfell.Collections.Array Polygons { get; set; }The list of polygons, in case more than one is being represented. Every individual polygon is stored as a int[] where each Polygon2D.Polygon. If empty, this property will be ignored, and the resulting single polygon will be composed of all points in Polygon2D.Polygon, using the order they are stored in.
SkeletonProperty
public EntityPath Skeleton { get; set; }The path to a Skeleton2D relative to this Polygon2D, for example ../Skeleton for a sibling. Bone paths in AddBone() are relative to that Skeleton2D instead. Visible skinning also requires vertex weights.
TextureProperty
public Texture2D Texture { get; set; }The polygon's fill texture. Use Polygon2D.UV to set texture coordinates.
TextureOffsetProperty
public Vector2 TextureOffset { get; set; }Amount to offset the polygon's Polygon2D.Texture. If set to Vector2(0, 0), the texture's origin (its top-left corner) will be placed at the polygon's position.
TextureRotationProperty
public float TextureRotation { get; set; }The texture's rotation in radians.
TextureScaleProperty
public Vector2 TextureScale { get; set; }Amount to multiply the Polygon2D.UV coordinates when using Polygon2D.Texture. Larger values make the texture smaller, and vice versa.
UVProperty
public Vector2[] UV { get; set; }Texture coordinates for each vertex of the polygon. There should be one UV value per polygon vertex. If there are fewer, undefined vertices will use Vector2(0, 0).
VertexColorsProperty
public Color[] VertexColors { get; set; }Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use Polygon2D.Color.
Methods43
AddBone2 overloads
public void AddBone(EntityPath path, ReadOnlySpan<float> weights);Adds a bone-weight record. path is relative to the assigned Skeleton2D; weights supplies one nonnegative weight per Polygon vertex, including internal vertices. A mismatched array length or missing bone excludes the record from rendering. The four largest weights per vertex are selected and normalized. Call QueueRedraw() when modifying an already visible polygon.
| Name | Type | Default |
|---|---|---|
path | EntityPath | — |
weights | ReadOnlySpan<float> | — |
public void AddBone(EntityPath path, float[] weights);Adds a bone-weight record. path is relative to the assigned Skeleton2D; weights supplies one nonnegative weight per Polygon vertex, including internal vertices. A mismatched array length or missing bone excludes the record from rendering. The four largest weights per vertex are selected and normalized. Call QueueRedraw() when modifying an already visible polygon.
| Name | Type | Default |
|---|---|---|
path | EntityPath | — |
weights | float[] | — |
ClearBonesvoid
public void ClearBones();Removes all bones from this Polygon2D.
EraseBonevoid
public void EraseBone(int index);Removes the specified bone from this Polygon2D.
| Name | Type | Default |
|---|---|---|
index | int | — |
GetAntialiasedbool
public bool GetAntialiased();boolGetBoneCountint
public int GetBoneCount();Returns the number of bones in this Polygon2D.
intGetBonePathEntityPath
public EntityPath GetBonePath(int index);Returns the path to the node associated with the specified bone.
| Name | Type | Default |
|---|---|---|
index | int | — |
EntityPathGetBoneWeightsfloat[]
public float[] GetBoneWeights(int index);Returns the weight values of the specified bone.
| Name | Type | Default |
|---|---|---|
index | int | — |
float[]GetColorColor
public Color GetColor();ColorGetInternalVertexCountint
public int GetInternalVertexCount();intGetInvertBorderfloat
public float GetInvertBorder();floatGetInvertEnabledbool
public bool GetInvertEnabled();boolGetOffsetVector2
public Vector2 GetOffset();Vector2GetPolygonVector2[]
public Vector2[] GetPolygon();Vector2[]GetPolygonsReckfell.Collections.Array
public Reckfell.Collections.Array GetPolygons();Reckfell.Collections.ArrayGetSkeletonEntityPath
public EntityPath GetSkeleton();EntityPathGetTextureTexture2D
public Texture2D GetTexture();Texture2DGetTextureOffsetVector2
public Vector2 GetTextureOffset();Vector2GetTextureRotationfloat
public float GetTextureRotation();floatGetTextureScaleVector2
public Vector2 GetTextureScale();Vector2GetUVVector2[]
public Vector2[] GetUV();Vector2[]GetVertexColorsColor[]
public Color[] GetVertexColors();Color[]SetAntialiasedvoid
public void SetAntialiased(bool antialiased);| Name | Type | Default |
|---|---|---|
antialiased | bool | — |
SetBonePathvoid
public void SetBonePath(int index, EntityPath path);Sets the path to the node associated with the specified bone.
| Name | Type | Default |
|---|---|---|
index | int | — |
path | EntityPath | — |
SetBoneWeights2 overloads
public void SetBoneWeights(int index, ReadOnlySpan<float> weights);Sets the weight values for the specified bone.
| Name | Type | Default |
|---|---|---|
index | int | — |
weights | ReadOnlySpan<float> | — |
public void SetBoneWeights(int index, float[] weights);Sets the weight values for the specified bone.
| Name | Type | Default |
|---|---|---|
index | int | — |
weights | float[] | — |
SetColorvoid
public void SetColor(Color color);| Name | Type | Default |
|---|---|---|
color | Color | — |
SetInternalVertexCountvoid
public void SetInternalVertexCount(int internalVertexCount);| Name | Type | Default |
|---|---|---|
internalVertexCount | int | — |
SetInvertBordervoid
public void SetInvertBorder(float invertBorder);| Name | Type | Default |
|---|---|---|
invertBorder | float | — |
SetInvertEnabledvoid
public void SetInvertEnabled(bool invert);| Name | Type | Default |
|---|---|---|
invert | bool | — |
SetOffsetvoid
public void SetOffset(Vector2 offset);| Name | Type | Default |
|---|---|---|
offset | Vector2 | — |
SetPolygon2 overloads
public void SetPolygon(Vector2[] polygon);| Name | Type | Default |
|---|---|---|
polygon | Vector2[] | — |
public void SetPolygon(ReadOnlySpan<Vector2> polygon);| Name | Type | Default |
|---|---|---|
polygon | ReadOnlySpan<Vector2> | — |
SetPolygonsvoid
public void SetPolygons(Reckfell.Collections.Array polygons);| Name | Type | Default |
|---|---|---|
polygons | Reckfell.Collections.Array | — |
SetSkeletonvoid
public void SetSkeleton(EntityPath skeleton);| Name | Type | Default |
|---|---|---|
skeleton | EntityPath | — |
SetTexturevoid
public void SetTexture(Texture2D texture);| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
SetTextureOffsetvoid
public void SetTextureOffset(Vector2 textureOffset);| Name | Type | Default |
|---|---|---|
textureOffset | Vector2 | — |
SetTextureRotationvoid
public void SetTextureRotation(float textureRotation);| Name | Type | Default |
|---|---|---|
textureRotation | float | — |
SetTextureScalevoid
public void SetTextureScale(Vector2 textureScale);| Name | Type | Default |
|---|---|---|
textureScale | Vector2 | — |
SetUV2 overloads
public void SetUV(Vector2[] uV);| Name | Type | Default |
|---|---|---|
uV | Vector2[] | — |
public void SetUV(ReadOnlySpan<Vector2> uV);| Name | Type | Default |
|---|---|---|
uV | ReadOnlySpan<Vector2> | — |
SetVertexColors2 overloads
public void SetVertexColors(Color[] vertexColors);| Name | Type | Default |
|---|---|---|
vertexColors | Color[] | — |
public void SetVertexColors(ReadOnlySpan<Color> vertexColors);| Name | Type | Default |
|---|---|---|
vertexColors | ReadOnlySpan<Color> | — |