VTK  9.4.20250509
Rendering/OpenXR/vtkOpenXRSceneObserver.h

vtkOpenXRSceneObserver is a wrapper around OpenXR scene understanding extensions

vtkOpenXRSceneObserver is a wrapper around OpenXR scene understanding extensions

vtkOpenXRSceneObserver uses an event based mecanism to retrieve components. vtkOpenXRSceneObserver will invoke vtkCommand::UpdateDataEvent when a new component is detected by the runtime. This event will forward the new component as calldata.

A vtkOpenXRSceneObserver is instanciated, initialized and updated by vtkOpenXRRenderWindow if vtkOpenXRRenderWindow::EnableSceneUnderstanding is true. vtkOpenXRSceneObserver::Initialize will be called by vtkOpenXRRenderWindow when initialized vtkOpenXRSceneObserver::UpdateSceneData is automatically called by vtkOpenXRRenderWindow::Render() for the window scene observer.

You may instantiate it manually and handle it's lifetime and updates on your own.

See also
vtkOpenXRRenderWindow::SetEnableSceneUnderstanding
vtkOpenXRRenderWindow::GetSceneObserver
vtkOpenXRSceneComponent
void OnNewComponent(vtkObject* object, unsigned long, void* calldata) {
auto* component = static_cast<vtkOpenXRSceneComponent*>(calldata);
}
renderWindow->SetEnableSceneUnderstanding(true);
renderWindow->Initialize();
vtkOpenXRSceneObserver* sceneObserver = renderWindow->GetSceneObserver();
assert(sceneObserver && "Something went wrong!");
callback->SetCallback(OnNewComponent);
sceneObserver->AddObserver(vtkCommand::UpdateDataEvent, callback);
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract base class for most VTK objects
Definition vtkObject.h:162
unsigned long AddObserver(unsigned long event, vtkCommand *, float priority=0.0f)
Allow people to add/remove/invoke observers (callbacks) to any VTK object.
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
#ifndef vtkOpenXRSceneObserver_h
#define vtkOpenXRSceneObserver_h
#include "vtkObject.h"
#include "vtkRenderingOpenXRModule.h" // For export macro
#include <memory> // For std::unique_ptr
VTK_ABI_NAMESPACE_BEGIN
class VTKRENDERINGOPENXR_EXPORT vtkOpenXRSceneObserver : public vtkObject
{
struct vtkInternals;
public:
bool Initialize();
bool UpdateSceneData();
enum SceneConsistency
{
// enum values from OpenXR
SnapshotComplete = 1,
SnapshotIncompleteFast = 2,
OcclusionOptimized = 3,
};
vtkGetMacro(ComputeConsistency, SceneConsistency);
vtkSetMacro(ComputeConsistency, SceneConsistency);
vtkGetMacro(ClippingRadius, double);
vtkSetClampMacro(ClippingRadius, double, 0.0, 1e100);
enum SceneFeature
{
// enum values from XrSceneComputeFeatureMSFT
Markers = 1000147000,
};
bool EnableComputeFeature(SceneFeature feature);
void DisableComputeFeature(SceneFeature feature);
bool IsComputeFeatureEnabled(SceneFeature feature) const;
bool IsComputeFeatureSupported(SceneFeature feature) const;
vtkSetMacro(MinimumInterval, double);
vtkGetMacro(MinimumInterval, double);
protected:
private:
void operator=(const vtkOpenXRSceneObserver&) = delete;
bool CreateMSFTSceneObserver();
std::unique_ptr<vtkInternals> Impl{};
double MinimumInterval{ 2.0 };
double ClippingRadius{ 2.0 };
SceneConsistency ComputeConsistency{ SceneConsistency::SnapshotComplete };
};
VTK_ABI_NAMESPACE_END
#endif
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
OpenXR rendering window.