reckfellENGINE

ImporterMesh

Intermediate CPU import-surface data that builds an ArrayMesh.

On this page
class ImporterMeshReckfellSharpInherits Resource

ImporterMesh is a RefCounted preparation-data object rather than a directly drawable Mesh or Entity. Add surfaces with AddSurface, set blend mode, lightmap hint and LODs, then call GetMesh. Assign the resulting ArrayMesh to MeshInstance3D or save it as a resource.

C#
using var staged = new ImporterMesh();
using var arrays = new Reckfell.Collections.Array();
arrays.Resize((int)Mesh.ArrayType.Max);
arrays[(int)Mesh.ArrayType.Vertex] = new Vector3[] {
    Vector3.Zero, new(1, 0, 0), new(1, 1, 0), new(0, 1, 0)
};
arrays[(int)Mesh.ArrayType.Index] = new int[] { 0, 1, 2, 0, 2, 3 };
staged.AddSurface(Mesh.PrimitiveType.Triangles, arrays, name: "part");
using var mesh = staged.GetMesh();
int vertexCount = mesh.SurfaceGetArrayLen(0); // 4

The example creates geometry without a visible instance/material. To display it, assign mesh to a consumer and keep it alive throughout use; the example using scope ends its lifetime after inspecting data. Finish staging before constructing the result. Default blend mode here is Normalized, whereas a new ArrayMesh defaults to Relative.

AddSurface takes exactly Mesh.ArrayType.Max slots with nonempty Vector3 positions. Prepare consistent channel lengths and valid indices. It does not validate all geometry later packed by ArrayMesh. GetSurfaceFormat returns supplied flags rather than a computed channel mask: 0 does not mean no vertices. Primary flags type is ulong; the uint overload forwards its value.

Unlike ArrayMesh, AddSurface retains a shared Array container; GetSurfaceArrays and GetSurfaceBlendShapeArrays return aliases. Replacing a slot changes staging data and the original container. AsVector3Array gives a managed copy, however: explicitly reassign it to the slot after editing. Copy containers beforehand for independent staging; Material resources can still remain shared. Shared-array edits neither invalidate the result cache nor emit Changed.

GetMesh caches its result and repeatedly returns the same reference. AddSurface, SetSurfaceName and SetSurfaceMaterial invalidate the cache, but an already-returned ArrayMesh remains the separate old result. SetBlendShapeMode and SetLightmapSizeHint do not invalidate it. Set them before the first GetMesh; reading again does not update the old resource. baseMesh is used only on initial construction and is not cleared: surfaces are appended. Supply an empty dedicated ArrayMesh for a controlled result rather than a resource that must not be mutated.

Declare shape names before surfaces. Colons become underscores without uniqueness enforcement. Every declared shape needs a Max-slot array with matching vertex count. Duplicate names can become different names when converted to ArrayMesh, so enforce uniqueness yourself. Staged LODs hold a numeric threshold and index list; the final renderer requires a positive threshold and a list shorter than the base. Generate LODs before the first GetMesh and inspect their quality separately.

FromMesh copies surfaces, blend data, LODs, resource name and metadata; Material remains shared. It uses ArrayMesh surface names, falling back to Material.ResourceName when empty. It is not a complete settings transfer: lightmap hint and shadow mesh are not copied. Clear removes surfaces, shape names and cache while retaining blend mode and lightmap hint; no automatic Changed notification occurs.

MergeImporterMeshes applies relative Transform3D values to static geometry. With deduplicateSurfaces = true, surfaces with matching name, primitive and flags can combine despite different materials: the first material wins. Disable deduplication for different materials. It concatenates vertices and offsets indices rather than welding. Blend shapes and LODs are discarded with warnings. Skeletons/bind poses are not remapped; nonuniform scale does not use inverse-transpose normals, and reflections leave tangent handedness unchanged. Do not treat it as a universal animated-model merge.

Hidden _Data is for serialization rather than safe editing. The current getter writes blend_shapes but the setter reads b_shapes; mode/lightmap hint are absent from the dictionary. Do not rely on a complete _Data roundtrip.

