reckfellENGINE

PrimitiveMesh

Base for procedural primitives with one surface.

On this page
class PrimitiveMeshReckfellSharpInherits Mesh

PrimitiveMesh generates one surface from concrete primitive parameters. Use BoxMesh, PlaneMesh, SphereMesh or another subclass for ordinary shapes; override _CreateMeshArray for a custom shape. Multiple MeshInstance3D instances can share one resource, so resource parameter changes affect all of them.

AddUV2 prepares a second UV channel without proving lighting was baked. See LightmapGI for Static mode, normals and suitable UV preparation. Consider ArrayMesh for multiple surfaces or arbitrary topology rather than simulating multiple surfaces in this class.

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

Constructors1

PrimitiveMeshConstructor
# PrimitiveMesh
C#
public PrimitiveMesh();

Creates a base PrimitiveMesh resource, not a ready-made shape. Use BoxMesh, SphereMesh or another concrete primitive, or override _CreateMeshArray. The base class without vertices cannot produce a usable surface. AddUV2 and FlipFaces initially equal false; UV2Padding is 2.

Properties5

AddUV2Property
# AddUV2
C#
public bool AddUV2 { get; set; }

Generate a second UV channel; defaults to false. Built-in primitives use their generator; for a custom array lacking UV2 the base fallback scales existing UV1 with padding. This is not an arbitrary-mesh unwrap: UV1 overlaps remain. Changing it updates geometry and the map size where supported by the specific primitive; rebake existing LightmapGI afterward.

CustomAabbProperty
# CustomAabb
C#
public Aabb CustomAabb { get; set; }

Custom mesh culling box; defaults to an empty Aabb. Does not move vertices or change the generated CPU-geometry bounds returned by GetAabb(). Useful for shader vertex displacement, for example; choose bounds covering the animation result.

FlipFacesProperty
# FlipFaces
C#
public bool FlipFaces { get; set; }

Invert indexed-triangle orientation. The base implementation negates normals and swaps the first two indices of each triangle when normals and indices are present. Defaults to false. Does not enable a double-sided material or replace cull-mode configuration.

MaterialProperty
# Material
C#
public Material Material { get; set; }

Material for the primitive single surface. Assignment changes the mesh resource and affects instances using it; this is not MeshInstance3D.MaterialOverride. Applies immediately when geometry exists, otherwise during generation. null clears the assignment. Returns a material reference, not an independent copy.

UV2PaddingProperty
# UV2Padding
C#
public float UV2Padding { get; set; }

UV2 padding, default 2. The specific generator combines it with map size and texel density. Changing it updates map size and geometry. The inspector hint 0…10 allows higher values and does not clamp the setter; use a finite nonnegative value. Large padding does not repair overlapping UVs or guarantee freedom from leaks.

Methods13

GetAddUV2bool
# GetAddUV2
C#
public bool GetAddUV2();

Returns AddUV2. Generate a second UV channel; defaults to false. Built-in primitives use their generator; for a custom array lacking UV2 the base fallback scales existing UV1 with padding. This is not an arbitrary-mesh unwrap: UV1 overlaps remain. Changing it updates geometry and the map size where supported by the specific primitive; rebake existing LightmapGI afterward.

Returns bool

Current AddUV2 value.

GetCustomAabbAabb
# GetCustomAabb
C#
public Aabb GetCustomAabb();

Returns CustomAabb. Custom mesh culling box; defaults to an empty Aabb. Does not move vertices or change the generated CPU-geometry bounds returned by GetAabb(). Useful for shader vertex displacement, for example; choose bounds covering the animation result.

Returns Aabb

Current CustomAabb value.

GetFlipFacesbool
# GetFlipFaces
C#
public bool GetFlipFaces();

Returns FlipFaces. Invert indexed-triangle orientation. The base implementation negates normals and swaps the first two indices of each triangle when normals and indices are present. Defaults to false. Does not enable a double-sided material or replace cull-mode configuration.

Returns bool

Current FlipFaces value.

GetMaterialMaterial
# GetMaterial
C#
public Material GetMaterial();

Returns Material. Material for the primitive single surface. Assignment changes the mesh resource and affects instances using it; this is not MeshInstance3D.MaterialOverride. Applies immediately when geometry exists, otherwise during generation. null clears the assignment. Returns a material reference, not an independent copy.

Returns Material

Current Material value.

GetMeshArraysReckfell.Collections.Array
# GetMeshArrays
C#
public Reckfell.Collections.Array GetMeshArrays();

Returns the channel array for the single surface 0, indexed by Mesh.ArrayType. Generates geometry first if needed. Slots may contain Nil when a channel is absent; do not expect a generated second UV channel with AddUV2 = false. Returned C# vertex arrays are copies; editing them does not upload new geometry into the resource. For a custom shape change its parameters and call RequestUpdate.

Returns Reckfell.Collections.Array

An array of Mesh.ArrayType.Max slots containing surface channels.

GetUV2Paddingfloat
# GetUV2Padding
C#
public float GetUV2Padding();

