reckfellENGINE

Curve3D

Local 3D Bezier curve with control handles and a CPU length/orientation cache.

On this page
class Curve3DReckfellSharpInherits Resource

Add points and relative in/out handles, then choose sampling units: Sample(idx,t) is one segment parameter; Samplef uses index plus fraction; SampleBaked(offset) uses local distance on an approximation. For motion in local units per second, accumulate distance instead of treating t as time or a fraction of the whole length.

Baked data rebuild lazily after edits. BakeInterval controls density, but length remains approximate. SampleBaked clamps distance and does not loop even when Closed. Closed Samplef(PointCount) has special boundary behavior; use the explicit final-segment endpoint or GetBakedLength for the loop endpoint.

Tilt is in radians and applies by flag. Frame forward is −Basis.Z. All results are local: Path3D transform/scale are not automatically applied. _Data is an internal container requiring matching lengths, not a user-input format.

Small nondegenerate curves, cache/handles, closure, orientation and valid data roundtrips were tested in Windows headless. Degenerate geometry, malformed data, exact analytic length, all tessellation tolerances and graphics were not established.

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

Constructors1

Curve3DConstructor
# Curve3D
C#
public Curve3D();

Creates an owned empty curve resource: Closed=false, BakeInterval=0.2, UpVectorEnabled=true. Add control points before sampling. Stores local data rather than moving Entities or building collisions. Dispose the resource after use.

Properties5

BakeIntervalProperty
# BakeInterval
C#
public float BakeInterval { get; set; }

Positive finite CPU-cache density scale, default 0.2 in local units. Smaller usually produces more samples and memory/CPU work. Not a promise of perfectly equal spacing or exact analytic length: subdivision depth is bounded. The setter does not validate positivity/finiteness for you.

ClosedProperty
# Closed
C#
public bool Closed { get; set; }

Adds a last-to-first segment without duplicating a control point in PointCount. Requires at least two meaningful points. Does not enable automatic SampleBaked looping: distance still clamps to endpoints. RemovePoint clears Closed below two points, while PointCount/ClearPoints can retain it.

PointCountProperty
# PointCount
C#
public int PointCount { get; set; }

Control-point count, not baked-sample count. Growth appends zero positions/handles/tilts; shrinking truncates the end. Changed can occur per appended point rather than one atomic path replacement. Shrinking through PointCount does not automatically clear Closed; validate configuration yourself.

UpVectorEnabledProperty
# UpVectorEnabled
C#
public bool UpVectorEnabled { get; set; }

Enables baked up-vector computation, default true. Used for an up direction along the path and SampleBakedUpVector. Disabling reduces cache data; frame sampling falls back to Vector3.Up, which does not guarantee stability for vertical/degenerate curves. Does not control gravity.

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

Internal data container: points is Vector3[] triplets of in/out/position; tilts is float[] with one value per point. Getter creates a Dictionary snapshot; setter requires matching lengths. An undersized tilts array is not safely validated input. Use point methods for ordinary code and resources for persistence; this is not a stable external format. Dispose the owned Dictionary wrapper after reading.

Methods32

AddPointvoid
# AddPoint
C#
public void AddPoint(Vector3 position, Vector3? @in = default, Vector3? @out = default, int index = -1);

Adds a control point with local position and relative in/out handles. Default nullable handles become Vector3.Zero. index in [0,PointCount) inserts before that point; negative/out-of-range appends. Shifts subsequent indices, invalidates the cache and emits Changed.

Parameters
NameTypeDefault
positionVector3—
inVector3?default
outVector3?default
indexint-1
position

Finite local position; SetPointIn/Out take a relative handle rather than an endpoint.

in

Relative incoming handle; null/default means Vector3.Zero.

out

Relative outgoing handle; null/default means Vector3.Zero.

index

Insert-before index; out-of-range appends.

ClearPointsvoid
# ClearPoints
C#
public void ClearPoints();

Removes all control points; the next baked query rebuilds an empty cache. Retains settings including Closed. Do not sample positions/orientation on an empty curve; GetBakedLength returns 0.

GetBakeIntervalfloat
# GetBakeInterval
C#
public float GetBakeInterval();

Reads BakeInterval. Positive finite CPU-cache density scale, default 0.2 in local units. Smaller usually produces more samples and memory/CPU work. Not a promise of perfectly equal spacing or exact analytic length: subdivision depth is bounded. The setter does not validate positivity/finiteness for you.

Returns float

Stored setting; see the description for units.

GetBakedLengthfloat
# GetBakedLength
C#
public float GetBakedLength();

