CARLA
Loading...
Searching...
No Matches
ProceduralVegetationTool.h
Go to the documentation of this file.
1#pragma once
2
3#include "CoreMinimal.h"
4#include "GameFramework/Actor.h"
5#include "PCGSettings.h"
6#include "ProceduralVegetationTool.generated.h"
7
8class UBoxComponent;
9class UPCGComponent;
10class UPCGGraphInterface;
11class UInstancedStaticMeshComponent;
12
13USTRUCT(BlueprintType)
15{
16 GENERATED_BODY()
17 UPROPERTY(VisibleAnywhere, BlueprintReadOnly) FString Id;
18 UPROPERTY(VisibleAnywhere, BlueprintReadOnly) FString Provenance;
19 UPROPERTY(VisibleAnywhere, BlueprintReadOnly) FTransform Transform;
20 UPROPERTY(VisibleAnywhere, BlueprintReadOnly) TSoftObjectPtr<UStaticMesh> Mesh;
21 UPROPERTY(VisibleAnywhere, BlueprintReadOnly) int32 Seed = 0;
22};
23
24/** Editor preview and persistent bake for validated TwinModel vegetation plans. */
25UCLASS(BlueprintType)
26class CARLA_API AProceduralVegetationTool : public AActor
27{
28 GENERATED_BODY()
29public:
31
32 UPROPERTY(VisibleAnywhere, Category="Vegetation") TObjectPtr<UBoxComponent> GenerationBounds;
33 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Vegetation") FFilePath PlanFile;
34 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Vegetation") TSoftObjectPtr<UPCGGraphInterface> Graph;
35 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Vegetation") TObjectPtr<UPCGComponent> PCG;
36 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Vegetation") FString Status;
37 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Vegetation") TArray<FCarlaVegetationPoint> Points;
38 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Vegetation") int32 BakedInstanceCount = 0;
39
40 UFUNCTION(BlueprintCallable, CallInEditor, Category="Vegetation") bool ImportPlan();
41 UFUNCTION(BlueprintCallable, CallInEditor, Category="Vegetation") void Preview();
42 UFUNCTION(BlueprintCallable, CallInEditor, Category="Vegetation") bool Bake();
43 UFUNCTION(BlueprintCallable, CallInEditor, Category="Vegetation") void ClearGenerated();
44 UFUNCTION(BlueprintPure, Category="Vegetation") int32 PreviewInstanceCount() const;
45 UFUNCTION(BlueprintPure, Category="Vegetation") bool IsGenerating() const;
46 UFUNCTION(BlueprintCallable, Category="Vegetation") void TickCommandletGeneration();
47
48private:
49 UFUNCTION() void OnGenerated(UPCGComponent* Component);
50 UPROPERTY(VisibleAnywhere, Instanced, Category="Vegetation") TArray<TObjectPtr<UInstancedStaticMeshComponent>> BakedComponents;
51 UPROPERTY() bool bPreviewReady = false;
52};
53
54/** Emits validated plan points with Mesh, SourceId, Provenance and stable seeds. */
55UCLASS(BlueprintType, ClassGroup=(Procedural))
57{
58 GENERATED_BODY()
59public:
60#if WITH_EDITOR
61 virtual FName GetDefaultNodeName() const override { return TEXT("CarlaVegetationPlan"); }
62 virtual FText GetDefaultNodeTitle() const override { return FText::FromString(TEXT("CARLA Vegetation Plan")); }
63 virtual EPCGSettingsType GetType() const override { return EPCGSettingsType::InputOutput; }
64#endif
65protected:
66 virtual TArray<FPCGPinProperties> InputPinProperties() const override { return {}; }
67 virtual TArray<FPCGPinProperties> OutputPinProperties() const override { return DefaultPointOutputPinProperties(); }
68 virtual FPCGElementPtr CreateElement() const override;
69};
Editor preview and persistent bake for validated TwinModel vegetation plans.
UPROPERTY(VisibleAnywhere, Category="Vegetation") TObjectPtr< UBoxComponent > GenerationBounds
Emits validated plan points with Mesh, SourceId, Provenance and stable seeds.
virtual TArray< FPCGPinProperties > OutputPinProperties() const override
virtual TArray< FPCGPinProperties > InputPinProperties() const override