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.
Stream Key
Section titled “Stream Key”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 dataFRealtimeMeshStreams::PositionPrev— (Vertex) previous-frame positions; its presence enables motion-vector output for deforming meshesFRealtimeMeshStreams::Tangents— (Vertex) tangents, both Tangent-Z (normal) and Tangent-XFRealtimeMeshStreams::TexCoords— (Vertex) texture coordinates, for 1-8 channelsFRealtimeMeshStreams::Color— (Vertex) vertex color dataFRealtimeMeshStreams::Triangles— (Index) the indexing data for the triangle listFRealtimeMeshStreams::DepthOnlyTriangles— (Index) an optional simplified index list used for depth/shadow passesFRealtimeMeshStreams::PolyGroups— (Index) the poly group id for each triangleFRealtimeMeshStreams::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.
Creating a Stream
Section titled “Creating a Stream”using namespace RealtimeMesh;
// This creates a stream with the key `Vertex:Position` and the data type FVector3f.FRealtimeMeshStream PositionStream = FRealtimeMeshStream::Create<FVector3f>(FRealtimeMeshStreams::Position);Bulk Adding Data
Section titled “Bulk Adding Data”// 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 AppendPositionStream.Append(IncomingData);Append is overloaded for TArray, TArrayView, an initializer list, and another FRealtimeMeshStream, so you can append from whichever source is convenient.
Miscellaneous Helpers
Section titled “Miscellaneous Helpers”// 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.