Returns UV2Padding. UV2 padding, default 2. The specific generator combines it with map size and texel density. Changing it updates map size and geometry. The inspector hint 0…10 allows higher values and does not clamp the setter; use a finite nonnegative value. Large padding does not repair overlapping UVs or guarantee freedom from leaks.

Returns float

Current UV2Padding value.

RequestUpdatevoid
# RequestUpdate
C#
public void RequestUpdate();

Requests geometry rebuilding after a custom primitive parameter changes. When initial generation is pending it happens on the first surface/RID read. For existing geometry the call performs an update and emits Changed. Does not unwrap an imported mesh, run LightmapGI or automatically upload arbitrary edited C# arrays.

SetAddUV2void
# SetAddUV2
C#
public void SetAddUV2(bool addUV2);

Sets AddUV2. Generate a second UV channel; defaults to false. Built-in primitives use their generator; for a custom array lacking UV2 the base fallback scales existing UV1 with padding. This is not an arbitrary-mesh unwrap: UV1 overlaps remain. Changing it updates geometry and the map size where supported by the specific primitive; rebake existing LightmapGI afterward.

Parameters
NameTypeDefault
addUV2bool—
addUV2

New AddUV2 value; follow the property usage rules.

SetCustomAabbvoid
# SetCustomAabb
C#
public void SetCustomAabb(Aabb aabb);

Sets CustomAabb. Custom mesh culling box; defaults to an empty Aabb. Does not move vertices or change the generated CPU-geometry bounds returned by GetAabb(). Useful for shader vertex displacement, for example; choose bounds covering the animation result.

Parameters
NameTypeDefault
aabbAabb—
aabb

New CustomAabb value; follow the property usage rules.

SetFlipFacesvoid
# SetFlipFaces
C#
public void SetFlipFaces(bool flipFaces);

Sets FlipFaces. Invert indexed-triangle orientation. The base implementation negates normals and swaps the first two indices of each triangle when normals and indices are present. Defaults to false. Does not enable a double-sided material or replace cull-mode configuration.

Parameters
NameTypeDefault
flipFacesbool—
flipFaces

New FlipFaces value; follow the property usage rules.

SetMaterialvoid
# SetMaterial
C#
public void SetMaterial(Material material);

Sets Material. Material for the primitive single surface. Assignment changes the mesh resource and affects instances using it; this is not MeshInstance3D.MaterialOverride. Applies immediately when geometry exists, otherwise during generation. null clears the assignment. Returns a material reference, not an independent copy.

Parameters
NameTypeDefault
materialMaterial—
material

New Material value; follow the property usage rules.

SetUV2Paddingvoid
# SetUV2Padding
C#
public void SetUV2Padding(float uV2Padding);

Sets UV2Padding. UV2 padding, default 2. The specific generator combines it with map size and texel density. Changing it updates map size and geometry. The inspector hint 0…10 allows higher values and does not clamp the setter; use a finite nonnegative value. Large padding does not repair overlapping UVs or guarantee freedom from leaks.

Parameters
NameTypeDefault
uV2Paddingfloat—
uV2Padding

New UV2Padding value; follow the property usage rules.

_CreateMeshArrayReckfell.Collections.Array
# _CreateMeshArray
C#
public virtual Reckfell.Collections.Array _CreateMeshArray();

Override to generate one surface. Return an Array of exactly Mesh.ArrayType.Max slots with a nonempty Vertex array; populate required normals, UVs, indices and other channels consistently. The base checks array size and vertices, not arbitrary topology validity. Use RequestUpdate after custom parameter changes rather than invoking the generator manually.

Indexed-triangle example with width validation; this illustrates the API rather than a finished showcase scene:

C#
using System;
using Reckfell;
using Array = Reckfell.Collections.Array;

public partial class TrianglePrimitive : PrimitiveMesh
{
    private float _width = 1f;

    public TrianglePrimitive()
    {
        LightmapSizeHint = new Vector2I(32, 32);
    }

    public void SetWidth(float width)
    {
        if (!float.IsFinite(width) || width <= 0f)
            throw new ArgumentOutOfRangeException(nameof(width));
        _width = width;
        RequestUpdate();
    }

    public override Array _CreateMeshArray()
    {
        var arrays = new Array();
        arrays.Resize((int)Mesh.ArrayType.Max);
        arrays[(int)Mesh.ArrayType.Vertex] = new Vector3[]
            { Vector3.Zero, new(_width, 0, 0), new(0, 0, 1) };
        arrays[(int)Mesh.ArrayType.Normal] = new Vector3[]
            { Vector3.Up, Vector3.Up, Vector3.Up };
        arrays[(int)Mesh.ArrayType.TexUV] = new Vector2[]
            { Vector2.Zero, Vector2.Right, Vector2.Down };
        arrays[(int)Mesh.ArrayType.Index] = new int[] { 0, 2, 1 };
        return arrays;
    }
}
Returns Reckfell.Collections.Array

Channel array for the new single surface.

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.