Lazily updates the CPU cache and returns approximate baked-polyline length in local units. Empty/single-point curves yield 0; Closed includes the closing segment. Path3D scale is not automatically included.

Returns float

Approximate local CPU-cache length, 0 for empty/single-point curves.

GetBakedPointsVector3[]
# GetBakedPoints
C#
public Vector3[] GetBakedPoints();

Returns an independent C# array of local cached positions, rebuilding first if needed. Array indices are not control-point indices. Samples an approximation rather than original handles.

Returns Vector3[]

New independent C# array of the specified baked/polyline data.

GetBakedTiltsfloat[]
# GetBakedTilts
C#
public float[] GetBakedTilts();

Returns tilt radians aligned with baked positions. Not a list of control-point tilts alone or automatic Entity roll application.

Returns float[]

New independent C# array of the specified baked/polyline data.

GetBakedUpVectorsVector3[]
# GetBakedUpVectors
C#
public Vector3[] GetBakedUpVectors();

Returns baked up vectors; empty when UpVectorEnabled=false. Orientation data rather than terrain surface normals. Array edits do not modify the curve.

Returns Vector3[]

New independent C# array of the specified baked/polyline data.

GetClosestOffsetfloat
# GetClosestOffset
C#
public float GetClosestOffset(Vector3 toPoint);

Returns local distance along the baked polyline to the closest toPoint projection. Neither perpendicular distance to the curve nor segment t. Can require scanning the entire cache.

Parameters
NameTypeDefault
toPointVector3—
toPoint

Finite point in the curve local coordinate system.

Returns float

Distance along the baked path to the closest projection.

GetClosestPointVector3
# GetClosestPoint
C#
public Vector3 GetClosestPoint(Vector3 toPoint);

Projects local toPoint onto the baked polyline by scanning its segments. An approximation, not a physics raycast or guaranteed solution for degenerate segments. Convert world input through Path3D.ToLocal first and the result through ToGlobal if needed.

Parameters
NameTypeDefault
toPointVector3—
toPoint

Finite point in the curve local coordinate system.

Returns Vector3

Local vector/position for the specified query; do not ignore failure diagnostics.

GetPointCountint
# GetPointCount
C#
public int GetPointCount();

Reads the number of control points, including both endpoints of an open curve. Not the segment or baked-sample count.

Returns int

Control-point count, not baked samples.

GetPointInVector3
# GetPointIn
C#
public Vector3 GetPointIn(int idx);

Reads the incoming handle relative to this point position. Absolute Bezier control position = GetPointPosition(idx)+GetPointIn(idx).

Parameters
NameTypeDefault
idxint—
idx

Existing control-point index; for Sample, a segment index.

Returns Vector3

Local vector/position for the specified query; do not ignore failure diagnostics.

GetPointOutVector3
# GetPointOut
C#
public Vector3 GetPointOut(int idx);

Reads the outgoing handle relative to the point position. Neither the next endpoint nor a world coordinate.

Parameters
NameTypeDefault
idxint—
idx

Existing control-point index; for Sample, a segment index.

Returns Vector3

Local vector/position for the specified query; do not ignore failure diagnostics.

GetPointPositionVector3
# GetPointPosition
C#
public Vector3 GetPointPosition(int idx);

Reads an existing control point local position. Returns neither its world position nor the nearest baked sample.

Parameters
NameTypeDefault
idxint—
idx

Existing control-point index; for Sample, a segment index.

Returns Vector3

Local vector/position for the specified query; do not ignore failure diagnostics.

GetPointTiltfloat
# GetPointTilt
C#
public float GetPointTilt(int idx);

Reads the control-point tilt in radians. A roll around path direction, not Entity Euler degrees.

Parameters
NameTypeDefault
idxint—
idx

Existing control-point index; for Sample, a segment index.

Returns float

Stored tilt in radians.

IsClosedbool
# IsClosed
C#
public bool IsClosed();

Reads Closed. Adds a last-to-first segment without duplicating a control point in PointCount. Requires at least two meaningful points. Does not enable automatic SampleBaked looping: distance still clamps to endpoints. RemovePoint clears Closed below two points, while PointCount/ClearPoints can retain it.

Returns bool

Current flag value rather than a geometry-validity guarantee.

IsUpVectorEnabledbool
# IsUpVectorEnabled
C#
public bool IsUpVectorEnabled();

Reads UpVectorEnabled. Enables baked up-vector computation, default true. Used for an up direction along the path and SampleBakedUpVector. Disabling reduces cache data; frame sampling falls back to Vector3.Up, which does not guarantee stability for vertical/degenerate curves. Does not control gravity.

