I3DHInteractiveSplatDrawing.h Source File

I3DHInteractiveSplatDrawing.h Source File#

instant3Dhub: I3DHInteractiveSplatDrawing.h Source File
instant3Dhub
I3DHInteractiveSplatDrawing.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "CoreMinimal.h"
9
10#include "I3DHAsyncTaskFence.h"
11#include "I3DHError.h"
12#include "I3DHVersion.h"
13
14#include "Components/InstancedStaticMeshComponent.h"
15#include "GameFramework/Actor.h"
16#include "Templates/RefCounting.h"
17
18#include "I3DHInteractiveSplatDrawing.generated.h"
19
20class AI3DHConnector;
21
22DECLARE_DYNAMIC_DELEGATE_TwoParams(FSplatDrawingCreatedDelegate, const FI3DHDrawingResult&, DrawingResult, const FI3DHDrawingProperties&, DrawingProperties);
23
24class INSTANT3DHUB_EXPERIMENTAL(0.0.27, "The instant3Dhub Drawings feature is available as a preview and is actively under development.") AI3DHInteractiveSplatDrawing;
25
46UCLASS(Experimental, Abstract, NotPlaceable, meta = (DisplayName = "I3DH Interactive SplatDrawing (Experimental)"))
47class INSTANT3DHUBDRAWINGS_API AI3DHInteractiveSplatDrawing : public AActor
48{
49 GENERATED_BODY()
50
51public:
52 // Sets default values for this actor's properties
53 AI3DHInteractiveSplatDrawing();
54
61 UFUNCTION(BlueprintCallable, meta = (DefaultToSelf = "HubConnector", DeterminesOutputType = "DrawingClass"), Category = "{instant3DhubDrawings}")
62 static AI3DHInteractiveSplatDrawing* CreateInteractiveSplatDrawing(AI3DHConnector* HubConnector, TSubclassOf<AI3DHInteractiveSplatDrawing> DrawingClass = nullptr);
63
68 void InitializePreSpawn(AI3DHConnector* ParentHubConnector);
69
74 UFUNCTION(BlueprintPure, Category = "{instant3DhubDrawings}")
75 AI3DHConnector* GetHubConnector() const { return HubConnector; }
76
81 UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "Color"), Category = "{instant3DhubDrawings}")
83
88 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3DhubDrawings}")
90
95 UFUNCTION(BlueprintCallable, Category = "{instant3DhubDrawings}")
96 void SetBrushHiddenInGame(bool bIsHiddenInGame);
97
105 UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "{instant3DhubDrawings}")
106 void MoveBrushTo(const FVector& Location, const FVector& Normal, const FVector& Scale) const;
107
112 UFUNCTION(BlueprintCallable, Category = "{instant3DhubDrawings}")
114
120 UFUNCTION(BlueprintCallable, Category = "{instant3DhubDrawings}")
121 void EraseAtBrush(bool bEraseAllColors = false);
122
127 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "{instant3DhubDrawings}")
128 bool IsEmpty() const;
129
131 UFUNCTION(BlueprintCallable, Category = "{instant3DhubDrawings}")
132 void Clear();
133
141
152 void CreateHubDrawingAndDestroy(const FString& Name, TUniqueFunction<void(int32 DrawingHandle, EI3DHErrorCode ErrorCode)> OnComplete);
153
155 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3DhubDrawings}")
156 double MinBrushDist = 0.25;
157
159 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3DhubDrawings}")
160 double EraserRelativeSize = 0.75;
161
166 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3DhubDrawings}")
167 double DrawingNormalOffset = 0.01;
168
170 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "{instant3DhubDrawings}")
172
173protected:
174 // Called when the game starts or when spawned
175 virtual void BeginPlay() override;
176
177 virtual bool IsReadyForFinishDestroy() override { return Super::IsReadyForFinishDestroy() && (!AsyncTaskFence.IsValid() || AsyncTaskFence->GetRefCount() <= 1); }
178
179private:
180 UPROPERTY()
181 AI3DHConnector* HubConnector;
182
183 UPROPERTY(EditDefaultsOnly, Category = "{instant3DhubDrawings}")
184 UStaticMeshComponent* BrushMesh;
185
186 UPROPERTY(EditDefaultsOnly, Category = "{instant3DhubDrawings}")
187 FLinearColor DefaultColor = FLinearColor::Yellow;
188
189 UPROPERTY()
190 TMap<UMaterialInterface*, UInstancedStaticMeshComponent*> MaterialToInstancedStaticMesh;
191
192 UPROPERTY()
193 bool bIsFinalized{false};
194
195 // Keeps track how many instances are drawn.
196 int32 NumRenderInstances = 0;
197
198 TRefCountPtr<FI3DHAsyncTaskFence> AsyncTaskFence{nullptr};
199};
EI3DHErrorCode
Enumeration of Error Codes returned from various instant3Dhub API Calls.
Definition I3DHError.h:16
The HubConnector is the central actor for communication with an instant3Dhub instance in your network...
Definition I3DHConnector.h:214
A helper for creating splat-based drawings in the scene that are synced to the session when finished.
Definition I3DHInteractiveSplatDrawing.h:48
double DrawingNormalOffset
Offset along the normal when moving the brush (in world units).
Definition I3DHInteractiveSplatDrawing.h:167
void SetBrushHiddenInGame(bool bIsHiddenInGame)
Sets the brush to be hidden in game.
FLinearColor GetBrushAndEraserColor() const
Gets brush and eraser color.
static AI3DHInteractiveSplatDrawing * CreateInteractiveSplatDrawing(AI3DHConnector *HubConnector, TSubclassOf< AI3DHInteractiveSplatDrawing > DrawingClass=nullptr)
Creates an actor which can be used for drawing and syncing to the Hub when finished.
double MinBrushDist
Minimum distance of two instances in units of current relative scale of the brush (minimum of {x,...
Definition I3DHInteractiveSplatDrawing.h:156
bool IsEmpty() const
Query if this Drawing is empty.
void Clear()
Clears this drawing to its blank/initial state.
void SetBrushAndEraserColor(const FLinearColor &Color)
Sets brush and eraser color.
void InitializePreSpawn(AI3DHConnector *ParentHubConnector)
Call before (deferred) spawning.
void DrawAtBrush()
Adds the current brush transformation to the drawing.
void EraseAtBrush(bool bEraseAllColors=false)
Uses the eraser at the current brush transformation for either the active color or every color.
void MoveBrushTo(const FVector &Location, const FVector &Normal, const FVector &Scale) const
Set a new location of the brush.
void FinalizeDrawing(TUniqueFunction< void(FI3DHDrawingResult)> OnComplete)
Finalizes the drawing and builds the drawing geometry.
double EraserRelativeSize
Size of the erase in units of current relative scale of the brush (minimum of {x,y,...
Definition I3DHInteractiveSplatDrawing.h:160
AI3DHConnector * GetHubConnector() const
Returns the parent hub connector.
Definition I3DHInteractiveSplatDrawing.h:75
FString ThumbnailBase64DataURI
Data-URI string, e.g.
Definition I3DHInteractiveSplatDrawing.h:171
void CreateHubDrawingAndDestroy(const FString &Name, TUniqueFunction< void(int32 DrawingHandle, EI3DHErrorCode ErrorCode)> OnComplete)
Finalizes the drawing, synchronizes it with the hub and destroys this actor.
#define INSTANT3DHUB_EXPERIMENTAL(Version, Message)
Macro for marking up experimental code, functions and types.
Definition I3DHVersion.h:246
instant3Dhub drawing properties.
Definition I3DHDataTypes.h:1995
Encapsulates the result of an instant3Dhub drawing.
Definition I3DHDataTypes.h:2093