Quickstart
This walks through the minimal path to get a triangle rendering with RMC: a C++ actor that builds its own mesh. It follows the same pipeline as the plugin’s own ARealtimeMeshExample_Simple_HelloTriangle example (Source/RealtimeMeshExamples/Private/Simple/RealtimeMeshExample_Simple_HelloTriangle.cpp), so you can cross-reference the full working source at any point.
Prerequisites
Section titled “Prerequisites”You need a C++-ready Unreal project with the plugin installed (see Installation) and RealtimeMeshComponent added to your module’s Build.cs:
PublicDependencyModuleNames.Add("RealtimeMeshComponent");1. Derive from ARealtimeMeshActor
Section titled “1. Derive from ARealtimeMeshActor”ARealtimeMeshActor owns a URealtimeMeshComponent for you (mobility, collision profile, root component are already wired up). Create a new actor class that derives from it:
#pragma once
#include "CoreMinimal.h"#include "RealtimeMeshActor.h"#include "MyFirstMesh.generated.h"
UCLASS()class MYGAME_API AMyFirstMesh : public ARealtimeMeshActor{ GENERATED_BODY()
protected: virtual void OnConstruction(const FTransform& Transform) override;};Building the mesh in OnConstruction means it renders immediately when you drop the actor into a level or move it around in the editor — this is what every shipped example does. If your mesh generation is expensive and you don’t want it re-running on every editor drag, set bDeferGeneration = true (a property on ARealtimeMeshActor) and build the mesh in an override of OnGenerateMesh_Implementation() instead — it only fires when a rebuild is explicitly requested.
2. Initialize the mesh and build a StreamSet
Section titled “2. Initialize the mesh and build a StreamSet”In OnConstruction, initialize the component with the URealtimeMeshSimple leaf type — the general-purpose, CPU-authored mesh type, closest in behavior to ProceduralMeshComponent:
#include "MyFirstMesh.h"#include "RealtimeMeshSimple.h"
using namespace RealtimeMesh;
void AMyFirstMesh::OnConstruction(const FTransform& Transform){ Super::OnConstruction(Transform);
URealtimeMeshSimple* RealtimeMesh = GetRealtimeMeshComponent()->InitializeRealtimeMesh<URealtimeMeshSimple>();
// The StreamSet holds the raw buffers: positions, tangents, texcoords, triangles, etc. FRealtimeMeshStreamSet StreamSet;
// TRealtimeMeshBuilderLocal is a helper that writes into a StreamSet's buffers for you. // Template args: index type, tangent type, texcoord type, number of UV channels. TRealtimeMeshBuilderLocal<uint16, FPackedNormal, FVector2DHalf, 1> Builder(StreamSet);
Builder.EnableTangents(); Builder.EnableTexCoords(); Builder.EnableColors(); Builder.EnablePolyGroups();
const int32 V0 = Builder.AddVertex(FVector3f(-50.0f, 0.0f, 0.0f)) .SetNormalAndTangent(FVector3f(0.0f, -1.0f, 0.0f), FVector3f(1.0f, 0.0f, 0.0f)) .SetColor(FColor::Red) .SetTexCoord(FVector2f(0.0f, 0.0f));
const int32 V1 = Builder.AddVertex(FVector3f(0.0f, 0.0f, 100.0f)) .SetNormalAndTangent(FVector3f(0.0f, -1.0f, 0.0f), FVector3f(1.0f, 0.0f, 0.0f)) .SetColor(FColor::Green) .SetTexCoord(FVector2f(0.5f, 1.0f));
const int32 V2 = Builder.AddVertex(FVector3f(50.0f, 0.0f, 0.0f)) .SetNormalAndTangent(FVector3f(0.0f, -1.0f, 0.0f), FVector3f(1.0f, 0.0f, 0.0f)) .SetColor(FColor::Blue) .SetTexCoord(FVector2f(1.0f, 0.0f));
// Add the triangle, tagged into poly group 0. Builder.AddTriangle(V0, V1, V2, 0);A few things worth calling out:
RealtimeMesh::needs to be in scope (using namespace RealtimeMesh;) forFRealtimeMeshStreamSetand the builder types.AddVertexreturns a handle you chain.Set...()calls onto to fill in per-vertex data.EnablePolyGroups()lets you tag triangles so oneStreamSetcan back multiple sections — see Poly Groups in Key Concepts.
3. Set up materials and create the section group
Section titled “3. Set up materials and create the section group”Material slots are set up on the mesh object, then a section group is created from the StreamSet:
// One material slot per poly group used above. RealtimeMesh->SetupMaterialSlot(0, "PrimaryMaterial");
const FRealtimeMeshBufferSetKey GroupKey = FRealtimeMeshBufferSetKey::Create(0, FName("MyTriangle"));
// Because the StreamSet has poly groups enabled, this auto-creates one section per poly group. RealtimeMesh->CreateBufferSet(GroupKey, MoveTemp(StreamSet));}CreateBufferSet takes the StreamSet by rvalue reference — pass it with MoveTemp (as above) or construct it in place; the section group takes ownership of the buffers rather than copying them.
At this point, compiling and placing AMyFirstMesh in a level renders a single triangle using whatever material you assign to the PrimaryMaterial slot in the actor’s details panel.
Next steps
Section titled “Next steps”- Key Concepts — streams, stream sets, and the builder types in more depth.
- Component Core — materials, LODs, sections, and updating mesh data after the initial build.
- Examples — every shipped example actor, from this same triangle to Nanite and spatial streaming.