Add option to reconfigure ar session
This commit is contained in:
@@ -157,6 +157,10 @@ namespace OpenVulkano::AR
|
||||
static bool IsNativeArAvailable();
|
||||
|
||||
virtual ~ArSession() = default;
|
||||
|
||||
virtual void Configure(const ArSessionConfig& config) {}
|
||||
|
||||
virtual void Restart() { Stop(); Start(); }
|
||||
|
||||
/**
|
||||
* Starts the AR session.
|
||||
|
||||
@@ -25,6 +25,10 @@ namespace OpenVulkano::AR::ArKit
|
||||
ArSessionArKitInternal(const ArSessionConfig& config);
|
||||
|
||||
~ArSessionArKitInternal() override;
|
||||
|
||||
void Configure(const ArSessionConfig& config) override;
|
||||
|
||||
void Restart() override;
|
||||
|
||||
void Start() override;
|
||||
|
||||
|
||||
@@ -79,6 +79,26 @@ namespace OpenVulkano::AR::ArKit
|
||||
: m_frameId(0)
|
||||
{
|
||||
m_arKitDelegate = [[ArKitDelegate alloc] initWithFrameHandler:this];
|
||||
|
||||
Configure(config);
|
||||
|
||||
m_arSession = [ARSession new];
|
||||
m_arSession.delegate = m_arKitDelegate;
|
||||
|
||||
running = false;
|
||||
}
|
||||
|
||||
ArSessionArKitInternal::~ArSessionArKitInternal()
|
||||
{
|
||||
Stop();
|
||||
[m_arSession release];
|
||||
[m_arConfig release];
|
||||
[m_arKitDelegate release];
|
||||
Logger::AR->info("Released AR session");
|
||||
}
|
||||
|
||||
void ArSessionArKitInternal::Configure(const ArSessionConfig& config)
|
||||
{
|
||||
if (config.useFrontCamera)
|
||||
{
|
||||
#ifdef OPENVULKANO_ENABLE_ARKIT_TRUEDEPTH
|
||||
@@ -104,7 +124,7 @@ namespace OpenVulkano::AR::ArKit
|
||||
arConfig.autoFocusEnabled = config.autoFocus;
|
||||
m_arConfig = arConfig;
|
||||
}
|
||||
|
||||
|
||||
// Set video format
|
||||
{
|
||||
Logger::AR->debug("Supported Video Formats: {}", SupportedVideoFormatsToString(config.useFrontCamera));
|
||||
@@ -119,20 +139,6 @@ namespace OpenVulkano::AR::ArKit
|
||||
metadata.imageResolution = { m_arConfig.videoFormat.imageResolution.width, m_arConfig.videoFormat.imageResolution.height };
|
||||
metadata.frameRate = m_arConfig.videoFormat.framesPerSecond;
|
||||
}
|
||||
|
||||
m_arSession = [ARSession new];
|
||||
m_arSession.delegate = m_arKitDelegate;
|
||||
|
||||
running = false;
|
||||
}
|
||||
|
||||
ArSessionArKitInternal::~ArSessionArKitInternal()
|
||||
{
|
||||
Stop();
|
||||
[m_arSession release];
|
||||
[m_arConfig release];
|
||||
[m_arKitDelegate release];
|
||||
Logger::AR->info("Released AR session");
|
||||
}
|
||||
|
||||
void ArSessionArKitInternal::SetRenderer(IRenderer* renderer)
|
||||
@@ -179,6 +185,12 @@ namespace OpenVulkano::AR::ArKit
|
||||
//#endif
|
||||
running = false;
|
||||
}
|
||||
|
||||
void ArSessionArKitInternal::Restart()
|
||||
{
|
||||
[m_arSession pause];
|
||||
[m_arSession runWithConfiguration:m_arConfig];
|
||||
}
|
||||
|
||||
void ArSessionArKitInternal::Pause()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user