I3DHDrawing.h Source File

I3DHDrawing.h Source File#

instant3Dhub: I3DHDrawing.h Source File
instant3Dhub
I3DHDrawing.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "CoreMinimal.h"
9
10#include "I3DHDataTypes.h"
11
12#include "GameFramework/Actor.h"
13#include "UObject/Object.h"
14
15#include "I3DHDrawing.generated.h"
16
19class UBodySetup;
20
27USTRUCT()
28struct FI3DHDrawingGeometryRenderState
29{
30 GENERATED_BODY()
31
32 UPROPERTY(Category = "{instant3Dhub}|Drawing", VisibleAnywhere, Transient);
33 TArray<TObjectPtr<class UI3DHDrawingRendererBase>> DrawingRendererArray;
34
35 UPROPERTY(Category = "{instant3Dhub}|Drawing", VisibleAnywhere, Transient);
36 FLinearColor DrawingColor{FLinearColor::Yellow};
37};
38
40
45UCLASS(NotPlaceable, MinimalAPI)
46class AI3DHDrawing : public AActor
47{
48 GENERATED_BODY()
49
50 friend class UI3DHEditDrawingGeometryProvider;
51
52public:
53 // ----------------------------------------------------------
54 // AI3DHDrawing API
55 // ----------------------------------------------------------
56 INSTANT3DHUB_API AI3DHDrawing();
57
62 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Drawing")
63 FORCEINLINE int32 GetDrawingHandle() const { return DrawingHandle; }
64
69 FORCEINLINE class AI3DHConnector* GetHubConnector() const { return Connector.Get(); }
70
72 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing")
73 INSTANT3DHUB_API virtual void OnHoverStart();
74
76 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Drawing")
77 INSTANT3DHUB_API virtual void OnHoverEnd();
78
79 INSTANT3DHUB_DEPRECATED(1.1.0, "GetHoveredMaterial is no longer used.")
80 INSTANT3DHUB_API virtual UMaterialInterface* GetHoveredMaterial(const FLinearColor& DrawingColor) const { return nullptr; }
81
87 INSTANT3DHUB_API void SetDrawingVisibilityOverride(const bool bIsVisible);
88
90 INSTANT3DHUB_API void ClearDrawingVisibilityOverride();
91
92public:
93 // ----------------------------------------------------------
94 // Internal
95 // ----------------------------------------------------------
96
97 // Call before spawning:
98 void SetHubConnector(class AI3DHConnector* InHubConnector);
99 void SetDrawingHandle(int32 InDrawingHandle);
100
101 // Call once after spawning. Creates the components to render the passed in InDrawingResult.
102 void BuildFromDrawingResult(FI3DHDrawingResult InDrawingResult);
104 bool HasDrawingResult() const { return bHasDrawingResult; }
105
106 void MarkAsInternallyCreated() { bWasInternallyCreated = true; }
107 bool WasInternallyCreated() const { return bWasInternallyCreated; }
108
109 void ApplyDrawingProperties(const struct FI3DHDrawingProperties& Properties);
110
111 const FI3DHDrawingResult* GetCachedDrawingResult() const;
112 TUniquePtr<FI3DHDrawingResult> TakeCachedDrawingResult();
113 void SetCachedDrawingResult(TUniquePtr<FI3DHDrawingResult> DrawingResult);
114
115 const FI3DHDrawingProperties& GetCachedDrawingProperties() const;
116
117private:
118 void ApplyDrawingVisibility();
119
120public:
125 UPROPERTY(Category = "{instant3Dhub}|Drawing", EditDefaultsOnly, BlueprintReadWrite, meta = (DisplayAfter = "bCreateDrawingCollisions", EditCondition = "bCreateDrawingCollisions", EditConditionHides))
127
129 UPROPERTY(Category = "{instant3Dhub}|Drawing", EditDefaultsOnly, BlueprintReadWrite, meta = (DisplayName = "Create Drawing Collisions"))
131
132private:
134 uint8 bHasDrawingResult : 1;
136 uint8 bWasInternallyCreated : 1;
137 uint8 bIsDrawingEnabled : 1;
138 uint8 bIsHovered : 1;
139
140 TOptional<bool> bDrawingVisibilityOverride;
141
142private:
143 TWeakObjectPtr<class AI3DHConnector> Connector;
144
145 UPROPERTY(Category = "{instant3Dhub}|Drawing", VisibleAnywhere)
146 int32 DrawingHandle{INDEX_NONE};
147
148 UPROPERTY(Transient)
149 TArray<struct FI3DHDrawingGeometryRenderState> DrawingGeometryRenderStateArray;
150
152 TUniquePtr<FI3DHDrawingResult> CachedDrawingResult{nullptr};
153
155 FI3DHDrawingProperties CachedDrawingProperties;
156};
157
159
160struct FCreateDrawingRenderContext;
161
162/* Base class for rendering support of drawing geometry. */
163
164UCLASS(Abstract, EditInlineNew, DefaultToInstanced, Transient)
165class UI3DHDrawingRendererBase : public UObject
166{
167 GENERATED_BODY()
168
169public:
170 virtual bool IsRenderStateCreated() const PURE_VIRTUAL(UI3DHDrawingRendererBase::IsRenderStateCreated, return false;);
171 virtual void CreateRenderState(const FCreateDrawingRenderContext& Context) PURE_VIRTUAL(UI3DHDrawingRendererBase::CreateRenderState, );
172 virtual void UpdateMaterial(UMaterialInterface* Material) const PURE_VIRTUAL(UI3DHDrawingRendererBase::UpdateMaterial, );
173 virtual void UpdateMaterialParameters(const FLinearColor& Color, const bool bIsHovered) const PURE_VIRTUAL(UI3DHDrawingRendererBase::SetHovered, );
174};
175
181UCLASS()
182class UI3DHTriangleDrawingRenderer : public UI3DHDrawingRendererBase
183{
184 GENERATED_BODY()
185
186protected:
187 UPROPERTY(Category = "{instant3Dhub}|Drawing", VisibleAnywhere, Transient)
188 TObjectPtr<UStaticMeshComponent> TriangleDrawingComponent{nullptr};
189
190 UPROPERTY(Transient)
191 TObjectPtr<UBodySetup> AsyncCookBodySetup{nullptr};
192
193public:
194 virtual bool IsRenderStateCreated() const override;
195 virtual void CreateRenderState(const FCreateDrawingRenderContext& Context) override;
196 virtual void UpdateMaterial(UMaterialInterface* Material) const override;
197 virtual void UpdateMaterialParameters(const FLinearColor& Color, const bool bIsHovered) const override;
198
199private:
200 void FinishPhysicsAsyncCook(bool bSuccess, UBodySetup* FinishedBodySetup);
201};
202
208UCLASS()
209class UI3DHLineSegmentDrawingRenderer : public UI3DHDrawingRendererBase
210{
211 GENERATED_BODY()
212
213protected:
214 UPROPERTY(Category = "{instant3Dhub}|Drawing", VisibleAnywhere, Transient)
215 TObjectPtr<UInstancedStaticMeshComponent> InstancedStaticMeshComponent{nullptr};
216
217public:
218 virtual bool IsRenderStateCreated() const override;
219 virtual void CreateRenderState(const FCreateDrawingRenderContext& Context) override;
220 virtual void UpdateMaterial(UMaterialInterface* Material) const override;
221 virtual void UpdateMaterialParameters(const FLinearColor& Color, const bool bIsHovered) const override;
222};
223
229UCLASS()
230class UI3DHPointDrawingRenderer : public UI3DHDrawingRendererBase
231{
232 GENERATED_BODY()
233
234protected:
235 UPROPERTY(Category = "{instant3Dhub}|Drawing", VisibleAnywhere, Transient)
236 TObjectPtr<UInstancedStaticMeshComponent> InstancedStaticMeshComponent{nullptr};
237
238public:
239 virtual bool IsRenderStateCreated() const override;
240 virtual void CreateRenderState(const FCreateDrawingRenderContext& Context) override;
241 virtual void UpdateMaterial(UMaterialInterface* Material) const override;
242 virtual void UpdateMaterialParameters(const FLinearColor& Color, const bool bIsHovered) const override;
243};
244
EI3DHGlPrimitiveType
Enumeration of Primitive types.
Definition I3DHDataTypes.h:1974
@ LINE_STRIP
Line strip enum value.
Definition I3DHDataTypes.h:1982
The HubConnector is the central actor for communication with an instant3Dhub instance in your network...
Definition I3DHConnector.h:214
virtual void OnHoverEnd()
OnHoverEnd should be called if this DrawingActor is no longer hovered to revert its Material.
class AI3DHConnector * GetHubConnector() const
Gets hub connector that's connected to the instant3Dhub session this drawing belongs to.
Definition I3DHDrawing.h:69
void SetDrawingVisibilityOverride(const bool bIsVisible)
Overrides the visibility of the Drawing disregarding the visibility of the instant3Dhub session.
virtual UMaterialInterface * GetHoveredMaterial(const FLinearColor &DrawingColor) const
Definition I3DHDrawing.h:80
TSet< EI3DHGlPrimitiveType > AllowedPrimitivesColliders
Finer control over which geometry types have collisions enabled.
Definition I3DHDrawing.h:126
virtual void OnHoverStart()
OnHoverStart should be called if this DrawingActor is hovered to change its Material to one that visu...
void ClearDrawingVisibilityOverride()
Clears any active visibility override and restores the drawing's instant3Dhub session visibility.
int32 GetDrawingHandle() const
Gets instant3Dhub Drawing Handle of this Drawing Actor.
Definition I3DHDrawing.h:63
bool HasDrawingResult() const
Returns true if this Drawing Actor has a valid Drawing Result.
Definition I3DHDrawing.h:104
uint8 bCreateDrawingCollisions
Whether drawings should ever have collisions created from their geometry.
Definition I3DHDrawing.h:130
#define INSTANT3DHUB_DEPRECATED(Version, Message)
Macro for marking up deprecated code, functions and types.
Definition I3DHVersion.h:203
instant3Dhub drawing properties.
Definition I3DHDataTypes.h:1995
Encapsulates the result of an instant3Dhub drawing.
Definition I3DHDataTypes.h:2093