Returns bool

Current flag value rather than a geometry-validity guarantee.

RemovePointvoid
# RemovePoint
C#
public void RemovePoint(int idx);

Removes an existing index and shifts subsequent ones. If Closed and fewer than two points remain, opens the curve. Unlike shrinking PointCount; invalidates the cache and emits Changed.

Parameters
NameTypeDefault
idxint—
idx

Existing control-point index; for Sample, a segment index.

SampleVector3
# Sample
C#
public Vector3 Sample(int idx, float t);

Evaluates a segment Bezier position at parameter t, normally 0..1. Not distance or constant speed: even zero handles do not make t=0.25 a quarter of the length. Open segments are 0..PointCount−2; Closed adds last→first. Out-of-segment endpoint indices can return an endpoint, but use a valid index; do not assume t is clamped.

Parameters
NameTypeDefault
idxint—
tfloat—
idx

Existing control-point index; for Sample, a segment index.

t

Bezier segment parameter, normally 0..1; neither distance nor elapsed time.

Returns Vector3

Local vector/position for the specified query; do not ignore failure diagnostics.

SampleBakedVector3
# SampleBaked
C#
public Vector3 SampleBaked(float offset = 0f, bool cubic = false);

Samples position at finite distance offset along the baked cache. Clamps to 0..GetBakedLength() without looping even when Closed. cubic=true uses cubic cache interpolation, not exact original Bezier sampling, and can differ from linear. Add points first.

Parameters
NameTypeDefault
offsetfloat0f
cubicboolfalse
offset

Finite local-unit distance along the baked cache, not a normalized ratio.

cubic

true enables cubic cache interpolation, default false; not exact reconstruction of the original Bezier.

Returns Vector3

Local vector/position for the specified query; do not ignore failure diagnostics.

SampleBakedUpVectorVector3
# SampleBakedUpVector
C#
public Vector3 SampleBakedUpVector(float offset, bool applyTilt = false);

Samples a local up vector at distance offset; requires UpVectorEnabled and a usable cache. applyTilt defaults to false. Do not use on empty/degenerate curves or treat a diagnosed Vector3.Up fallback as successful sampling.

Parameters
NameTypeDefault
offsetfloat—
applyTiltboolfalse
offset

Finite local-unit distance along the baked cache, not a normalized ratio.

applyTilt

true applies tilt radians to frame/up-vector; false by default.

Returns Vector3

Local vector/position for the specified query; do not ignore failure diagnostics.

SampleBakedWithRotationTransform3D
# SampleBakedWithRotation
C#
public Transform3D SampleBakedWithRotation(float offset = 0f, bool cubic = false, bool applyTilt = false);

Returns a local Transform3D: Origin is the baked position and Basis the orientation frame; forward is −Basis.Z. applyTilt includes tilt roll in radians. Meaningful orientation needs at least two nondegenerate points; one point produces diagnostics. Does not automatically assign an Entity transform.

Parameters
NameTypeDefault
offsetfloat0f
cubicboolfalse
applyTiltboolfalse
offset

Finite local-unit distance along the baked cache, not a normalized ratio.

cubic

true enables cubic cache interpolation, default false; not exact reconstruction of the original Bezier.

applyTilt

true applies tilt radians to frame/up-vector; false by default.

Returns Transform3D

Local Transform3D with forward=−Basis.Z, not a world transform.

SamplefVector3
# Samplef
C#
public Vector3 Samplef(float fofs);

Uses the integer part of fofs as segment index and the fraction as t. Not a normalized whole-curve distance. In 1.0.0 Closed Samplef(PointCount) returns the last-segment start rather than the loop endpoint. Use Sample(PointCount−1,1) or SampleBaked(GetBakedLength()) for the closing endpoint.

Parameters
NameTypeDefault
fofsfloat—
fofs

Segment index plus fractional t; avoid integer upper bound PointCount for Closed.

Returns Vector3

Local vector/position for the specified query; do not ignore failure diagnostics.

SetBakeIntervalvoid
# SetBakeInterval
C#
public void SetBakeInterval(float distance);

Sets BakeInterval. Positive finite CPU-cache density scale, default 0.2 in local units. Smaller usually produces more samples and memory/CPU work. Not a promise of perfectly equal spacing or exact analytic length: subdivision depth is bounded. The setter does not validate positivity/finiteness for you.

Parameters
NameTypeDefault
distancefloat—
distance

Positive finite BakeInterval; the setter does not validate it for you.

