Skip to content
PRODUCT GITHUB  ↗

Streams

Streams are the core of the RMC data structure. A stream (FRealtimeMeshStream) holds a single data type, like FVector3f or FColor, and each row can contain 1-8 elements. A stream is meant to hold a single data component — whether that’s positions, tangents, colors, texture coordinates, triangles, or something custom. You can work directly with a stream, but that’s usually not the most convenient way; most of the time you’ll wrap it in a stream builder and store it in a stream set.

Streams live in the RealtimeMesh namespace and are declared in Interface/Core/RealtimeMeshDataStream.h.


FRealtimeMeshStreamKey identifies a stream within a stream set, or to the RMC itself. It combines a stream type — either Vertex or Index (ERealtimeMeshStreamType) — with a stream name.

The RMC’s well-known stream keys are collected in the FRealtimeMeshStreams struct so you don’t have to spell out the names yourself:

  • FRealtimeMeshStreams::Position — (Vertex) vertex position data
  • FRealtimeMeshStreams::PositionPrev — (Vertex) previous-frame positions; its presence enables motion-vector output for deforming meshes
  • FRealtimeMeshStreams::Tangents — (Vertex) tangents, both Tangent-Z (normal) and Tangent-X
  • FRealtimeMeshStreams::TexCoords — (Vertex) texture coordinates, for 1-8 channels
  • FRealtimeMeshStreams::Color — (Vertex) vertex color data
  • FRealtimeMeshStreams::Triangles — (Index) the indexing data for the triangle list
  • FRealtimeMeshStreams::DepthOnlyTriangles — (Index) an optional simplified index list used for depth/shadow passes
  • FRealtimeMeshStreams::PolyGroups — (Index) the poly group id for each triangle
  • FRealtimeMeshStreams::DepthOnlyPolyGroups — (Index) the poly group id for each depth-only triangle

There are a few more specialized keys on FRealtimeMeshStreams (for example ReversedTriangles, ReversedDepthOnlyTriangles, and the PolyGroupSegments variants) that the RMC uses internally, but the ones above are what you’ll work with directly.


using namespace RealtimeMesh;
// This creates a stream with the key `Vertex:Position` and the data type FVector3f.
FRealtimeMeshStream PositionStream = FRealtimeMeshStream::Create<FVector3f>(FRealtimeMeshStreams::Position);

// If you have an array like the following (assuming it's filled with data)
TArray<FVector3f> IncomingData;
// You can add all of it at once through Append
PositionStream.Append(IncomingData);

Append is overloaded for TArray, TArrayView, an initializer list, and another FRealtimeMeshStream, so you can append from whichever source is convenient.


// Fill the stream starting at index 10 and running for 20 rows with a value.
PositionStream.FillRange(10, 20, FVector3f(0, 0, 1));
// Zero a range of the stream starting at index 10 and running the next 20 rows.
PositionStream.ZeroRange(10, 20);
// Preallocate the stream to hold 128 rows. This can cut down on reallocation and data copying.
PositionStream.Reserve(128);

The stream also exposes lower-level operations — Num, SetNumUninitialized/SetNumZeroed, AddUninitialized/AddZeroed, RemoveAt, Empty, Shrink, and ConvertTo to change the stored layout — but for day-to-day building you’ll usually reach for a stream builder instead.