I3DHGeometry.h Source File

instant3Dhub: I3DHGeometry.h Source File
instant3Dhub
I3DHGeometry.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "CoreMinimal.h"
9
10#include "I3DHDataTypes.h"
11#include "I3DHVersion.h"
12
13#include "GameFramework/Actor.h"
14
15#include "I3DHGeometry.generated.h"
16
17class AI3DHConnector;
18
19class INSTANT3DHUB_EXPERIMENTAL(1.0.0, "Working with the I3DH Geometry class is only necessary for advanced use-cases. How we expose geometry data is suspected to change in the future.") AI3DHGeometry;
20
28enum class EI3DHGeometryMaterialFlags : uint16
29{
30 None = 0,
31 OverrideAppearanceRGB = 1u << 0,
32 OverrideAppearanceOpacity = 1u << 1,
33 Selected = 1u << 2,
34 Hovered = 1u << 3,
35
36 Appearance = OverrideAppearanceRGB | OverrideAppearanceOpacity,
37 Highlight = Selected | Hovered,
38};
39ENUM_CLASS_FLAGS(EI3DHGeometryMaterialFlags);
78UCLASS(NotPlaceable, MinimalAPI, Experimental, meta = (DisplayName = "I3DH Geometry (Experimental)"))
79class AI3DHGeometry : public AActor
80{
81 GENERATED_BODY()
82
83public:
84 INSTANT3DHUB_API AI3DHGeometry();
85
86protected:
87 // Begin Actor Interface
88 INSTANT3DHUB_API virtual void BeginPlay() override;
89 // End Actor Interface
90
91public:
92 // ----------------------------------------------------------
93 // Geometry Public API
94 // ----------------------------------------------------------
95
100 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
101 FORCEINLINE AI3DHConnector* GetHubConnector() const { return Connector.Get(); }
102
107 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
108 FORCEINLINE int32 GetNodeId() const { return RootNodeId; }
109
114 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
115 FORCEINLINE bool IsSelectedNode() const { return bIsSelected; }
116
121 INSTANT3DHUB_DEPRECATED(1.0.0, "Replaced by HoverAPI. Use GetConnector()->GetAPI()->GetHoverAPI()->SetHoveredNode(GetNodeId()) instead.")
122 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
123 INSTANT3DHUB_API void OnHoverStart();
124
126 INSTANT3DHUB_DEPRECATED(1.0.0, "Replaced by HoverAPI. Use GetConnector()->GetAPI()->GetHoverAPI()->ClearHoveredNodes() instead.")
127 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
128 INSTANT3DHUB_API void OnHoverEnd();
129
130protected:
137 UPROPERTY(EditDefaultsOnly, Category = "{instant3Dhub}|Geometry")
138 UMaterialInterface* GeometryDefaultMaterial;
139
147 UPROPERTY(EditDefaultsOnly, Category = "{instant3Dhub}|Geometry")
148 UMaterialInterface* GeometryAppearanceMaterial;
149
157 UPROPERTY(EditDefaultsOnly, Category = "{instant3Dhub}|Geometry")
158 UMaterialInterface* GeometryHighlightMaterial;
159
167 UPROPERTY(EditDefaultsOnly, Category = "{instant3Dhub}|Geometry")
168 UMaterialInterface* GeometryAppearanceHighlightMaterial;
169
170public:
178 static constexpr int32 NumReservedCustomPrimitiveDataFloats = 4;
179
180public:
182 // ----------------------------------------------------------
183 // Internal
184 // ----------------------------------------------------------
185
186 struct FPageInstanceMeshComponent
187 {
188 FI3DHPageInstanceHandle PageInstanceHandle;
189 UStaticMeshComponent* MeshComponent;
190 };
191
192 void InitializePreSpawn(AI3DHConnector* InConnector, int32 InRootNodeId);
193
194 // Called by the HubConnector when a new component is added.
195 void OnPageInstanceMeshAttached(FI3DHPageInstanceHandle PageInstanceHandle, UStaticMeshComponent* NewMeshComponent);
196
197 const TArray<FPageInstanceMeshComponent>& GetPageInstanceMeshComponents() { return PageInstanceMeshComponents; };
198
199 void SetAppearance_GeometryInternal(const FLinearColor& OverrideColor, EAppearanceURIMode OverrideMode);
200
201 void SetEnabled_GeometryInternal(bool bNewIsEnabled);
202 void SetVariantEnabled_GeometryInternal(bool bNewIsVariantEnabled);
203 void SetSelected_GeometryInternal(bool bNewIsSelected);
204 void SetHovered_GeometryInternal(bool bNewIsHovered);
205
206 bool IsSelected_GeometryInternal() const { return bIsSelected; }
207
208private:
210 EI3DHGeometryMaterialFlags GetMaterialFlags() const;
211
213 UMaterialInterface* GetGeometryMaterialByFlags(EI3DHGeometryMaterialFlags MaterialFlags) const;
214
215 void UpdateMaterialsAndPrimitiveData(EI3DHGeometryMaterialFlags MaterialFlags);
216 void SetCustomPrimitiveDataByFlags(class UMeshComponent* MeshComponent, EI3DHGeometryMaterialFlags MaterialFlags) const;
217
218private:
220 TWeakObjectPtr<AI3DHConnector> Connector;
221
222 // Note: use int type here to be Blueprint compatible. Range should be enough for NodeIds anyway.
223 int32 RootNodeId = 0;
224
225 bool bIsEnabled = true;
226 bool bIsVariantEnabled = true;
227 bool bIsSelected = false;
228 bool bIsHovered = false;
229
231 TArray<FPageInstanceMeshComponent> PageInstanceMeshComponents;
232
233 struct
234 {
235 FLinearColor OverrideColor{};
236 bool bUseOverrideRGB{};
237 bool bUseOverrideOpacity{};
238 } Appearance;
239
240 INSTANT3DHUB_DEPRECATED(1.2.0, "Geometry materials are now grouped by Appearance and Highlight. Please use GeometryDefaultMaterial and its variants (Appearance, Highlight).")
241 UPROPERTY()
242 UMaterialInterface* DefaultMaterial_DEPRECATED;
243
244 INSTANT3DHUB_DEPRECATED(1.2.0, "Geometry materials are now grouped by Appearance and Highlight. Please use GeometryDefaultMaterial and its variants (Appearance, Highlight).")
245 UPROPERTY()
246 UMaterialInterface* SelectedMaterial_DEPRECATED;
247
248 INSTANT3DHUB_DEPRECATED(1.2.0, "Geometry materials are now grouped by Appearance and Highlight. Please use GeometryDefaultMaterial and its variants (Appearance, Highlight).")
249 UPROPERTY()
250 UMaterialInterface* HoveredMaterial_DEPRECATED;
251
252 INSTANT3DHUB_DEPRECATED(1.2.0, "Geometry materials are now grouped by Appearance and Highlight. Please use GeometryDefaultMaterial and its variants (Appearance, Highlight).")
253 UPROPERTY()
254 UMaterialInterface* HoveredSelectedMaterial_DEPRECATED;
255
257};
@ None
Zero value.
@ Selected
Specifies whether a node is selected.
The HubConnector is the central actor for communication with an instant3Dhub instance in your network...
Definition I3DHConnector.h:121
Actor containing mesh components used to represent instant3Dhub geometry.
Definition I3DHGeometry.h:80
#define INSTANT3DHUB_DEPRECATED(Version, Message)
Macro for marking up deprecated code, functions and types.
Definition I3DHVersion.h:189
#define INSTANT3DHUB_EXPERIMENTAL(Version, Message)
Macro for marking up experimental code, functions and types.
Definition I3DHVersion.h:233
TSharedPtr< FI3DHConnectorAPI > GetAPI() const
Returns a shared pointer to the ConnectorAPI.