UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ARSystem.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"
6#include "ARTypes.h"
7#include "ARSessionConfig.h"
8#include "Engine/Engine.h" // for FWorldContext
9
10class UARPin;
11class UARTexture;
16struct FARTraceResult;
17enum class EARTextureType : uint8;
18
19#define DEFINE_AR_DELEGATE_BASE(DelegateName) \
20private: \
21 F##DelegateName DelegateName##Delegates; \
22public: \
23 virtual FDelegateHandle Add##DelegateName##Delegate_Handle(const F##DelegateName##Delegate& Delegate) \
24 { \
25 DelegateName##Delegates.Add(Delegate); \
26 return Delegate.GetHandle(); \
27 } \
28 virtual void Clear##DelegateName##Delegate_Handle(FDelegateHandle& Handle) \
29 { \
30 DelegateName##Delegates.Remove(Handle); \
31 Handle.Reset(); \
32 } \
33 virtual void Clear##DelegateName##Delegates(FDelegateUserObject Object) \
34 { \
35 DelegateName##Delegates.RemoveAll(Object); \
36 }
37
38//need to move refactor some class hierarchies to make this protected again
39#define DEFINE_AR_DELEGATE_ONE_PARAM(DelegateName, Param1Type) \
40 DEFINE_AR_DELEGATE_BASE(DelegateName) \
41public: \
42 virtual void Trigger##DelegateName##Delegates(Param1Type Param1) \
43 { \
44 DelegateName##Delegates.Broadcast(Param1); \
45 } \
46public:
47
48
78{
79public:
81 virtual void OnARSystemInitialized(){};
82
83 virtual bool OnStartARGameFrame(FWorldContext& WorldContext) { return false; };
84
87
90
99
101 virtual void OnPauseARSession() = 0;
102
104 virtual void OnStopARSession() = 0;
105
108
110 virtual bool IsARAvailable() const = 0;
111
119
128
131
133 virtual TArray<UARPin*> OnGetAllPins() const = 0;
134
136 virtual bool OnIsTrackingTypeSupported(EARSessionType SessionType) const = 0;
137
138 virtual bool OnToggleARCapture(const bool bOnOff, const EARCaptureType CaptureType) { return false; };
139
140 virtual void OnSetEnabledXRCamera(bool bOnOff) {};
141 virtual FIntPoint OnResizeXRCamera(const FIntPoint& InSize) { return FIntPoint(0, 0); }
142
145
149 virtual UARPin* FindARPinByComponent(const USceneComponent* Component) const = 0;
150
157 virtual UARPin* OnPinComponent(USceneComponent* ComponentToPin, const FTransform& PinToWorldTransform, UARTrackedGeometry* TrackedGeometry = nullptr, const FName DebugName = NAME_None) = 0;
158
166 virtual bool OnPinComponentToARPin(USceneComponent* ComponentToPin, UARPin* Pin) = 0;
167
172 virtual void OnRemovePin(UARPin* PinToRemove) = 0;
173
179 virtual bool OnTryGetOrCreatePinForNativeResource(void* InNativeResource, const FString& InPinName, UARPin*& OutPin) { OutPin = nullptr; return false; }
180
182 virtual bool OnAddManualEnvironmentCaptureProbe(FVector Location, FVector Extent) = 0;
183
186
189
192
195
197 virtual TArray<FVector> OnGetPointCloud() const = 0;
198
200 virtual bool OnAddRuntimeCandidateImage(UARSessionConfig* SessionConfig, UTexture2D* CandidateTexture, FString FriendlyName, float PhysicalWidth) = 0;
201
202 virtual void* GetARSessionRawPointer() = 0;
204
207
209 virtual TArray<FARPose2D> OnGetTracked2DPose() const { return {}; }
210
212 virtual bool OnIsSceneReconstructionSupported(EARSessionType SessionType, EARSceneReconstruction SceneReconstructionMethod) const { return false; }
213
214 virtual bool OnAddTrackedPointWithName(const FTransform& WorldTransform, const FString& PointName, bool bDeletePointsWithSameName) { return false; }
215
217 virtual int32 OnGetNumberOfTrackedFacesSupported() const { return 1; }
218
220 virtual UARTexture* OnGetARTexture(EARTextureType TextureType) const { return nullptr; }
221
223
229 DEFINE_AR_DELEGATE_ONE_PARAM(OnTrackableAdded, UARTrackedGeometry* /* Added */);
230
236 DEFINE_AR_DELEGATE_ONE_PARAM(OnTrackableUpdated, UARTrackedGeometry* /* Updated */);
237
243 DEFINE_AR_DELEGATE_ONE_PARAM(OnTrackableRemoved, UARTrackedGeometry* /* Removed */);
244
245 // ARPin Local Store support.
246 // Some Platforms/Devices have the ability to persist AR Anchors (real world positiosn) to the device or user account.
247 // They are saved and loaded with a string identifier.
248
249 virtual bool IsLocalPinSaveSupported() const
250 {
251 return false;
252 }
253
254 virtual bool ArePinsReadyToLoad()
255 {
256 //UE_LOG(LogHMD, Log, TEXT("Pin Local Store is not supported on this platform"));
257 return false;
258 }
259
261 {
262 //UE_LOG(LogHMD, Log, TEXT("Pin Local Store is not supported on this platform"));
263 }
264 virtual bool SaveARPin(FName InName, UARPin* InPin)
265 {
266 //UE_LOG(LogHMD, Log, TEXT("Pin Local Store is not supported on this platform"));
267 return false;
268 }
269 virtual void RemoveSavedARPin(FName InName)
270 {
271 //UE_LOG(LogHMD, Log, TEXT("Pin Local Store is not supported on this platform"));
272 }
273 virtual void RemoveAllSavedARPins()
274 {
275 //UE_LOG(LogHMD, Log, TEXT("Pin Local Store is not supported on this platform"));
276 }
277
278 virtual bool OnGetCameraIntrinsics(FARCameraIntrinsics& OutCameraIntrinsics) const { return false; }
279};
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
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
FInt32Point FIntPoint
Definition MathFwd.h:124
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition NameTypes.h:617
Definition ARSystem.h:78
virtual void RemoveSavedARPin(FName InName)
Definition ARSystem.h:269
virtual void OnPauseARSession()=0
virtual EARTrackingQuality OnGetTrackingQuality() const =0
virtual bool OnAddTrackedPointWithName(const FTransform &WorldTransform, const FString &PointName, bool bDeletePointsWithSameName)
Definition ARSystem.h:214
virtual TArray< UARTrackedGeometry * > OnGetAllTrackedGeometries() const =0
virtual bool SaveARPin(FName InName, UARPin *InPin)
Definition ARSystem.h:264
virtual UARPin * FindARPinByComponent(const USceneComponent *Component) const =0
DEFINE_AR_DELEGATE_ONE_PARAM(OnTrackableUpdated, UARTrackedGeometry *)
virtual int32 OnGetNumberOfTrackedFacesSupported() const
Definition ARSystem.h:217
virtual void RemoveAllSavedARPins()
Definition ARSystem.h:273
virtual UARLightEstimate * OnGetCurrentLightEstimate() const =0
virtual EARTrackingQualityReason OnGetTrackingQualityReason() const =0
virtual TSharedPtr< FARGetCandidateObjectAsyncTask, ESPMode::ThreadSafe > OnGetCandidateObject(FVector Location, FVector Extent) const =0
virtual bool IsLocalPinSaveSupported() const
Definition ARSystem.h:249
virtual void OnSetAlignmentTransform(const FTransform &InAlignmentTransform)=0
virtual void * GetGameThreadARFrameRawPointer()=0
virtual void OnRemovePin(UARPin *PinToRemove)=0
virtual bool OnPinComponentToARPin(USceneComponent *ComponentToPin, UARPin *Pin)=0
virtual UARPin * OnPinComponent(USceneComponent *ComponentToPin, const FTransform &PinToWorldTransform, UARTrackedGeometry *TrackedGeometry=nullptr, const FName DebugName=NAME_None)=0
virtual void OnARSystemInitialized()
Definition ARSystem.h:81
virtual ~IARSystemSupport()
Definition ARSystem.h:222
virtual void OnSetEnabledXRCamera(bool bOnOff)
Definition ARSystem.h:140
virtual void OnStartARSession(UARSessionConfig *SessionConfig)=0
virtual TArray< UARPin * > OnGetAllPins() const =0
virtual FARSessionStatus OnGetARSessionStatus() const =0
virtual bool ArePinsReadyToLoad()
Definition ARSystem.h:254
virtual TSharedPtr< FARSaveWorldAsyncTask, ESPMode::ThreadSafe > OnSaveWorld() const =0
DEFINE_AR_DELEGATE_ONE_PARAM(OnTrackableAdded, UARTrackedGeometry *)
virtual TArray< FARVideoFormat > OnGetSupportedVideoFormats(EARSessionType SessionType) const =0
virtual bool OnGetCameraIntrinsics(FARCameraIntrinsics &OutCameraIntrinsics) const
Definition ARSystem.h:278
virtual bool OnIsSceneReconstructionSupported(EARSessionType SessionType, EARSceneReconstruction SceneReconstructionMethod) const
Definition ARSystem.h:212
virtual bool OnTryGetOrCreatePinForNativeResource(void *InNativeResource, const FString &InPinName, UARPin *&OutPin)
Definition ARSystem.h:179
virtual EARWorldMappingState OnGetWorldMappingStatus() const =0
virtual TArray< FARTraceResult > OnLineTraceTrackedObjects(const FVector Start, const FVector End, EARLineTraceChannels TraceChannels)=0
virtual UARTexture * OnGetARTexture(EARTextureType TextureType) const
Definition ARSystem.h:220
virtual FIntPoint OnResizeXRCamera(const FIntPoint &InSize)
Definition ARSystem.h:141
virtual bool OnAddManualEnvironmentCaptureProbe(FVector Location, FVector Extent)=0
virtual bool OnStartARGameFrame(FWorldContext &WorldContext)
Definition ARSystem.h:83
virtual TArray< FVector > OnGetPointCloud() const =0
virtual TArray< FARPose2D > OnGetTracked2DPose() const
Definition ARSystem.h:209
virtual void * GetARSessionRawPointer()=0
virtual void OnStopARSession()=0
DEFINE_AR_DELEGATE_ONE_PARAM(OnTrackableRemoved, UARTrackedGeometry *)
virtual bool IsARAvailable() const =0
virtual bool OnAddRuntimeCandidateImage(UARSessionConfig *SessionConfig, UTexture2D *CandidateTexture, FString FriendlyName, float PhysicalWidth)=0
virtual bool OnIsTrackingTypeSupported(EARSessionType SessionType) const =0
virtual TArray< FARTraceResult > OnLineTraceTrackedObjects(const FVector2D ScreenCoord, EARLineTraceChannels TraceChannels)=0
virtual void LoadARPins(TMap< FName, UARPin * > &LoadedPins)
Definition ARSystem.h:260
virtual bool OnToggleARCapture(const bool bOnOff, const EARCaptureType CaptureType)
Definition ARSystem.h:138
virtual bool OnIsSessionTrackingFeatureSupported(EARSessionType SessionType, EARSessionTrackingFeature SessionTrackingFeature) const
Definition ARSystem.h:206
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition ARLightEstimate.h:20
Definition ARPin.h:15
Definition ARSessionConfig.h:183
Definition ARTextures.h:107
Definition ARTextures.h:78
Definition ARTextures.h:31
Definition ARTrackable.h:17
Definition Texture2D.h:26
Definition ARTypes.h:601
Definition ARTypes.h:256
Definition ARTraceResult.h:17
Definition Engine.h:334
Definition IntPoint.h:25