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
57UCLASS(NotPlaceable, MinimalAPI, Experimental, meta = (DisplayName = "I3DH Geometry (Experimental)"))
58class AI3DHGeometry : public AActor
59{
60 GENERATED_BODY()
61
62public:
63 INSTANT3DHUB_API AI3DHGeometry();
64
65protected:
66 // Begin Actor Interface
67 INSTANT3DHUB_API virtual void BeginPlay() override;
68 // End Actor Interface
69
70public:
71 // ----------------------------------------------------------
72 // Geometry Public API
73 // ----------------------------------------------------------
74
79 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
80 FORCEINLINE AI3DHConnector* GetHubConnector() const { return Connector.Get(); }
81
86 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
87 FORCEINLINE int32 GetNodeId() const { return RootNodeId; }
88
93 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
94 FORCEINLINE bool IsSelectedNode() const { return bIsSelected; }
95
100 INSTANT3DHUB_DEPRECATED(1.0.0, "Replaced by HoverAPI. Use GetConnector()->GetAPI()->GetHoverAPI()->SetHoveredNode(GetNodeId()) instead.")
101 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
102 INSTANT3DHUB_API void OnHoverStart();
103
105 INSTANT3DHUB_DEPRECATED(1.0.0, "Replaced by HoverAPI. Use GetConnector()->GetAPI()->GetHoverAPI()->ClearHoveredNodes() instead.")
106 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Geometry")
107 INSTANT3DHUB_API void OnHoverEnd();
108
110 // ----------------------------------------------------------
111 // Internal
112 // ----------------------------------------------------------
113
114 struct FPageInstanceMeshComponent
115 {
116 FI3DHPageInstanceHandle PageInstanceHandle;
117 UStaticMeshComponent* MeshComponent;
118 };
119
120 void InitializePreSpawn(AI3DHConnector* InConnector, int32 InRootNodeId);
121
122 // Called by the HubConnector when a new component is added.
123 void OnPageInstanceMeshAttached(FI3DHPageInstanceHandle PageInstanceHandle, UStaticMeshComponent* NewMeshComponent);
124
125 const TArray<FPageInstanceMeshComponent>& GetPageInstanceMeshComponents() { return PageInstanceMeshComponents; };
126
127 void SetAppearance_GeometryInternal(const FLinearColor& OverrideColor, EAppearanceURIMode OverrideMode);
128
129 void SetEnabled_GeometryInternal(bool bNewIsEnabled);
130 void SetVariantEnabled_GeometryInternal(bool bNewIsVariantEnabled);
131 void SetSelected_GeometryInternal(bool bNewIsSelected);
132 void SetHovered_GeometryInternal(bool bNewIsHovered);
133
134 bool IsSelected_GeometryInternal() const { return bIsSelected; }
135
136private:
137 // Returns the material to use for a given state.
138 UMaterialInterface* GetMaterialForState(bool bSelected, bool bHovered) const;
139
140 // Sets the material on all mesh components.
141 void SetMaterialOnMeshComponents(UMaterialInterface* Material) const;
142
143 void SyncComponentAppearance(class UMeshComponent* MeshComponent) const;
144
145private:
147 TWeakObjectPtr<AI3DHConnector> Connector;
148
149 // Note: use int type here to be Blueprint compatible. Range should be enough for NodeIds anyway.
150 int32 RootNodeId = 0;
151
152 bool bIsEnabled = true;
153 bool bIsVariantEnabled = true;
154 bool bIsSelected = false;
155 bool bIsHovered = false;
156
158 TArray<FPageInstanceMeshComponent> PageInstanceMeshComponents;
159
160 struct
161 {
162 FLinearColor OverrideColor{};
163 bool bUseOverrideRGB{};
164 bool bUseOverrideOpacity{};
165 } Appearance;
166
168 UPROPERTY()
169 UMaterialInterface* ActiveMaterial;
170
173 UPROPERTY(EditDefaultsOnly, Category = "{instant3Dhub}|Geometry")
174 UMaterialInterface* DefaultMaterial;
175
177 UPROPERTY(EditDefaultsOnly, Category = "{instant3Dhub}|Geometry")
178 UMaterialInterface* SelectedMaterial;
179
181 UPROPERTY(EditDefaultsOnly, Category = "{instant3Dhub}|Geometry")
182 UMaterialInterface* HoveredMaterial;
183
185 UPROPERTY(EditDefaultsOnly, Category = "{instant3Dhub}|Geometry")
186 UMaterialInterface* HoveredSelectedMaterial;
187
189};
The HubConnector is the central actor for communication with an instant3Dhub instance in your network...
Definition I3DHConnector.h:98
Actor containing mesh components used to represent instant3Dhub geometry.
Definition I3DHGeometry.h:59
#define INSTANT3DHUB_DEPRECATED(Version, Message)
Macro for marking up deprecated code, functions and types.
Definition I3DHVersion.h:168
#define INSTANT3DHUB_EXPERIMENTAL(Version, Message)
Macro for marking up experimental code, functions and types.
Definition I3DHVersion.h:212
TSharedPtr< FI3DHConnectorAPI > GetAPI() const
Returns a shared pointer to the ConnectorAPI.