26 Windows headless checks covered staging, aliases, cache, a simple blend/LOD package and static surface merging. Visible rendering, new LOD generation, reflected/nonuniform/skinned merging and blend-shape serialization were not tested in this pass. Previously reviewed LOD prose retains its separate evidence report.

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

Constructors1

ImporterMeshConstructor
# ImporterMesh
C#
public ImporterMesh();

Creates an owned empty staging RefCounted: no surfaces/shapes, Normalized mode, lightmap hint (0,0). Not a drawable Mesh.

Properties1

_DataProperty
# _Data
C#
public Reckfell.Collections.Dictionary _Data { get; set; }

Hidden serialization Dictionary containing staged arrays/shared references. Not an independent copy of the entire resource. Getter writes blend_shapes while setter reads b_shapes; mode/hint are absent. Not a guaranteed lossless roundtrip.

Methods26

AddBlendShapevoid
# AddBlendShape
C#
public void AddBlendShape(string name);

Adds a name before surfaces. Replaces : with _ without ensuring uniqueness. Prevent duplicates beforehand to avoid different names after GetMesh.

Parameters
NameTypeDefault
namestring—
name

Shape name before : → _ sanitization; ensure uniqueness yourself.

AddSurface2 overloads
# AddSurface · 1/2
C#
public void AddSurface(Mesh.PrimitiveType primitive, Reckfell.Collections.Array arrays, Reckfell.Collections.Array<Reckfell.Collections.Array> blendShapes, Reckfell.Collections.Dictionary lods, Material material, string name, uint flags);

Appends a staging surface and invalidates GetMesh cache. Retains shared arrays/blend containers and material/name/flags; does not emit Changed. Input validation is partial: prepare valid channels/indices before building ArrayMesh. ulong is primary; uint is a forwarding overload.

Parameters
NameTypeDefault
primitiveMesh.PrimitiveType—
arraysReckfell.Collections.Array—
blendShapesReckfell.Collections.Array<Reckfell.Collections.Array>—
lodsReckfell.Collections.Dictionary—
materialMaterial—
namestring—
flagsuint—
primitive

Assembly mode. For Triangles prepare a corner/index count divisible by three.

arrays

Exactly Mesh.ArrayType.Max slots with nonempty Vector3[] Vertex and consistent channels. The container is retained shared.

blendShapes

One Max-slot Array per declared shape in order, with the same vertex count. null only without declared shapes.

lods

Optional threshold → int[] Dictionary. Final ArrayMesh needs positive thresholds and shorter valid lists; staging does not fully validate this.

material

Shared Material reference or null; not cloned.

name

Staged surface name; empty/duplicate names are allowed.

flags

ulong packing/custom-format flags, default 0. The uint overload forwards to ulong without deriving channel flags from arrays.

# AddSurface · 2/2
C#
public void AddSurface(Mesh.PrimitiveType primitive, Reckfell.Collections.Array arrays, Reckfell.Collections.Array<Reckfell.Collections.Array> blendShapes = null, Reckfell.Collections.Dictionary lods = null, Material material = null, string name = "", ulong flags = 0);

Appends a staging surface and invalidates GetMesh cache. Retains shared arrays/blend containers and material/name/flags; does not emit Changed. Input validation is partial: prepare valid channels/indices before building ArrayMesh. ulong is primary; uint is a forwarding overload.

Parameters
NameTypeDefault
primitiveMesh.PrimitiveType—
arraysReckfell.Collections.Array—
blendShapesReckfell.Collections.Array<Reckfell.Collections.Array>null
lodsReckfell.Collections.Dictionarynull
materialMaterialnull
namestring""
flagsulong0
primitive

Assembly mode. For Triangles prepare a corner/index count divisible by three.

arrays

Exactly Mesh.ArrayType.Max slots with nonempty Vector3[] Vertex and consistent channels. The container is retained shared.

blendShapes

One Max-slot Array per declared shape in order, with the same vertex count. null only without declared shapes.

lods

Optional threshold → int[] Dictionary. Final ArrayMesh needs positive thresholds and shorter valid lists; staging does not fully validate this.

