AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
NeoCameraSensorBackend.h
Go to the documentation of this file.
1/*
2Copyright 2007-2026. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16#pragma once
18
19#if AGX_USE_AGXSENSOR()
21
22 #include <agxOSG/NeoCamera.h>
23
24 #include <agx/Singleton.h>
25
26 #include <unordered_map>
27#endif
28
29#if AGX_USE_AGXSENSOR()
30namespace agxOSG
31{
36 {
37 public:
45 static void configure(
46 osg::Group* sceneGraph, osg::Node* sceneNode, agxSDK::Simulation* simulation = nullptr, bool override = false);
47
51 static void injectAsCameraDefault();
52
59
65
71 static bool hasBackendCamera(agxSensor::Camera* camera);
72
74
75 public:
76 SINGLETON_CLASSNAME_METHOD();
77
78 virtual void shutdown() override;
79
81
82 private:
83 static NeoCameraSensorBackend& self();
84
85 private:
86 using NeoCameraSensorMap = std::unordered_map<agxSensor::Camera*, NeoCameraRef>;
87 using NeoCameraSensorColorOutputMap = std::unordered_map<
88 agxSensor::Camera*, std::unordered_map<agxSensor::CameraColorOutput*, NeoCameraColorImageOutputRef>>;
89
90 static void synchronize(agxSensor::Camera* camera, agx::Real dt);
91 static void execute(agxSensor::Camera* camera, agx::Real dt);
92 static void complete(agxSensor::Camera* camera);
93 static void result(agxSensor::Camera* camera, agx::Real dt);
94 static void synchronizeGraphics(agxSensor::Camera* camera, agxSensor::Matrix4x4* viewMatrix);
95 static void cleanup(agxSensor::Camera* camera);
96
97 static void setCameraLensSingleElement(
98 agxSensor::Camera* camera, agxSensor::CameraLensSingleElement* lens,
99 agxSensor::CameraLensSingleElementParameters* parameters);
100 static void setCameraCMOSSensor(
101 agxSensor::Camera* camera, agxSensor::CameraCMOSSensor* sensor,
102 agxSensor::CameraCMOSSensorParameters* parameters);
103
104 static void setCameraLensDistortionNone(agxSensor::Camera* camera, agxSensor::CameraLens* lens);
105 static void setCameraLensDistortionBrownConrady(
106 agxSensor::Camera* camera, agxSensor::CameraLens* lens,
107 agxSensor::LensDistortionBrownConradyCoefficients* coefficients);
108
109 static void setCameraColorOutput(
110 agxSensor::Camera* camera, agxSensor::CameraColorOutput* output,
111 agxSensor::CameraColorOutputParameters* parameters);
112 static void setCameraColorOutputAddress(
113 agxSensor::Camera* camera, agxSensor::CameraColorOutput* output, void* outputAddress);
114 static void captureCameraColorOutput(agxSensor::Camera* camera, agxSensor::CameraColorOutput* output);
115 static bool hasCameraColorOutputUnreadData(
116 agxSensor::Camera* camera, agxSensor::CameraColorOutput* output, bool markAsRead);
117
118 private:
120
121 NeoCamera* getOrCreateBackendCameraForInternal(agxSensor::Camera* camera);
122 void eraseBackendCameraOfInternal(agxSensor::Camera* camera);
123 bool hasBackendCameraInternal(agxSensor::Camera* camera);
124
125 NeoCameraColorImageOutput* getOrCreateBackendColorOutputForInternal(
126 agxSensor::Camera* camera, agxSensor::CameraColorOutput* output);
127
128 private:
129 std::unique_ptr<agxSensor::CameraBackend> m_backend;
130 NeoCameraSensorMap m_sensorMap;
131 NeoCameraSensorColorOutputMap m_sensorColorOutputMap;
132
133 osg::ref_ptr<osg::Group> m_sceneGraph;
134 osg::ref_ptr<osg::Node> m_sceneNode;
135 agxSDK::SimulationObserver m_simulation;
136 };
137}
138#endif
#define AGXOSG_EXPORT
Outputs the NeoCamera color feed to an image buffer of the specified format and color mapping matrix.
Definition: NeoCamera.h:518
The agxSensor camera backend for use of the agxOSG NeoCamera/agxViewer.
static void configure(osg::Group *sceneGraph, osg::Node *sceneNode, agxSDK::Simulation *simulation=nullptr, bool override=false)
Configure this backend for the given scene graph, and optionally simulation.
static void eraseBackendCameraOf(agxSensor::Camera *camera)
Delete the current backend for the given AGX camera.
static bool hasBackendCamera(agxSensor::Camera *camera)
Check if the given AGX camera has a current backend.
static NeoCamera * getOrCreateBackendCameraFor(agxSensor::Camera *camera)
Fetch or create a backend for the given AGX camera.
static void injectAsCameraDefault()
Set this backend as the default for the agxSensor Camera.
A new (as of 2026) extended camera type, allowing for more "cinematic"-like effects.
Definition: NeoCamera.h:56
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
Camera instance class defined by a frame/transform and a model.
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:31
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
The agxSensor namespace contains components to model real-time sensors connected to the physics of AG...
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
STL namespace.