// Copyright® 2015-2023 PICO Technology Co., Ltd. All rights reserved.
// This plugin incorporates portions of the Unreal® Engine. Unreal® is a trademark or registered trademark of Epic Games, Inc. in the United States of America and elsewhere.
// Unreal® Engine, Copyright 1998 – 2023, Epic Games, Inc. All rights reserved.
#pragma once
#include "CoreMinimal.h"
#include "PICO_MRTypes.h"
#include "PICO_AnchorComponent.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "PICO_MRFunctionLibrary.generated.h"
// Delegates
//MR
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPXRAnchorDataUpdatedDelegate);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPXRMeshDataUpdatedDelegate);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPXRSceneCaptureDataUpdatedDelegate);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPXRAnchorServiceStateUpdatedDelegate,EMRStatePICO,State);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPXRMeshScanningStateUpdatedDelegate,EMRStatePICO,State);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPXRSceneCaptureServiceStateUpdatedDelegate,EMRStatePICO,State);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPXRVSTDisplayChangedDelegate,EVSTDisplayStatusPICO,Status);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPXRResume);
UCLASS(BlueprintType)
class PICOOPENXRMR_API UMRDelegateManagerPICO : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintAssignable)
FPXRAnchorDataUpdatedDelegate AnchorDataUpdatedDelegate;
UPROPERTY(BlueprintAssignable)
FPXRMeshDataUpdatedDelegate MeshDataUpdatedDelegate;
UPROPERTY(BlueprintAssignable)
FPXRSceneCaptureDataUpdatedDelegate SceneCaptureDataUpdatedDelegate;
UPROPERTY(BlueprintAssignable)
FPXRAnchorServiceStateUpdatedDelegate SpatialAnchorServiceStateUpdatedDelegate;
UPROPERTY(BlueprintAssignable)
FPXRMeshScanningStateUpdatedDelegate MeshScanningStateUpdatedDelegate;
UPROPERTY(BlueprintAssignable)
FPXRSceneCaptureServiceStateUpdatedDelegate SceneCaptureServiceStateUpdatedDelegate;
UPROPERTY(BlueprintAssignable)
FPXRVSTDisplayChangedDelegate VSTDisplayChangedDelegate;
UPROPERTY(BlueprintAssignable)
FPXRResume ResumeDelegate;
};
UCLASS()
class PICOOPENXRMR_API UMRFunctionLibraryPICO : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
static UMRDelegateManagerPICO* PICODelegateManager;
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static UMRDelegateManagerPICO* GetMRDelegateManagerPICO();
///
/// Gets the universally unique identifier (UUID) of an anchor entity.
///
/// The bound actor of the anchor entity to get UUID for.
/// Returns the UUID of the anchor entity.
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static bool GetAnchorEntityUuidPICO(AActor* BoundActor, FSpatialUUIDPICO& OutAnchorUUID,EResultPICO& OutResult);
///
/// Gets the universally unique identifier (UUID) of an anchor entity.
///
/// Specifies the AnchorComponent for which you want to get anchor entity pose information.
/// Returns the UUID of the anchor entity.
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static bool GetAnchorEntityUuidByComponentPICO(UAnchorComponentPICO* AnchorComponent, FSpatialUUIDPICO& OutAnchorUUID,EResultPICO& OutResult);
///
/// Gets the information about the Bounding Box 2D for a SceneCapture.
/// Before calling this method, you need to load SceneCaptures and get the SceneInfos first. The result contains the UUIDs of SceneCaptures loaded.
///
/// Specifies the uuid of the SceneCapture.
///
/// * `Center`: Returns the offset of the boundary's position relative to the world position.
/// * `Extent`: Returns the width and height of the boundary.
///
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool GetSceneBoundingBox2DPICO(const FSpatialUUIDPICO& UUID, FBoundingBox2DPICO& OutBoundingBox2D);
///
/// Gets the information about the polygon (irregular plane) for an anchor entity.
/// Before calling this method, you need to load SceneCaptures and get the SceneInfos first. The result contains the UUIDs of SceneCaptures loaded.
///
/// Specifies the uuid of the SceneCapture.
///
/// * `Vertices`: The positions of the polygon's vertices on the X, Y, and Z axis.
///
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool GetSceneBoundingPolygonPICO(const FSpatialUUIDPICO& UUID, TArray& OutPolygonVertices);
///
/// Gets the information about the Bounding Box 3D for an SceneCapture.
/// Before calling this method, you need to load SceneCaptures and get the SceneInfos first. The result contains the UUIDs of SceneCaptures loaded.
///
/// Specifies the uuid of the SceneCapture.
///
/// * `Center`: Returns the offset of the boundary's position relative to the world position.
/// * `Extent`: Returns the width, height and depth of the boundary.
///
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool GetSceneBoundingBox3DPICO(const FSpatialUUIDPICO& UUID, FBoundingBox3DPICO& OutBoundingBox3D);
///
/// Gets the pose of an actor's anchor entit by Actor.
///
/// Specifies the Actor for which you want to get anchor entity pose information.
///
/// * `Location`: The location of the anchor entity.
/// * `Rotation`: The rotation of the anchor entity.
/// * `Scale`: The scale of the anchor entity. `1` by default.
///
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static bool GetAnchorPoseByActorPICO(AActor* BoundActor, FTransform& OutTransform,EResultPICO& OutResult);
///
/// Gets the pose of an actor's anchor entity by AnchorComponent.
///
/// Specifies the AnchorComponent for which you want to get anchor entity pose information.
///
/// * `Location`: The location of the anchor entity.
/// * `Rotation`: The rotation of the anchor entity.
/// * `Scale`: The scale of the anchor entity. `1` by default.
///
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static bool GetAnchorPoseByComponentPICO(UAnchorComponentPICO* AnchorComponent, FTransform& OutTransform,EResultPICO& OutResult);
///
/// Destroy anchor entity by AnchorComponent.
///
/// Specifies the AnchorComponent for the anchor you want to destroy.
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool DestroyAnchorByComponentPICO(UAnchorComponentPICO* AnchorComponent,EResultPICO& OutResult);
///
/// Destroy anchor entity by Actor.
///
/// Specifies the Actor for the anchor you want to destroy.
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool DestroyAnchorByActorPICO(AActor* BoundActor,EResultPICO& OutResult);
///
/// Checks if an Actor's anchor is valid.
///
/// Specifies the Actor for the anchor you want to check.
/// Bool:
///
/// - `true` - valid
/// - `false` - invalid
///
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static bool IsAnchorValidForActorPICO(AActor* BoundActor);
///
/// Checks if an AnchorComponent's anchor is valid.
///
/// Specifies the AnchorComponent for the anchor you want to check.
/// Bool:
///
/// - `true` - valid
/// - `false` - invalid
///
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static bool IsAnchorValidForComponentPICO(UAnchorComponentPICO* AnchorComponent);
///
/// Spawns an actor from the specified anchor load result.
///
/// The world context in which the actor will be spawned.
/// The anchor load result containing information for spawning, including the anchor's handle, UUID, and location.
/// The class of the actor to be spawned.
/// The spawned actor, or nullptr if spawning fails.
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR", meta = (WorldContext = "WorldContext", UnsafeDuringActorConstruction = "true"))
static AActor* SpawnActorFromLoadResultPICO(UObject* WorldContext, const FAnchorLoadResultPICO& LoadResult, UClass* ActorClass);
///
/// From AnchorHandle To FString.
///
/// Specifies the AnchorHandle for which you want to convert.
/// FString of AnchorHandle.
///
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToString (Anchor Handle)", CompactNodeTitle = "->", BlueprintAutocast), Category = "PICO|MR")
static FString FromAnchorToStringPICO(const FSpatialHandlePICO& AnchorHandle);
///
/// From UUID To FString.
///
/// Specifies the AnchorUUID for which you want to convert.
/// FString of UUID.
///
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToString", CompactNodeTitle = "->", BlueprintAutocast), Category = "PICO|MR")
static FString FromUUIDToStringPICO(const FSpatialUUIDPICO& AnchorUUID);
///
/// From FString To UUID.
///
/// Specifies the AnchorUUIDString for which you want to convert.
/// UUID.
///
UFUNCTION(BlueprintPure, meta = (DisplayName = "To UUID PICO", CompactNodeTitle = "->", BlueprintAutocast),Category = "PICO|MR")
static FSpatialUUIDPICO FromStringToUUIDPICO(const FString& AnchorUUIDString);
///
/// Closes Spatial Mesh scanning.
///
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool CloseSpatialMeshScanningPICO(EResultPICO& OutResult);
///
/// Closes Spatial Anchor service.
///
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool CloseSpatialAnchorServicePICO(EResultPICO& OutResult);
///
/// Closes Scene Capture service.
///
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool CloseSceneCaptureServicePICO(EResultPICO& OutResult);
///
/// Creates Scene Bounding Polygon.
///
/// Specifies the actor bound by polygon.
/// True if never create collision, false otherwise.
/// True if you want to flip polygon, false otherwise. It is recommend to be ture in Floor type, otherwise the orientation is down, which may affect rendering and collision.
/// True if you want to use Wireframe, false otherwise.
/// The transform of polygon.
/// The set of vertices.
/// Default mesh material.
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool CreateSceneBoundingPolygonPICO(AActor* BoundActor,bool bNeverCreateCollision,bool bFlipPolygon,bool UseWireframe,const FTransform& Transform,const TArray& Vertices,UMaterialInterface* DefaultMeshMaterial);
///
/// Changes Spatial Mesh's Lod Setting.
///
/// Specifies the Lod for which you want to set.
/// Bool:
///
/// - `true` - success
/// - `false` - failure
///
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static bool ChangeSpatialMeshLodSettingPICO(ESpatialMeshLodPICO SpatialMeshLod,EResultPICO& OutResult);
///
/// Gets Spatial Mesh Lod Setting.
///
/// Spatial Mesh Lod.
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static ESpatialMeshLodPICO GetSpatialMeshLodSettingPICO();
///
/// Gets Spatial Mesh scanning state.
///
/// State of Spatial Mesh scanning:
/// - Initialized: After checking the Spacial Mesh feature in ProjectSettings, the initialization will be completed during the app startup process.
/// - Running: This state is set after the Spatial Mesh scanning has been successfully started.
/// - Stopped: This state is set after the Spatial Mesh scanning has been successfully shut down.
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static EMRStatePICO GetSpatialMeshScanningStatePICO();
///
/// Get Spatial Anchor service state.
///
/// State of Spatial Anchor service:
/// - Initialized: After checking the Spatial Anchor feature in ProjectSettings, the initialization will be completed during the app startup process.
/// - Running: This state is set after the Spatial Anchor service has been successfully started.
/// - Stopped: This state is set after the Spatial Anchor service has been successfully shut down.
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static EMRStatePICO GetSpatialAnchorServiceStatePICO();
///
/// Get Scene Capture service state.
///
/// State of Scene Capture service:
/// - Initialized: After checking the Scene Capture feature in ProjectSettings, the initialization will be completed during the app startup process.
/// - Running: This state is set after the Scene Capture service has been successfully started.
/// - Stopped: This state is set after the Scene Capture service has been successfully shut down.
///
UFUNCTION(BlueprintPure, Category = "PICO|MR")
static EMRStatePICO GetSceneCaptureServiceStatePICO();
///
/// Reset Spatial Mesh Infos State.
///
UFUNCTION(BlueprintCallable, Category = "PICO|MR")
static void ResetSpatialMeshInfosStatePICO();
};