material

Shared Material reference or null; not cloned.

name

Staged surface name; empty/duplicate names are allowed.

flags

ulong packing/custom-format flags, default 0. The uint overload forwards to ulong without deriving channel flags from arrays.

Clearvoid
# Clear
C#
public void Clear();

Removes surfaces, blend-shape names and result cache. Retains blend mode/lightmap size hint; not a complete settings reset and does not emit Changed.

FromMeshImporterMesh
# FromMesh
C#
public static ImporterMesh FromMesh(Mesh mesh);

Creates ImporterMesh from Mesh: surfaces, shapes/LODs, shared Materials, name and metadata. Falls back to material name for an empty surface name. Does not copy lightmap hint, shadow mesh or every other resource setting. null yields an empty ImporterMesh.

Parameters
NameTypeDefault
meshMesh—
mesh

Source Mesh with readable surfaces, or null for an empty result; not a full snapshot of every setting.

Returns ImporterMesh

New owned ImporterMesh, empty for null. Materials and some data can remain shared.

GenerateLodsvoid
# GenerateLods
C#
public void GenerateLods(float normalMergeAngle, float normalSplitAngle, Reckfell.Collections.Array boneTransformArray);

Prepares additional triangle-surface index LODs. Call after AddSurface and before the first GetMesh. Source skips surfaces without indices; a call alone does not guarantee generated LODs. Check GetSurfaceLodCount and result quality.

Parameters
NameTypeDefault
normalMergeAnglefloat—
normalSplitAnglefloat—
boneTransformArrayReckfell.Collections.Array—
normalMergeAngle

Normal merge angle in degrees; the example uses 60. Controls simplification preparation, not LOD switching distance.

normalSplitAngle

Present in the current signature but unused by the implementation. The example passes 0; changing it does not establish a changed result.

boneTransformArray

Transform3D array for bones when applicable. The unskinned static sphere passes an empty Array. Skinned/blend-shape cases are outside this example.

GetBlendShapeCountint
# GetBlendShapeCount
C#
public int GetBlendShapeCount();

Returns the staged declared shape count; 0 after Clear.

Returns int

Nonnegative declared shape count.

GetBlendShapeModeMesh.BlendShapeMode
# GetBlendShapeMode
C#
public Mesh.BlendShapeMode GetBlendShapeMode();

Returns the staging mode, initially Normalized. It can differ from an already-cached GetMesh result.

Returns Mesh.BlendShapeMode

Staging Mesh.BlendShapeMode, initially Normalized.

GetBlendShapeNamestring
# GetBlendShapeName
C#
public string GetBlendShapeName(int blendShapeIdx);

Reads the name after : becomes _. Duplicates are possible; not a guaranteed unique identifier.

Parameters
NameTypeDefault
blendShapeIdxint—
blendShapeIdx

Declared shape index from 0 to GetBlendShapeCount()-1. For the array getter the shape must exist in the selected surface.

Returns string

Stored string or an empty invalid-index fallback.

GetLightmapSizeHintVector2I
# GetLightmapSizeHint
C#
public Vector2I GetLightmapSizeHint();

Reads the stored lightmap-size hint. Does not measure a baked texture/UV2 and can differ from a cached ArrayMesh.

Returns Vector2I

Hint Vector2I; (0,0) for a new object.

GetMeshArrayMesh
# GetMesh
C#
public ArrayMesh GetMesh(ArrayMesh baseMesh = null);

Obtains the prepared surfaces/LODs as an ArrayMesh. The result is cached: generate LODs before the first GetMesh rather than assuming repeated reads rebuild a previously returned resource.

Parameters
NameTypeDefault
baseMeshArrayMeshnull
baseMesh

Optional ArrayMesh for initial result construction. Source uses it when no mesh is cached. Do not supply a resource that must not be modified.

Returns ArrayMesh

ArrayMesh with prepared LODs, or null if no result can be obtained. The example saves .rdata, reloads without cache and re-verifies distant LOD through rendered primitive counts.

