From bb70527107cc24a09eb478b6d8507edeb20acf2f Mon Sep 17 00:00:00 2001 From: Rob B Date: Wed, 4 Dec 2024 21:40:13 -0500 Subject: [PATCH] Custom visualizations in machine holograms example from Beaver --- .../Satisfactory/BuildableHolograms.adoc | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/modules/ROOT/pages/Development/Satisfactory/BuildableHolograms.adoc b/modules/ROOT/pages/Development/Satisfactory/BuildableHolograms.adoc index cab28523..494b5330 100644 --- a/modules/ROOT/pages/Development/Satisfactory/BuildableHolograms.adoc +++ b/modules/ROOT/pages/Development/Satisfactory/BuildableHolograms.adoc @@ -502,3 +502,44 @@ bool AMyModHologram::TryUpgrade(const FHitResult& hitResult) return Super::TryUpgrade(hitResult); } ``` + +== Showing Additional Visualizations + +Blueprint Machine Holograms can spawn custom visuals to assist the user with placement of some buildable objects. +Using a custom visualization replaces the default visualization. +This approach is commonly used when a custom buildable requires extra settings and configuration to look correct. +Consider the following example: + +```cpp +void FMyModModule::StartupModule() { + AFGBlueprintHologram::FCreateBuildableVisualizationDelegate visualizingDelegate; + visualizingDelegate.BindLambda([](AFGBlueprintHologram* blueprintHologram, AFGBuildable* buildable, USceneComponent* buildableRootComponent) { + // Get your buildable + AMyBuildable* myBuildable = Cast(buildable); + + // - your cool code here for all the relevant components- + // likely involves referencing stuff myBuildable + // note that the buildable reference is only scoped to this lambda so don't expect it to persist + + // example: if we had one custom spline mesh component to show it might look like this: + USplineMeshComponent* splineMesh = Cast( + // we use the built in setup component so we don't have to worry about things like: attaching to the actor, transformations, mobility, customizer data, hologramFX, collision channels, and more you would need to set manually if you didn't + blueprintHologram->SetupComponent( + buildableRootComponent, + buildable->GetComponentByClass(), + buildable->GetFName(), + FName() + ) + ); + + // example: now do the configuration the vanilla configuration won't, since we are using a custom one + splineMesh->SetStartPosition(curve->StartPosition, false); + splineMesh->SetEndPosition(curve->EndPosition, false); + splineMesh->SetStartTangent(curve->StartTangent, false); + splineMesh->SetEndTangent(curve->EndTangent, false); + splineMesh->UpdateMesh_Concurrent(); + }); + + AFGBlueprintHologram::RegisterCustomBuildableVisualization(AABCurvedDecorBuildable::StaticClass(), visualizingDelegate); +} +```