Streams

Streams are the core of the data structure for the RMC. They hold a single data type, like FVector3f or FColor, and they can handle 1-8 elements. They are 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 it’s generally not the best way. Usually you’ll want a FRealtimeMeshStreamSet


Stream Key

FRealtimeMeshStreamKey is a way of identifying the stream within things like a StreamSet, or to the RMC itself. It contains the StreamType, either Vertex or Index, as well as a stream name.

Some common stream keys

  • Vertex:Position - Contains the vertex position data
  • Vertex:Tangents - Contains the tangents, both TangentZ and TangentX, of the vertex data
  • Vertex:TexCoords - Contains the Texture Coordinates for 1-8 channels
  • Vertex::Colors - Contains the vertex color data
  • Index:Triangles - Contains the indexing data for a triangle list
  • Index:PolyGroups - Contains the poly group id for each triangle

Creating a Stream
// For example, this will create a stream with the key `Vertex:Position` and the datatype of FVector3f
auto PositionStream = FRealtimeMeshStream::Create<FVector3f>(FRealtimeMeshStreams::Position);

Bulk Adding Data
// If you have an array like the following (assuming it's filled with data)
TArray<FVector3f> IncomingData;

// You could add all of this at once through
PositionStream.Append(IncomingData);

Miscellaneous Helpers
// Fill the stream starting at position 10 and running for 20 elements with a default value
PositionStream.FillRange(10, 20, FVector3f(0, 0, 1));

// Zero a range of the stream starting at index 10 and running the next 20 elements
PositionStream.ZeroRange(10, 20);

// Preallocate the stream to hold 128 rows, this can cut down on reallocation and data copying.
PositionStream.Reserve(128);