SetClosedvoid
# SetClosed
C#
public void SetClosed(bool closed);

Sets Closed. Adds a last-to-first segment without duplicating a control point in PointCount. Requires at least two meaningful points. Does not enable automatic SampleBaked looping: distance still clamps to endpoints. RemovePoint clears Closed below two points, while PointCount/ClearPoints can retain it.

Parameters
NameTypeDefault
closedbool—
closed

true adds last→first; does not enable distance wrapping.

SetPointCountvoid
# SetPointCount
C#
public void SetPointCount(int count);

Sets PointCount. Control-point count, not baked-sample count. Growth appends zero positions/handles/tilts; shrinking truncates the end. Changed can occur per appended point rather than one atomic path replacement. Shrinking through PointCount does not automatically clear Closed; validate configuration yourself.

Parameters
NameTypeDefault
countint—
count

Nonnegative control-point count; growth appends zero data.

SetPointInvoid
# SetPointIn
C#
public void SetPointIn(int idx, Vector3 position);

Sets an existing point relative incoming handle. It forms no preceding segment at an open curve first point; Closed uses it for the closing segment. Invalidates the cache.

Parameters
NameTypeDefault
idxint—
positionVector3—
idx

Existing control-point index; for Sample, a segment index.

position

Finite local position; SetPointIn/Out take a relative handle rather than an endpoint.

SetPointOutvoid
# SetPointOut
C#
public void SetPointOut(int idx, Vector3 position);

Sets an existing point relative outgoing handle. It creates no extra segment at an open curve last point; Closed uses it to return to the first. Invalidates the cache.

Parameters
NameTypeDefault
idxint—
positionVector3—
idx

Existing control-point index; for Sample, a segment index.

position

Finite local position; SetPointIn/Out take a relative handle rather than an endpoint.

SetPointPositionvoid
# SetPointPosition
C#
public void SetPointPosition(int idx, Vector3 position);

Changes an existing point local position while retaining relative handles/tilt. Invalidates the CPU cache and emits Changed. Every owner of a shared resource sees the edit.

Parameters
NameTypeDefault
idxint—
positionVector3—
idx

Existing control-point index; for Sample, a segment index.

position

Finite local position; SetPointIn/Out take a relative handle rather than an endpoint.

SetPointTiltvoid
# SetPointTilt
C#
public void SetPointTilt(int idx, float tilt);

Sets finite tilt in radians and invalidates the cache. Orientation sampling applies it only with applyTilt=true; position itself does not change.

Parameters
NameTypeDefault
idxint—
tiltfloat—
idx

Existing control-point index; for Sample, a segment index.

tilt

Finite roll in radians rather than degrees.

SetUpVectorEnabledvoid
# SetUpVectorEnabled
C#
public void SetUpVectorEnabled(bool enable);

Sets UpVectorEnabled. Enables baked up-vector computation, default true. Used for an up direction along the path and SampleBakedUpVector. Disabling reduces cache data; frame sampling falls back to Vector3.Up, which does not guarantee stability for vertical/degenerate curves. Does not control gravity.

Parameters
NameTypeDefault
enablebool—
enable

Enables baked up vectors, not world-up or gravity.

TessellateVector3[]
# Tessellate
C#
public Vector3[] Tessellate(int maxStages = 5, float toleranceDegrees = 4f);

Returns a local polyline from adaptive subdivision using toleranceDegrees as an angular criterion. maxStages limits depth rather than exact point count. Changes no control points and promises neither equal intervals nor exact length. Closed output returns to the first point.

Parameters
NameTypeDefault
maxStagesint5
toleranceDegreesfloat4f
maxStages

Sensible nonnegative subdivision depth; larger costs more work/memory.

toleranceDegrees

Positive finite angular tolerance in degrees, bounded by maxStages.

Returns Vector3[]

New independent C# array of the specified baked/polyline data.

TessellateEvenLengthVector3[]
# TessellateEvenLength
C#
public Vector3[] TessellateEvenLength(int maxStages = 5, float toleranceLength = 0.2f);

Returns a local polyline from length-based toleranceLength subdivision bounded by maxStages. “Even” guarantees neither perfectly identical spacing nor tolerance after reaching the depth limit. Requires at least two points and changes no source data.

Parameters
NameTypeDefault
maxStagesint5
toleranceLengthfloat0.2f
maxStages

Sensible nonnegative subdivision depth; larger costs more work/memory.

toleranceLength

Positive finite length criterion in local units, bounded by maxStages.

Returns Vector3[]

New independent C# array of the specified baked/polyline data.

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.