reckfellENGINE

ImmediateMesh

Sequential builder for small nonindexed Mesh surfaces.

On this page
class ImmediateMeshReckfellSharpInherits Mesh

ImmediateMesh is a Mesh resource rather than an overlay drawing command or Entity. SurfaceBegin opens one surface, SurfaceAddVertex adds corners, and SurfaceEnd publishes the finished surface. Assign it to MeshInstance3D.Mesh and place the instance in the tree to display it. Geometry persists between frames: another Begin/End appends a surface rather than replacing the previous one.

C#
using var mesh = new ImmediateMesh();
mesh.SurfaceBegin(Mesh.PrimitiveType.Lines);
mesh.SurfaceSetColor(new Color(1, 0, 0));
mesh.SurfaceAddVertex(new Vector3(0, 0, 2));
mesh.SurfaceAddVertex(new Vector3(1, 0, 2));
mesh.SurfaceEnd();
int surfaceCount = mesh.GetSurfaceCount(); // 1

The example creates line data without a visible object. When assigning mesh to an instance, keep the resource alive for its entire use rather than ending its using scope early. Visible color requires a material that uses vertex color, for example StandardMaterial3D with VertexColorUseAsAlbedo = true. SurfaceSetColor does not configure the material. An unshaded material suits diagnostic lines independent of lighting. This API does not set pixel line width.

Use Begin → optional attribute setters → vertex additions → End. Only one surface can be open. End without vertices is rejected and does not close the builder. Supply pairs for Lines and corner triples for Triangles; the builder creates no indices, bones/weights, custom channels, blend shapes or LODs. Prepare large repeated geometry with ArrayMesh or SurfaceTool rather than rebuilding it here every frame.

Attributes are latched for subsequent vertices. The first setter call also fills already-added vertices of the current surface with that value. Later calls affect only future vertices. Unlike SurfaceTool, a channel can be enabled after the first vertex. Successful End resets channel-presence flags: set required attributes again for every Begin. Color uses eight bits per channel: values are clamped to 0…1 and quantized. Normals/tangents are packed, so readback need not reproduce original floats bit for bit.

SurfaceAddVertex2D stores Vector2 in a mesh buffer; it neither creates a CanvasItem nor switches the scene to 2D. Do not mix 2D and 3D in one surface. SurfaceEnd resets dimensionality for the next surface. Known 1.0.0 defect: ClearSurfaces during an unfinished 2D build does not reset its dimensionality. The next first Vector3 loses Z and subsequent Vector3 additions are rejected. Create a new ImmediateMesh after such an interruption; repeating ClearSurfaces does not fix it.

SurfaceEnd emits Changed; ClearSurfaces does not. Call EmitChanged explicitly if dependent code requires a notification after clearing. ClearSurfaces removes all completed surfaces and cancels the current build. SurfaceGetArrays results are snapshots rather than a live editor. Inspect these arrays for vertex types/counts; do not copy C++ virtual SurfaceGetArrayLen/SurfaceGetFormat into C# code, where these public methods are absent.

Prepare triangle normals and UVs yourself. When normals exist without tangents, the engine derives a helper tangent from the normal rather than UV mapping. Supply consistent tangents for normal mapping or use SurfaceTool.GenerateTangents. SurfaceSetUV2 merely writes coordinates: it neither unwraps geometry nor bakes lighting.

17 Windows headless checks covered CPU data and reproduced the dimensionality defect. The full native run is marked unsuccessful because that scenario emits a diagnostic, even though its expected behavior was recorded. Visible drawing, normal mapping, arbitrary geometry and performance remain unestablished; the engine was not patched.

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

Constructors1

ImmediateMeshConstructor
# ImmediateMesh
C#
public ImmediateMesh();

Creates an owned empty Mesh with a RID. Display needs a consumer such as MeshInstance3D. Release when no longer used rather than treating it as a temporary draw-call object.

Methods10

ClearSurfacesvoid
# ClearSurfaces
C#
public void ClearSurfaces();