GetSurfaceArraysReckfell.Collections.Array
# GetSurfaceArrays
C#
public Reckfell.Collections.Array GetSurfaceArrays(int surfaceIdx);

Returns an alias of the shared surface Array. Slot replacement changes staging without invalidating GetMesh cache. Packed arrays obtained through AsVector3Array and similar methods are managed copies. Dispose your wrapper after use.

Parameters
NameTypeDefault
surfaceIdxint—
surfaceIdx

Current staging-surface index from 0 to GetSurfaceCount()-1.

Returns Reckfell.Collections.Array

Owned wrapper over the shared Array, not an independent snapshot. Empty container on invalid index.

GetSurfaceBlendShapeArraysReckfell.Collections.Array
# GetSurfaceBlendShapeArrays
C#
public Reckfell.Collections.Array GetSurfaceBlendShapeArrays(int surfaceIdx, int blendShapeIdx);

Returns an alias of one shared surface-shape Array. Slot edits affect staging and the original container without updating a built ArrayMesh.

Parameters
NameTypeDefault
surfaceIdxint—
blendShapeIdxint—
surfaceIdx

Current staging-surface index from 0 to GetSurfaceCount()-1.

blendShapeIdx

Declared shape index from 0 to GetBlendShapeCount()-1. For the array getter the shape must exist in the selected surface.

Returns Reckfell.Collections.Array

Owned wrapper over the shared shape Array; empty container on diagnosed invalid indices.

GetSurfaceCountint
# GetSurfaceCount
C#
public int GetSurfaceCount();

Staged surface count rather than the count of an arbitrary supplied baseMesh.

Returns int

Staged surface count; 0 for a new/cleared object.

GetSurfaceFormatulong
# GetSurfaceFormat
C#
public ulong GetSurfaceFormat(int surfaceIdx);

Returns flags supplied to AddSurface rather than deriving channels from arrays. 0 is valid with vertex/index data. Read actual packed layout from the built ArrayMesh.

Parameters
NameTypeDefault
surfaceIdxint—
surfaceIdx

Current staging-surface index from 0 to GetSurfaceCount()-1.

Returns ulong

Supplied ulong flags; 0 is also the invalid-surface-index fallback.

GetSurfaceLodCountint
# GetSurfaceLodCount
C#
public int GetSurfaceLodCount(int surfaceIdx);

Reads the surface additional LOD count. Counts resource data levels, not visible objects or the renderer’s currently selected level.

Parameters
NameTypeDefault
surfaceIdxint—
surfaceIdx

Existing surface index starting at 0.

Returns int

Additional level count; 0 means none. The full-detail base geometry is not included.

GetSurfaceLodIndicesint[]
# GetSurfaceLodIndices
C#
public int[] GetSurfaceLodIndices(int surfaceIdx, int lodIdx);

Gets one prepared LOD triangle-index array. Fewer indices reduce submitted primitives, not unload the source mesh or create a separate entity.

Parameters
NameTypeDefault
surfaceIdxint—
lodIdxint—
surfaceIdx

Surface index.

lodIdx

Additional LOD index from 0 through GetSurfaceLodCount(surfaceIdx)-1.

Returns int[]

Integer index array. Valid triangle data has length divisible by 3; every tested additional level is shorter than the base array.

GetSurfaceLodSizefloat
# GetSurfaceLodSize
C#
public float GetSurfaceLodSize(int surfaceIdx, int lodIdx);

Reads the level metric used for LOD selection. Source derives it from simplification error multiplied by geometry scale, not a ready-made world-space camera distance.

Parameters
NameTypeDefault
surfaceIdxint—
lodIdxint—
surfaceIdx

Surface index.

lodIdx

Additional LOD index.

Returns float

Level error/scale metric. Actual selection also depends on projection, distance, object scale, LodBias and viewport threshold.

GetSurfaceMaterialMaterial
# GetSurfaceMaterial
C#
public Material GetSurfaceMaterial(int surfaceIdx);

Returns the shared Material reference or null, not a copy. Do not release an alias ahead of its owner.

Parameters
NameTypeDefault
surfaceIdxint—
surfaceIdx

