reckfellENGINE

Polygon2D

Draws a polygon with color, texture and optional bone skinning.

On this page
class Polygon2DReckfellSharpInherits Entity2D

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.

Working example.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

Polygon2DConstructor
# Polygon2D
C#
public Polygon2D();

Properties16

AntialiasedProperty
# Antialiased
C#
public bool Antialiased { get; set; }

If true, polygon edges will be anti-aliased.

BonesProperty
# Bones
C#
public Reckfell.Collections.Array Bones { get; set; }
ColorProperty
# Color
C#
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
# InternalVertexCount
C#
public int InternalVertexCount { get; set; }

Number of internal vertices, used for UV mapping.

InvertBorderProperty
# InvertBorder
C#
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
# InvertEnabled
C#
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
# Offset
C#
public Vector2 Offset { get; set; }

The offset applied to each vertex.

PolygonProperty
# Polygon
C#
public Vector2[] Polygon { get; set; }

The polygon's list of vertices. The final point will be connected to the first.

PolygonsProperty
# Polygons
C#
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
# Skeleton
C#
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
# Texture
C#
public Texture2D Texture { get; set; }

The polygon's fill texture. Use Polygon2D.UV to set texture coordinates.

TextureOffsetProperty
# TextureOffset
C#
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
# TextureRotation
C#
public float TextureRotation { get; set; }

The texture's rotation in radians.

TextureScaleProperty
# TextureScale
C#
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
# UV
C#
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
# VertexColors
C#
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
# AddBone · 1/2
C#
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.

Parameters
NameTypeDefault
pathEntityPath—
weightsReadOnlySpan<float>—
# AddBone · 2/2
C#
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.

Parameters
NameTypeDefault
pathEntityPath—
weightsfloat[]—
ClearBonesvoid
# ClearBones
C#
public void ClearBones();

Removes all bones from this Polygon2D.

EraseBonevoid
# EraseBone
C#
public void EraseBone(int index);

Removes the specified bone from this Polygon2D.

Parameters
NameTypeDefault
indexint—
GetAntialiasedbool
# GetAntialiased
C#
public bool GetAntialiased();
Returns bool
GetBoneCountint
# GetBoneCount
C#
public int GetBoneCount();

Returns the number of bones in this Polygon2D.

Returns int
GetBonePathEntityPath
# GetBonePath
C#
public EntityPath GetBonePath(int index);

Returns the path to the node associated with the specified bone.

Parameters
NameTypeDefault
indexint—
Returns EntityPath
GetBoneWeightsfloat[]
# GetBoneWeights
C#
public float[] GetBoneWeights(int index);

Returns the weight values of the specified bone.

Parameters
NameTypeDefault
indexint—
Returns float[]
GetColorColor
# GetColor
C#
public Color GetColor();
Returns Color
GetInternalVertexCountint
# GetInternalVertexCount
C#
public int GetInternalVertexCount();
Returns int
GetInvertBorderfloat
# GetInvertBorder
C#
public float GetInvertBorder();
Returns float
GetInvertEnabledbool
# GetInvertEnabled
C#
public bool GetInvertEnabled();
Returns bool
GetOffsetVector2
# GetOffset
C#
public Vector2 GetOffset();
Returns Vector2
GetPolygonVector2[]
# GetPolygon
C#
public Vector2[] GetPolygon();
Returns Vector2[]
GetPolygonsReckfell.Collections.Array
# GetPolygons
C#
public Reckfell.Collections.Array GetPolygons();
Returns Reckfell.Collections.Array
GetSkeletonEntityPath
# GetSkeleton
C#
public EntityPath GetSkeleton();
Returns EntityPath
GetTextureTexture2D
# GetTexture
C#
public Texture2D GetTexture();
Returns Texture2D
GetTextureOffsetVector2
# GetTextureOffset
C#
public Vector2 GetTextureOffset();
Returns Vector2
GetTextureRotationfloat
# GetTextureRotation
C#
public float GetTextureRotation();
Returns float
GetTextureScaleVector2
# GetTextureScale
C#
public Vector2 GetTextureScale();
Returns Vector2
GetUVVector2[]
# GetUV
C#
public Vector2[] GetUV();
Returns Vector2[]
GetVertexColorsColor[]
# GetVertexColors
C#
public Color[] GetVertexColors();
Returns Color[]
SetAntialiasedvoid
# SetAntialiased
C#
public void SetAntialiased(bool antialiased);
Parameters
NameTypeDefault
antialiasedbool—
SetBonePathvoid
# SetBonePath
C#
public void SetBonePath(int index, EntityPath path);