Removes completed surfaces, cancels the active build and clears vertices/channels. Does not emit Changed. Defect: vertex_2d survives an interrupted 2D build; use a new ImmediateMesh for subsequent 3D construction.

SurfaceAddVertexvoid
# SurfaceAddVertex
C#
public void SurfaceAddVertex(Vector3 vertex);

Adds a local 3D corner with current attributes to the active surface. Does not index or weld equal positions. Cannot mix with 2D in one surface.

Parameters
NameTypeDefault
vertexVector3—
vertex

Finite local Vector3 position; use 3D throughout this surface.

SurfaceAddVertex2Dvoid
# SurfaceAddVertex2D
C#
public void SurfaceAddVertex2D(Vector2 vertex);

Adds a local 2D corner with current attributes to the mesh buffer. Not CanvasItem drawing. Cannot mix with 3D; create a new resource after interrupting this build with ClearSurfaces.

Parameters
NameTypeDefault
vertexVector2—
vertex

Local Vector2 position; use 2D throughout this surface.

SurfaceBeginvoid
# SurfaceBegin
C#
public void SurfaceBegin(Mesh.PrimitiveType primitive, Material material = null);

Opens a new surface with the supplied primitive and shared material. Does not clear completed surfaces. Another Begin while building is rejected; attribute setters/vertex additions require Begin first.

Parameters
NameTypeDefault
primitiveMesh.PrimitiveType—
materialMaterialnull
primitive

Assembly mode: pairs for Lines, triples for Triangles. Validate corner-count divisibility yourself.

material

Shared Material or null. Vertex colors require material configuration; the completed surface retains the reference.

SurfaceEndvoid
# SurfaceEnd
C#
public void SurfaceEnd();

Publishes a nonempty active surface, resets temporary channels/dimensionality and emits Changed. An empty surface is rejected without closing the build. Does not generate UVs or geometric normals.

SurfaceSetColorvoid
# SurfaceSetColor
C#
public void SurfaceSetColor(Color color);

Sets subsequent vertex color. The first call also fills already-added vertices of this surface. Stored as clamped RGBA8; material must use vertex color.

Parameters
NameTypeDefault
colorColor—
color

RGBA; publication clamps each component to 0…1 and quantizes to eight bits.

SurfaceSetNormalvoid
# SurfaceSetNormal
C#
public void SurfaceSetNormal(Vector3 normal);

Sets subsequent vertex normals; the first call fills previous vertices. Supply a unit normal. Without explicit tangents a helper is derived from the normal rather than UV derivatives for correct normal mapping.

Parameters
NameTypeDefault
normalVector3—
normal

Unit local normal for the intended lighting; direction is packed.

SurfaceSetTangentvoid
# SurfaceSetTangent
C#
public void SurfaceSetTangent(Plane tangent);

Sets subsequent vertex tangents; the first call fills previous vertices. Plane.Normal stores direction and D handedness, not a geometric plane. Prepare matching normal and UV data.

Parameters
NameTypeDefault
tangentPlane—
tangent

Plane with unit tangent xyz in Normal and handedness ±1 in D, consistent with normal/UV.

SurfaceSetUVvoid
# SurfaceSetUV
C#
public void SurfaceSetUV(Vector2 uV);

Sets subsequent vertex UVs; the first call fills previous vertices. Does not unwrap automatically. Coordinates affect output only when the material/shader uses the channel.

Parameters
NameTypeDefault
uVVector2—
uV

Texture UV coordinates, commonly 0…1; repetition depends on material/sampler.

SurfaceSetUV2void
# SurfaceSetUV2
C#
public void SurfaceSetUV2(Vector2 uV2);

Sets the second UV channel with the same initial-backfill/subsequent-vertex rule. Does not generate a lightmap unwrap or bake lighting.

Parameters
NameTypeDefault
uV2Vector2—
uV2

Prepared second-channel UV coordinates; this method does not validate lightmap overlap.

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.