UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ARBlueprintLibrary.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
8#include "ARTypes.h"
10#include "ARSystem.h"
11#include "ARTraceResult.h"
12#include "ARSessionConfig.h"
13#include "ARTrackable.h"
14#include "ARTextures.h"
15
16#include "ARBlueprintLibrary.generated.h"
17
18#define UE_API AUGMENTEDREALITY_API
19
20
21#define DEFINE_AR_BPLIB_DELEGATE_FUNCS(DelegateName) \
22public: \
23 static FDelegateHandle Add##DelegateName##Delegate_Handle(const F##DelegateName##Delegate& Delegate) \
24 { \
25 auto ARSystem = GetARSystem(); \
26 if (ARSystem.IsValid()) \
27 { \
28 return ARSystem.Pin()->Add##DelegateName##Delegate_Handle(Delegate); \
29 } \
30 return Delegate.GetHandle(); \
31 } \
32 static void Clear##DelegateName##Delegate_Handle(FDelegateHandle& Handle) \
33 { \
34 auto ARSystem = GetARSystem(); \
35 if (ARSystem.IsValid()) \
36 { \
37 ARSystem.Pin()->Clear##DelegateName##Delegate_Handle(Handle); \
38 return; \
39 } \
40 Handle.Reset(); \
41 } \
42 static void Clear##DelegateName##Delegates(FDelegateUserObject Object) \
43 { \
44 auto ARSystem = GetARSystem(); \
45 if (ARSystem.IsValid()) \
46 { \
47 ARSystem.Pin()->Clear##DelegateName##Delegates(Object); \
48 } \
49 }
50
51UCLASS(MinimalAPI, meta=(ScriptName="ARLibrary"))
53{
55
56public:
57
62 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Session", meta = (DisplayName="Is AR Supported", Keywords = "ar augmentedreality augmented reality session start run running"))
63 static UE_API bool IsARSupported();
64
70 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Session", meta = (DisplayName="Start AR Session", Keywords = "ar augmentedreality augmented reality session start run running"))
71 static UE_API void StartARSession(UARSessionConfig* SessionConfig);
72
74 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Session", meta = (DisplayName="Pause AR Session", Keywords = "ar augmentedreality augmented reality session stop run running"))
75 static UE_API void PauseARSession();
76
78 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Session", meta = (DisplayName="Stop AR Session", Keywords = "ar augmentedreality augmented reality session stop run running"))
79 static UE_API void StopARSession();
80
87 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Session", meta = (DisplayName="Get AR Session Status", Keywords = "ar augmentedreality augmented reality session start stop run running"))
88 static UE_API FARSessionStatus GetARSessionStatus();
89
91 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Session", meta = (DisplayName="Get AR Session Config", Keywords = "ar augmentedreality augmented reality session"))
92 static UE_API UARSessionConfig* GetSessionConfig();
93
95 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Session", meta = (Keywords = "ar augmentedreality augmented reality capture start stop"))
96 static UE_API bool ToggleARCapture(const bool bOnOff, const EARCaptureType CaptureType);
97
99 UFUNCTION(BlueprintCallable, Category = "AR", meta = (Keywords = "ar all"))
100 static UE_API void SetEnabledXRCamera(bool bOnOff);
101
103 UFUNCTION(BlueprintCallable, Category = "AR", meta = (Keywords = "ar all"))
104 static UE_API FIntPoint ResizeXRCamera(const FIntPoint& InSize);
105
106
119 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Alignment", meta = (DisplayName="Set AR Alignment Transform", Keywords = "ar augmentedreality augmented reality tracking alignment"))
120 static UE_API void SetAlignmentTransform( const FTransform& InAlignmentTransform );
121
122
130 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Trace Result", meta = (AdvancedDisplay="1", Keywords = "ar augmentedreality augmented reality tracking tracing linetrace"))
131 static UE_API TArray<FARTraceResult> LineTraceTrackedObjects( const FVector2D ScreenCoord, bool bTestFeaturePoints = true, bool bTestGroundPlane = true, bool bTestPlaneExtents = true, bool bTestPlaneBoundaryPolygon = true );
132
141 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Trace Result", meta = (AdvancedDisplay = "1", Keywords = "ar augmentedreality augmented reality tracking tracing linetrace"))
142 static UE_API TArray<FARTraceResult> LineTraceTrackedObjects3D(const FVector Start, const FVector End, bool bTestFeaturePoints = true, bool bTestGroundPlane = true, bool bTestPlaneExtents = true, bool bTestPlaneBoundaryPolygon = true);
143
145 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Tracking", meta = (DisplayName="Get AR Tracking Quality", Keywords = "ar augmentedreality augmented reality tracking quality"))
146 static UE_API EARTrackingQuality GetTrackingQuality();
147
149 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Tracking", meta = (DisplayName="Get AR Tracking Quality Reason", Keywords = "ar augmentedreality augmented reality tracking quality reason"))
150 static UE_API EARTrackingQualityReason GetTrackingQualityReason();
151
153 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Tracking", meta = (DisplayName="Get All AR Geometries", Keywords = "ar augmentedreality augmented reality tracking geometry anchor"))
154 static UE_API TArray<UARTrackedGeometry*> GetAllGeometries();
155
157 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Tracking", meta = (DisplayName="Get All AR Geometries By Class", Keywords = "ar augmentedreality augmented reality tracking geometry anchor", DeterminesOutputType = "GeometryClass"))
159
161 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Texture", meta = (DisplayName="Get AR Texture", Keywords = "ar augmentedreality augmented reality texture"))
162 static UE_API UARTexture* GetARTexture(EARTextureType TextureType);
163
168 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Tracking", meta = (DisplayName="Is AR Session Type Supported", Keywords = "ar augmentedreality augmented reality tracking"))
169 static UE_API bool IsSessionTypeSupported(EARSessionType SessionType);
170
171
173 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Debug", meta = (WorldContext = "WorldContextObject", AdvancedDisplay="1", Keywords = "ar augmentedreality augmented reality tracked geometry debug draw"))
174 static UE_API void DebugDrawTrackedGeometry( UARTrackedGeometry* TrackedGeometry, UObject* WorldContextObject, FLinearColor Color = FLinearColor(1.0f, 1.0f, 0.0f, 0.75f), float OutlineThickness=5.0f, float PersistForSeconds = 0.0f );
175
177 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Debug", meta = (WorldContext = "WorldContextObject", AdvancedDisplay="1", Keywords = "ar augmentedreality augmented reality pin debug draw"))
178 static UE_API void DebugDrawPin( UARPin* ARPin, UObject* WorldContextObject, FLinearColor Color = FLinearColor(1.0f, 1.0f, 0.0f, 0.75f), float Scale=5.0f, float PersistForSeconds = 0.0f );
179
180
190 UFUNCTION( BlueprintPure, Category = "AR AugmentedReality|Light Estimate" )
191 static UE_API UARLightEstimate* GetCurrentLightEstimate();
192
193
209 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (AdvancedDisplay="3", Keywords = "ar augmentedreality augmented reality tracking arpin tracked geometry pinning anchor"))
210 static UE_API UARPin* PinComponent( USceneComponent* ComponentToPin, const FTransform& PinToWorldTransform, UARTrackedGeometry* TrackedGeometry = nullptr, const FName DebugName = NAME_None );
211
216 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (AdvancedDisplay="2", Keywords = "ar augmentedreality augmented reality tracking arpin tracked geometry pinning anchor"))
217 static UE_API UARPin* PinComponentToTraceResult( USceneComponent* ComponentToPin, const FARTraceResult& TraceResult, const FName DebugName = NAME_None );
218
227 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin tracked geometry pinning anchor"))
228 static UE_API bool PinComponentToARPin(USceneComponent* ComponentToPin, UARPin* Pin);
229
231 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin tracked geometry pinning anchor"))
232 static UE_API void UnpinComponent( USceneComponent* ComponentToUnpin );
233
235 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin tracked geometry pinning anchor"))
236 static UE_API void RemovePin( UARPin* PinToRemove );
237
239 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin anchor"))
240 static UE_API TArray<UARPin*> GetAllPins();
241
247 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin anchor LocalStore"))
248 static UE_API bool IsARPinLocalStoreSupported();
249
255 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin anchor LocalStore"))
256 static UE_API bool IsARPinLocalStoreReady();
257
264 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin anchor LocalStore"))
265 static UE_API TMap<FName, UARPin*> LoadARPinsFromLocalStore();
266
274 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin anchor LocalStore"))
275 static UE_API bool SaveARPinToLocalStore(FName InSaveName, UARPin* InPin);
276
281 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin anchor LocalStore"))
282 static UE_API void RemoveARPinFromLocalStore(FName InSaveName);
283
287 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|ARPin", meta = (Keywords = "ar augmentedreality augmented reality tracking arpin anchor LocalStore"))
288 static UE_API void RemoveAllARPinsFromLocalStore();
289
291 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Tracking", meta = (DisplayName="Add AR Environment Probe", Keywords = "ar augmentedreality augmented reality tracking anchor"))
292 static UE_API bool AddManualEnvironmentCaptureProbe(FVector Location, FVector Extent);
293
295 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Tracking", meta = (DisplayName="Get AR World Mapping Status", Keywords = "ar augmentedreality augmented reality tracking anchor"))
296 static UE_API EARWorldMappingState GetWorldMappingStatus();
297
299 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Tracking", meta = (DisplayName="Get AR Point Cloud", Keywords = "ar augmentedreality augmented reality tracking point cloud"))
300 static UE_API TArray<FVector> GetPointCloud();
301
303 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Capabilities", meta = (DisplayName="Get Supported AR Video Formats", Keywords = "ar augmentedreality augmented reality config video formats"))
304 static UE_API TArray<FARVideoFormat> GetSupportedVideoFormats(EARSessionType SessionType);
305
308
321 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Session", meta = (Keywords = "ar augmentedreality augmented reality candidate image"))
322 static UE_API UARCandidateImage* AddRuntimeCandidateImage(UARSessionConfig* SessionConfig, UTexture2D* CandidateTexture, FString FriendlyName, float PhysicalWidth);
323
325 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Session", meta = (DisplayName="Is AR Session Tracking Feature Supported", Keywords = "ar augmentedreality augmented reality session tracking feature"))
326 static UE_API bool IsSessionTrackingFeatureSupported(EARSessionType SessionType, EARSessionTrackingFeature SessionTrackingFeature);
327
329 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Session", meta = (DisplayName="Is AR Scene Reconstruction Supported", Keywords = "ar augmentedreality augmented reality session scene reconstruction"))
330 static UE_API bool IsSceneReconstructionSupported(EARSessionType SessionType, EARSceneReconstruction SceneReconstructionMethod);
331
333 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Pose Tracking", meta = (DisplayName="Get All AR Tracked 2D Poses", Keywords = "ar augmentedreality augmented reality pose tracking"))
334 static UE_API TArray<FARPose2D> GetAllTracked2DPoses();
335
344 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Classification")
345 static UE_API bool GetObjectClassificationAtLocation(const FVector& InWorldLocation, EARObjectClassification& OutClassification, FVector& OutClassificationLocation, float MaxLocationDiff = 10.f);
346
353 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Alignment", meta = (DisplayName="Set AR World Origin Location and Rotation", Keywords = "ar augmentedreality augmented reality world origin"))
354 static UE_API void SetARWorldOriginLocationAndRotation(FVector OriginLocation, FRotator OriginRotation, bool bIsTransformInWorldSpace = true, bool bMaintainUpDirection = true);
355
361 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Alignment", meta = (DisplayName="Set AR World Scale", Keywords = "ar augmentedreality augmented reality world scale"))
362 static UE_API void SetARWorldScale(float InWorldScale);
363
365 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Alignment", meta = (DisplayName="Get AR World Scale", Keywords = "ar augmentedreality augmented reality world scale"))
366 static UE_API float GetARWorldScale();
367
369 UFUNCTION(BlueprintPure, Category = "AR AugmentedReality|Alignment", meta = (DisplayName="Get Alignment Transform", Keywords = "ar augmentedreality augmented reality alignment transform"))
370 static UE_API FTransform GetAlignmentTransform();
371
380 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality", meta = (Keywords = "ar augmentedreality augmented reality add point"))
381 static UE_API bool AddTrackedPointWithName(const FTransform& WorldTransform, const FString& PointName, bool bDeletePointsWithSameName = true);
382
384 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality", meta = (Keywords = "ar augmentedreality augmented reality find point"))
385 static UE_API TArray<UARTrackedPoint*> FindTrackedPointsByName(const FString& PointName);
386
387 // Static helpers to create the methods needed to add/remove delegates from the AR system
388 DEFINE_AR_BPLIB_DELEGATE_FUNCS(OnTrackableAdded)
389 DEFINE_AR_BPLIB_DELEGATE_FUNCS(OnTrackableUpdated)
390 DEFINE_AR_BPLIB_DELEGATE_FUNCS(OnTrackableRemoved)
391 // End helpers
392
393 //Alignment helpers
394 UFUNCTION(BlueprintCallable, Category = Alignment)
395 static UE_API void CalculateClosestIntersection(const TArray<FVector>& StartPoints, const TArray<FVector>& EndPoints, FVector& ClosestIntersection);
396
397 // Computes a transform that aligns two coordinate systems. Requires the transform of the same known point in each coordinate system.
398 UFUNCTION(BlueprintCallable, Category = Alignment)
399 static UE_API void CalculateAlignmentTransform(const FTransform& TransformInFirstCoordinateSystem, const FTransform& TransformInSecondCoordinateSystem, FTransform& AlignmentTransform);
400
402 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Face Tracking")
403 static UE_API int32 GetNumberOfTrackedFacesSupported();
404
406 UFUNCTION(BlueprintCallable, Category = "AR AugmentedReality|Geo Tracking")
407 static UE_API bool GetCameraIntrinsics(FARCameraIntrinsics& OutCameraIntrinsics);
408
410 template<class T>
412 {
414 for (auto Geometry : GetAllGeometries())
415 {
416 if (auto CastedGeometry = Cast<T>(Geometry))
417 {
419 }
420 }
421 return MoveTemp(Geometries);
422 }
423
424public:
425 static UE_API void RegisterAsARSystem(const TSharedRef<FARSupportInterface , ESPMode::ThreadSafe>& NewArSystem);
426
427private:
430};
431
432
433UCLASS(MinimalAPI, meta=(ScriptName="ARTraceResultLibrary"))
435{
437
438 public:
439
441 UFUNCTION( BlueprintPure, Category = "AR AugmentedReality|Trace Result" )
442 static UE_API float GetDistanceFromCamera( const FARTraceResult& TraceResult );
443
449 UFUNCTION( BlueprintPure, Category = "AR AugmentedReality|Trace Result" )
450 static UE_API FTransform GetLocalToTrackingTransform( const FARTraceResult& TraceResult );
451
453 UFUNCTION( BlueprintPure, Category = "AR AugmentedReality|Trace Result" )
454 static UE_API FTransform GetLocalToWorldTransform( const FARTraceResult& TraceResult );
455
457 UFUNCTION( BlueprintPure, Category = "AR AugmentedReality|Trace Result" )
458 static UE_API FTransform GetLocalTransform( const FARTraceResult& TraceResult );
459
461 UFUNCTION( BlueprintPure, Category = "AR AugmentedReality|Trace Result" )
462 static UE_API UARTrackedGeometry* GetTrackedGeometry( const FARTraceResult& TraceResult );
463
465 UFUNCTION( BlueprintPure, Category = "AR AugmentedReality|Trace Result" )
466 static UE_API EARLineTraceChannels GetTraceChannel( const FARTraceResult& TraceResult );
467};
468
469#undef UE_API
#define UE_API
Definition ARBlueprintLibrary.h:18
#define DEFINE_AR_BPLIB_DELEGATE_FUNCS(DelegateName)
Definition ARBlueprintLibrary.h:21
EARSessionType
Definition ARSessionConfig.h:37
EARSessionTrackingFeature
Definition ARSessionConfig.h:142
EARSceneReconstruction
Definition ARSessionConfig.h:167
EARTextureType
Definition ARTextures.h:13
EARWorldMappingState
Definition ARTypes.h:152
EARCaptureType
Definition ARTypes.h:47
EARTrackingQualityReason
Definition ARTypes.h:104
EARObjectClassification
Definition ARTypes.h:176
EARLineTraceChannels
Definition ARTypes.h:70
EARTrackingQuality
Definition ARTypes.h:91
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UCLASS(...)
Definition ObjectMacros.h:776
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition NameTypes.h:617
Definition Array.h:670
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition SubclassOf.h:30
Definition SharedPointer.h:1295
Definition ARBlueprintLibrary.h:53
static TArray< T * > GetAllGeometriesByClass()
Definition ARBlueprintLibrary.h:411
Definition ARTypes.h:313
Definition ARLightEstimate.h:20
Definition ARPin.h:15
Definition ARSessionConfig.h:183
Definition ARTextures.h:31
Definition ARBlueprintLibrary.h:435
Definition ARTrackable.h:17
Definition BlueprintFunctionLibrary.h:16
Definition Object.h:95
Definition Texture2D.h:26
Definition ARTypes.h:601
Definition ARTypes.h:256
Definition ARTraceResult.h:17
Definition Color.h:48
Definition IntPoint.h:25