Current staging-surface index from 0 to GetSurfaceCount()-1.

Returns Material

Shared Material or null; diagnosed invalid indices also return null.

GetSurfaceNamestring
# GetSurfaceName
C#
public string GetSurfaceName(int surfaceIdx);

Returns the staged name, possibly empty/duplicated. Not a persistent unique ID.

Parameters
NameTypeDefault
surfaceIdxint—
surfaceIdx

Current staging-surface index from 0 to GetSurfaceCount()-1.

Returns string

Name or empty string; emptiness does not establish a valid index.

GetSurfacePrimitiveTypeMesh.PrimitiveType
# GetSurfacePrimitiveType
C#
public Mesh.PrimitiveType GetSurfacePrimitiveType(int surfaceIdx);

Reads the staged surface primitive. Invalid-index fallback Max is not valid geometry.

Parameters
NameTypeDefault
surfaceIdxint—
surfaceIdx

Current staging-surface index from 0 to GetSurfaceCount()-1.

Returns Mesh.PrimitiveType

Stored primitive, or Max on invalid index.

MergeImporterMeshesImporterMesh
# MergeImporterMeshes
C#
public static ImporterMesh MergeImporterMeshes(Reckfell.Collections.Array<ImporterMesh> importerMeshes, Reckfell.Collections.Array<Transform3D> relativeTransforms, bool deduplicateSurfaces = true);

Merges static data using relative Transform3D values. By default equal name/primitive/flags combine without comparing Material, retaining the first. Not welding. Drops blend shapes/LODs with warnings and does not remap skeletons. Pass false for different materials; inspect nonuniform/reflected normals/tangents separately.

Parameters
NameTypeDefault
importerMeshesReckfell.Collections.Array<ImporterMesh>—
relativeTransformsReckfell.Collections.Array<Transform3D>—
deduplicateSurfacesbooltrue
importerMeshes

Nonempty typed array of nonnull ImporterMesh resources. Use consistent static 3D surfaces for a safe general case.

relativeTransforms

One Transform3D per input mesh in matching order, from its local space into result space.

deduplicateSurfaces

true combines matching name/primitive/flags without material checks. false retains separate surfaces and distinguishes conflicting names with suffixes.

Returns ImporterMesh

New owned ImporterMesh, or null for rejected input. A nonnull result does not guarantee material, animation or shading fidelity.

SetBlendShapeModevoid
# SetBlendShapeMode
C#
public void SetBlendShapeMode(Mesh.BlendShapeMode mode);

Changes the staging mode without converting arrays, invalidating GetMesh cache or emitting Changed. Set before initial construction.

Parameters
NameTypeDefault
modeMesh.BlendShapeMode—
mode

Normalized or Relative to match prepared data; does not update a cached result automatically.

SetLightmapSizeHintvoid
# SetLightmapSizeHint
C#
public void SetLightmapSizeHint(Vector2I size);

Stores a hint for subsequent ArrayMesh construction. Does not create UV2/a texture or invalidate an existing cache.

Parameters
NameTypeDefault
sizeVector2I—
size

Nonnegative hint dimensions in texels; (0,0) means no specified hint. Not a generation command.

SetSurfaceMaterialvoid
# SetSurfaceMaterial
C#
public void SetSurfaceMaterial(int surfaceIdx, Material material);

Changes the staged shared material reference and invalidates GetMesh cache. Already-returned ArrayMesh resources remain unchanged; no Changed notification.

Parameters
NameTypeDefault
surfaceIdxint—
materialMaterial—
surfaceIdx

Current staging-surface index from 0 to GetSurfaceCount()-1.

material

Shared Material reference or null; not cloned.

SetSurfaceNamevoid
# SetSurfaceName
C#
public void SetSurfaceName(int surfaceIdx, string name);

Changes the staged name and invalidates GetMesh cache. Does not enforce uniqueness, edit the old result or emit Changed.

Parameters
NameTypeDefault
surfaceIdxint—
namestring—
surfaceIdx

Current staging-surface index from 0 to GetSurfaceCount()-1.

name

Staged surface name; empty/duplicate names are allowed.

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.