I3DHUtilities.h Source File

I3DHUtilities.h Source File#

instant3Dhub: I3DHUtilities.h Source File
instant3Dhub
I3DHUtilities.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "CoreMinimal.h"
9
10#include "I3DHDataTypes.h"
11#include "I3DHError.h"
12#include "I3DHVersion.h"
13
14#include "Kismet/BlueprintFunctionLibrary.h"
15
16#include "I3DHUtilities.generated.h"
17
18class AI3DHConnector;
19
23UCLASS()
24class INSTANT3DHUB_API UI3DHUtilities : public UBlueprintFunctionLibrary
25{
26 GENERATED_BODY()
27
28public:
137public:
147 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities")
149
154 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities")
155 static const FMatrix& GetOriginalToUnrealMatrix();
156
161 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities")
162 static const FMatrix& GetUnrealToOriginalMatrix();
163
172 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities")
173 static const FMatrix& GetOriginalToUnrealNormalMatrix();
174
183 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities")
184 static const FMatrix& GetUnrealToOriginalNormalMatrix();
185
191 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities")
192 static UPARAM(DisplayName = "Unreal Transform") FMatrix ConvertTransformOriginalToUnreal(const FMatrix& OriginalTransform);
193
199 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities")
200 static UPARAM(DisplayName = "Original Transform") FMatrix ConvertTransformUnrealToOriginal(const FMatrix& UnrealTransform);
201
212 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities", meta = (DisplayName = "Convert Transform Original to Unreal (Pure)"))
213 static UPARAM(DisplayName = "Unreal Transform") FMatrix ConvertTransformOriginalToUnrealPure(const FMatrix& OriginalTransform);
214
225 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities", meta = (DisplayName = "Convert Transform Unreal to Original (Pure)"))
226 static UPARAM(DisplayName = "Original Transform") FMatrix ConvertTransformUnrealToOriginalPure(const FMatrix& UnrealTransform);
227
233 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities")
234 static UPARAM(DisplayName = "Unreal Volume") FBox ConvertVolumeOriginalToUnreal(const FBox& OriginalVolume);
235
241 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities")
242 static UPARAM(DisplayName = "Original Volume") FBox ConvertVolumeUnrealToOriginal(const FBox& UnrealVolume);
243
254 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities", meta = (DisplayName = "Convert Volume Original to Unreal (Pure)"))
255 static UPARAM(DisplayName = "Unreal Volume") FBox ConvertVolumeOriginalToUnrealPure(const FBox& OriginalVolume);
256
267 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities", meta = (DisplayName = "Convert Volume Unreal to Original (Pure)"))
268 static UPARAM(DisplayName = "Original Volume") FBox ConvertVolumeUnrealToOriginalPure(const FBox& UnrealVolume);
269
271
272public:
279 UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "Color"), Category = "{instant3Dhub}|Utilities")
281
289 UFUNCTION(BlueprintCallable, meta = (AutoCreateRefTerm = "InURI"), Category = "{instant3Dhub}|Utilities")
290 static bool WebvisAppearanceURIToUEColor(const FString& InURI, FLinearColor& OutColor, EAppearanceURIMode& OutMode);
291
292public:
304 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities")
305 static bool AnalyzeHitResult(const struct FHitResult& HitResult, FI3DHHitResult& OutI3DHHitResult, bool bRequestDetailNode = false);
306
307public:
315 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities")
316 static FPlane MakePlaneFromClipPlaneActor(const AActor* ClipPlaneActor);
317
327 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities")
328 static bool ClipLineSegmentByPlane(UPARAM(ref) FVector& Start, UPARAM(ref) FVector& End, const FPlane& Plane);
329
339 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities", meta = (DefaultToSelf = "HubConnector"))
340 static bool ClipLineSegmentByMainClipPlane(AI3DHConnector* HubConnector, UPARAM(ref) FVector& Start, UPARAM(ref) FVector& End);
341
351 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities", meta = (DefaultToSelf = "HubConnector"))
352 static bool ClipLineSegmentByClipPlanes(AI3DHConnector* HubConnector, UPARAM(ref) FVector& Start, UPARAM(ref) FVector& End);
353
354public:
359 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities")
360 static bool IsWithEditor();
361
368 UFUNCTION(BlueprintPure, Category = "{instant3Dhub}|Utilities", meta = (WorldContext = "WorldContextObject"))
369 static bool IsEditorStandaloneGame(const UObject* WorldContextObject);
370
378 UFUNCTION(BlueprintCallable, Category = "{instant3Dhub}|Utilities")
380
381 // These functions cannot be exposed via UFUNCTION because of the callback parameter.
382 // Instead, they have matching async blueprint nodes declared in I3DHAppUtilitiesNodes.h.
383public:
384 static constexpr FStringView URNPrefixView = TEXTVIEW("urn:");
385 static constexpr FStringView SeparatorView = TEXTVIEW(":");
386
388 static bool IsURN(const FStringView URI)
389 {
390 return URI.StartsWith(URNPrefixView, ESearchCase::IgnoreCase);
391 }
392
394 static FString ExtractNamespaceIdentifier(FStringView URI);
395
403 static bool IsValidNamespaceIdentifier(FStringView NamespaceIdentifier, FString* OutValidationError = nullptr);
404
411 static bool IsReservedNamespaceIdentifier(FStringView NamespaceIdentifier, FString* OutValidationError = nullptr);
412
414 static FStringView GetNamespaceSpecificString(const FStringView URN, const FStringView NamespaceIdentifier)
415 {
416 constexpr int32 URNPrefixLen = URNPrefixView.Len();
417 const int32 NamespaceIdentifierLen = NamespaceIdentifier.Len();
418 constexpr int32 SeparatorLen = SeparatorView.Len();
419 return URN.RightChop(URNPrefixLen + NamespaceIdentifierLen + SeparatorLen);
420 }
421
431 static void FindFirstUnselectedAncestor(TSharedPtr<class FI3DHConnectorAPI> API, int32 NodeId, TUniqueFunction<void(int32 AncestorId, EI3DHErrorCode ErrorCode)> OnComplete);
432
433private:
434 static void FindFirstUnselectedAncestor_GameThread(TSharedPtr<class FI3DHConnectorAPI> API, int32 CurrentNodeId, bool IsCurrentNodeSelected, TUniqueFunction<void(int32 AncestorId, EI3DHErrorCode ErrorCode)> OnComplete);
435};
EAppearanceURIMode
Describes how the appearance is affected by the appearance URI.
Definition I3DHDataTypes.h:1488
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
Utility functions for using Unreal Engine with Instant3DHub.
Definition I3DHUtilities.h:25
static bool IsReservedNamespaceIdentifier(FStringView NamespaceIdentifier, FString *OutValidationError=nullptr)
Checks whether a Namespace Identifier avoids the prefixes reserved by the plugin.
static FStringView GetNamespaceSpecificString(const FStringView URN, const FStringView NamespaceIdentifier)
Returns the Namespace-Specific String (NSS) from a URN urn:NID:NSS.
Definition I3DHUtilities.h:414
static void FindFirstUnselectedAncestor(TSharedPtr< class FI3DHConnectorAPI > API, int32 NodeId, TUniqueFunction< void(int32 AncestorId, EI3DHErrorCode ErrorCode)> OnComplete)
Finds the first ancestor node that is not selected, excluding the root node.
static bool IsURN(const FStringView URI)
Returns whether the string starts with the URN prefix urn:.
Definition I3DHUtilities.h:388
static bool IsValidNamespaceIdentifier(FStringView NamespaceIdentifier, FString *OutValidationError=nullptr)
Validates that a Namespace Identifier can be used for Custom Material URNs.
static bool AnalyzeHitResult(const struct FHitResult &HitResult, FI3DHHitResult &OutI3DHHitResult, bool bRequestDetailNode=false)
Analyzes a hit result to check if and what instant3Dhub geometry was hit.
static bool IsWithEditor()
Query if the current build is an Editor build of the engine.
static TMap< FString, FString > GetURLQueryParams(const FString &URL)
Parse the provided URL and retrieve its URL query parameters.
static FString ExtractNamespaceIdentifier(FStringView URI)
Extracts the Namespace Identifier (NID) from a URN urn:NID:NSS.
static bool WebvisAppearanceURIToUEColor(const FString &InURI, FLinearColor &OutColor, EAppearanceURIMode &OutMode)
Converts a WebVis appearanceURI (e.g.
static FString UEColorToWebvisAppearanceURI(const FLinearColor &Color, EAppearanceURIMode Mode)
Converts color to the matching WebVis appearanceURI.
static bool IsEditorStandaloneGame(const UObject *WorldContextObject)
Query if the current build is an Editor build of the engine and the provided 'WorldContextObject' is ...
static FPlane MakePlaneFromClipPlaneActor(const AActor *ClipPlaneActor)
Makes a plane structure from the clip plane actor with its world space location as plane origin and i...
static bool ClipLineSegmentByClipPlanes(AI3DHConnector *HubConnector, FVector &Start, FVector &End)
Clip a line segment to the positive half space (the side with the normal pointing upwards) of all Cli...
static bool ClipLineSegmentByMainClipPlane(AI3DHConnector *HubConnector, FVector &Start, FVector &End)
Clip a line segment to the positive half space (the side with the normal pointing upwards) of the Mai...
static bool ClipLineSegmentByPlane(FVector &Start, FVector &End, const FPlane &Plane)
Clip a line segment to the positive half space (the side with the normal pointing upwards) of a plane...
static FMatrix ConvertTransformUnrealToOriginal(const FMatrix &UnrealTransform)
Converts a transformation matrix to the Original coordinate system.
static FBox ConvertVolumeUnrealToOriginal(const FBox &UnrealVolume)
Converts a volume to the Original coordinate system.
static const FMatrix & GetOriginalToUnrealNormalMatrix()
Gets original to unreal normal matrix.
static FBox ConvertVolumeUnrealToOriginalPure(const FBox &UnrealVolume)
Converts a volume to the Original coordinate system.
static float GetOriginalToUnrealScale()
Returns the scale factor between Original and Unreal coordinates.
static const FMatrix & GetUnrealToOriginalNormalMatrix()
Gets unreal to original normal matrix.
static FBox ConvertVolumeOriginalToUnrealPure(const FBox &OriginalVolume)
Converts a volume to the Unreal coordinate system.
static FMatrix ConvertTransformUnrealToOriginalPure(const FMatrix &UnrealTransform)
Converts a transformation matrix to the Original coordinate system.
static const FMatrix & GetOriginalToUnrealMatrix()
Returns the conversion matrix between the Original and Unreal coordinate systems.
static const FMatrix & GetUnrealToOriginalMatrix()
Returns the conversion matrix between the Unreal and Original coordinate systems.
static FMatrix ConvertTransformOriginalToUnrealPure(const FMatrix &OriginalTransform)
Converts a transformation matrix to the Unreal coordinate system.
static FMatrix ConvertTransformOriginalToUnreal(const FMatrix &OriginalTransform)
Converts a transformation matrix to the Unreal coordinate system.
static FBox ConvertVolumeOriginalToUnreal(const FBox &OriginalVolume)
Converts a volume to the Unreal coordinate system.
Structure containing instant3Dhub-specific information about one hit of a trace.
Definition I3DHDataTypes.h:1522