Sets the path to the node associated with the specified bone.

Parameters
NameTypeDefault
indexint—
pathEntityPath—
SetBoneWeights2 overloads
# SetBoneWeights · 1/2
C#
public void SetBoneWeights(int index, ReadOnlySpan<float> weights);

Sets the weight values for the specified bone.

Parameters
NameTypeDefault
indexint—
weightsReadOnlySpan<float>—
# SetBoneWeights · 2/2
C#
public void SetBoneWeights(int index, float[] weights);

Sets the weight values for the specified bone.

Parameters
NameTypeDefault
indexint—
weightsfloat[]—
SetColorvoid
# SetColor
C#
public void SetColor(Color color);
Parameters
NameTypeDefault
colorColor—
SetInternalVertexCountvoid
# SetInternalVertexCount
C#
public void SetInternalVertexCount(int internalVertexCount);
Parameters
NameTypeDefault
internalVertexCountint—
SetInvertBordervoid
# SetInvertBorder
C#
public void SetInvertBorder(float invertBorder);
Parameters
NameTypeDefault
invertBorderfloat—
SetInvertEnabledvoid
# SetInvertEnabled
C#
public void SetInvertEnabled(bool invert);
Parameters
NameTypeDefault
invertbool—
SetOffsetvoid
# SetOffset
C#
public void SetOffset(Vector2 offset);
Parameters
NameTypeDefault
offsetVector2—
SetPolygon2 overloads
# SetPolygon · 1/2
C#
public void SetPolygon(Vector2[] polygon);
Parameters
NameTypeDefault
polygonVector2[]—
# SetPolygon · 2/2
C#
public void SetPolygon(ReadOnlySpan<Vector2> polygon);
Parameters
NameTypeDefault
polygonReadOnlySpan<Vector2>—
SetPolygonsvoid
# SetPolygons
C#
public void SetPolygons(Reckfell.Collections.Array polygons);
Parameters
NameTypeDefault
polygonsReckfell.Collections.Array—
SetSkeletonvoid
# SetSkeleton
C#
public void SetSkeleton(EntityPath skeleton);
Parameters
NameTypeDefault
skeletonEntityPath—
SetTexturevoid
# SetTexture
C#
public void SetTexture(Texture2D texture);
Parameters
NameTypeDefault
textureTexture2D—
SetTextureOffsetvoid
# SetTextureOffset
C#
public void SetTextureOffset(Vector2 textureOffset);
Parameters
NameTypeDefault
textureOffsetVector2—
SetTextureRotationvoid
# SetTextureRotation
C#
public void SetTextureRotation(float textureRotation);
Parameters
NameTypeDefault
textureRotationfloat—
SetTextureScalevoid
# SetTextureScale
C#
public void SetTextureScale(Vector2 textureScale);
Parameters
NameTypeDefault
textureScaleVector2—
SetUV2 overloads
# SetUV · 1/2
C#
public void SetUV(Vector2[] uV);
Parameters
NameTypeDefault
uVVector2[]—
# SetUV · 2/2
C#
public void SetUV(ReadOnlySpan<Vector2> uV);
Parameters
NameTypeDefault
uVReadOnlySpan<Vector2>—
SetVertexColors2 overloads
# SetVertexColors · 1/2
C#
public void SetVertexColors(Color[] vertexColors);
Parameters
NameTypeDefault
vertexColorsColor[]—
# SetVertexColors · 2/2
C#
public void SetVertexColors(ReadOnlySpan<Color> vertexColors);
Parameters
NameTypeDefault
vertexColorsReadOnlySpan<Color>—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.