VR-Engage  2.2
Loading...
Searching...
No Matches
instrumentPanelManagerStructs.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file instrumentPanelManagerStructs.h
7//! \brief Defines structures used by the instrument panel manager in VR-Engage
8//!
9//! This file contains the DtCameraStruct, DtPanelStruct, and DtTextureIndexDrawCallback
10//! classes which are used by the instrument panel manager to manage camera views,
11//! panels, and render-to-texture operations for instrument displays. These structures
12//! handle the configuration and rendering of instrument panel elements in 3D cockpits.
13
14#pragma once
15
17
18#include <vrvOsg/DtCameraNode.h>
19
20#include <osg/Object>
21#include <osg/ref_ptr>
22#include <osg/Texture2D>
23
24namespace makVrv
25{
26//! \brief Forward declaration of the entity facade class
27class DtEntityFacade;
28
29//! \brief Forward declaration of the observer class
30class DtObserver;
31
32//! \brief Forward declaration of the scene object class
33class DtSceneObject;
34
35//! \brief Forward declaration of the input driver class
36class DtInputDriver;
37
38//! \brief Forward declaration of the channel configuration class
39class DtChannelConfiguration;
40
41//! \brief Forward declaration of the OSG channel class
42class DtOsgChannel;
43
44//! \brief Forward declaration of the model definition class
45class DtModelDefinition;
46}; // namespace makVrv
47
48namespace osg
49{
50//! \brief Forward declaration of the render info class
51class RenderInfo;
52} // namespace osg
53
54namespace makVre
55{
56//! \brief Forward declaration of the interpolator class
57class DtInterpolator;
58
59//! \brief Forward declaration of the window operation message class
61
62//! \brief Forward declaration of the entity resolver class
64
65//! \brief Forward declaration of the initialization table class
66class DtInitTable;
67
68//! \brief Forward declaration of the texture index draw callback class
70
71//! \brief Enumeration of camera types used in instrument panels
72//!
73//! Defines the different types of cameras that can be used to render
74//! instrument panel views. Each type has different behaviors and rendering
75//! characteristics appropriate for different instrument display needs.
77{
78 Uninitialized = 0, //!< Camera is not yet initialized
79 Gimbal, //!< Camera with gimbal-like movement behavior
80 Stealth, //!< Camera that follows but doesn't affect the scene
81 PlanView, //!< Top-down map-like view camera
82 Panel //!< Instrument panel-specific camera
83};
84
85//! \brief Structure that manages camera and render-to-texture for instrument panels
86//!
87//! DtCameraStruct manages a camera view used for rendering to texture for
88//! an instrument panel display. It holds the configuration for a specific
89//! instrument panel camera, including render target settings, texture properties,
90//! and the associated OSG cameras. This struct maintains the relationships between
91//! the camera view, its output texture, and the display parameters.
93{
94 //! \brief Constructor
95 //! \param de Reference to the display engine
96 //!
97 //! Creates a new camera structure with default settings. Initializes all
98 //! camera properties to their default values and associates the structure
99 //! with the specified display engine.
100 DtCameraStruct(makVrv::DtDe& de)
101 : myDe(de)
103 , ownshipId(DtEntityIdentifier::nullId())
104 , windowName("")
105 , observerName("")
106 , channelName("")
107 , useCount(0)
108 , textureIndex(-1)
109 , textureOffsetX(0)
110 , textureOffsetY(0)
111 , textureWidth(512)
112 , textureHeight(512)
113 , rttCamera(0)
114 , overlayCamera(0)
115 , modelDef(NULL)
116 , mipRtt(false)
117 , rttIsHud(false)
118 , outputTexture()
120 {
121 }
122
123 //! \brief Handles viewport size or position changes
124 //! \param x New x-coordinate of the viewport
125 //! \param y New y-coordinate of the viewport
126 //! \param w New width of the viewport
127 //! \param h New height of the viewport
128 //!
129 //! Updates the camera and render-to-texture configuration when the viewport
130 //! dimensions or position change. This ensures the rendered output matches
131 //! the new viewport specifications.
132 void viewportChanged(int x, int y, int w, int h);
133
134 //! \brief Handles changes to the render texture
135 //!
136 //! Updates the camera and associated objects when the render texture
137 //! properties change. This ensures all components are properly synchronized
138 //! to use the updated texture.
140
141 //! \brief Callback executed during the rendering process
142 //! \param renderInfo Rendering information from OSG
143 //!
144 //! This callback is executed during the OSG rendering process. It handles
145 //! any custom rendering operations needed for this camera, such as setting
146 //! up texture indices or applying post-processing effects.
147 void drawCallback(osg::RenderInfo& renderInfo);
148
149 //! \brief Entity identifier of the ownship associated with this camera
150 DtEntityIdentifier ownshipId;
151
152 //! \brief Name of this camera
153 std::string name;
154
155 //! \brief Type of camera (Gimbal, Stealth, PlanView, Panel)
157
158 //! \brief Name of the window this camera renders to
159 std::string windowName;
160
161 //! \brief Name of the observer associated with this camera
162 std::string observerName;
163
164 //! \brief Name of the channel this camera renders to
165 std::string channelName;
166
167 //! \brief Reference count for this camera
168 //!
169 //! Tracks how many panel displays are using this camera view.
171
172 //! \brief Index of the texture in the texture array
174
175 //! \brief X-coordinate offset within the texture
177
178 //! \brief Y-coordinate offset within the texture
180
181 //! \brief Width of the render texture in pixels
183
184 //! \brief Height of the render texture in pixels
186
187 //! \brief Camera node used for render-to-texture operations
188 makVrv::DtCameraNode* rttCamera;
189
190 //! \brief Camera node used for rendering overlays on top of the main view
191 makVrv::DtCameraNode* overlayCamera;
192
193 //! \brief Reference to the output texture where the camera renders
194 osg::ref_ptr<osg::Texture2D> outputTexture;
195
196 //! \brief Name of the texture this RTT replaces in the model
197 std::string rttReplaces;
198
199 //! \brief Pointer to model definition associated with this camera
200 const makVrv::DtModelDefinition* modelDef;
201
202 //! \brief Flag indicating whether to generate mipmaps for the render texture
203 bool mipRtt;
204
205 //! \brief Flag indicating whether this render texture is for a HUD display
207
208 //! \brief Callback executed after drawing to handle post-render operations
210
211 //! \brief Reference to the display engine
212 makVrv::DtDe& myDe;
213};
214
215//! \brief Structure that manages a collection of instrument panels
216//!
217//! DtPanelStruct represents a group of related instrument panels associated
218//! with a specific entity. It manages the relationship between panel displays,
219//! their windows, and the cameras that render content to them. This struct forms
220//! the organizational structure for instrument panels in a cockpit or vehicle.
222{
223 //! \brief Constructor
224 //!
225 //! Creates a new panel structure with default settings. Initializes entity
226 //! identifiers to null and creates empty collections for windows and cameras.
228 : ownshipId(DtEntityIdentifier::nullId())
229 , panelHostId(DtEntityIdentifier::nullId())
230 , windows()
231 , cameras()
232 {
233 }
234
235 //! \brief Entity identifier of the ownship associated with these panels
236 DtEntityIdentifier ownshipId;
237
238 //! \brief Entity identifier of the host entity containing these panels
239 DtEntityIdentifier panelHostId;
240
241 //! \brief Type definition for mapping window names to model definition names
242 using WindowNameModelDefMap = std::map<std::string, std::string>;
243
244 //! \brief Map of window names to their associated model definition names
246
247 //! \brief Type definition for mapping camera names to camera structures
248 using CameraMap = std::map<std::string, DtCameraStruct*>;
249
250 //! \brief Map of camera names to their associated camera structures
252};
253
254//! \brief Draw callback that sets the correct texture index for instrument panel displays
255//!
256//! DtTextureIndexDrawCallback is an OSG draw callback that ensures the correct
257//! texture index is used when rendering to an instrument panel display. This is
258//! particularly important for GLStudio widgets, which need specific texture indices
259//! to properly display rendered content. The callback executes during the rendering
260//! process to maintain proper texture synchronization.
261class PLAYERSTATION_DLL DtTextureIndexDrawCallback : public osg::Camera::DrawCallback
262{
263public:
264 //! \brief OSG meta object declaration for proper type handling
266
267 //! \brief Default constructor
268 //!
269 //! Creates a new texture index draw callback with no associated camera structure.
271 : osg::Camera::DrawCallback()
272 , myCameraStruct(0)
273 {
274 }
275
276 //! \brief Constructor with camera structure
277 //! \param cs Pointer to the camera structure this callback is associated with
278 //!
279 //! Creates a new texture index draw callback associated with the specified
280 //! camera structure. The callback will use the camera structure's texture index
281 //! and other properties during rendering.
283 : osg::Camera::DrawCallback()
284 , myCameraStruct(cs)
285 {
286 }
287
288 //! \brief Copy constructor
289 //! \param cb Draw callback to copy from
290 //! \param co Copy operation to use
291 //!
292 //! Creates a new texture index draw callback by copying from an existing
293 //! draw callback. This constructor is required by the OSG object system
294 //! for proper cloning and copying of objects.
295 DtTextureIndexDrawCallback(const DrawCallback& cb, const osg::CopyOp& co)
296 : osg::Camera::DrawCallback(cb, co)
297 , myCameraStruct(0)
298 {
299 }
300
301 //! \brief Destructor
302 //!
303 //! Cleans up resources used by the texture index draw callback.
304 virtual ~DtTextureIndexDrawCallback() override {}
305
306 //! \brief Functor method called by the rendering thread
307 //! \param renderInfo Rendering information from OSG
308 //!
309 //! This method is called by the OSG rendering thread during the rendering
310 //! process. It delegates to the camera structure's drawCallback method to
311 //! handle the actual texture index updating and any other rendering operations.
312 virtual void operator()(osg::RenderInfo& renderInfo) const override { myCameraStruct->drawCallback(renderInfo); }
313
314 //! \brief Backwards compatibility functor method
315 //! \param camera Camera being rendered
316 //!
317 //! This method is provided for backwards compatibility with older OSG
318 //! versions. It is called by the operator()(osg::RenderInfo&) method
319 //! in those versions. This implementation is intentionally empty as
320 //! the actual work is done in the other operator() method.
321 virtual void operator()(const osg::Camera& /*camera*/) const override {}
322
323protected:
324 //! \brief Pointer to the camera structure this callback is associated with
326
327private:
328 //! \brief Copy constructor (deleted)
329 //!
330 //! Copy construction is not supported for this class.
332
333 //! \brief Assignment operator (deleted)
334 //!
335 //! Assignment is not supported for this class.
337};
338} // namespace makVre
Entity resolution and mapping system.
Definition entityResolver.h:52
Table-based access to Lua state for configuration data.
Definition initializer.h:38
Draw callback that sets the correct texture index for instrument panel displays.
Definition instrumentPanelManagerStructs.h:262
DtTextureIndexDrawCallback & operator=(const DtTextureIndexDrawCallback &orig)
Assignment operator (deleted)
DtTextureIndexDrawCallback(const DtTextureIndexDrawCallback &)
Copy constructor (deleted)
DtTextureIndexDrawCallback()
Default constructor.
Definition instrumentPanelManagerStructs.h:270
META_Object(osg, DtTextureIndexDrawCallback)
OSG meta object declaration for proper type handling.
virtual void operator()(const osg::Camera &) const override
Backwards compatibility functor method.
Definition instrumentPanelManagerStructs.h:321
makVre::DtCameraStruct * myCameraStruct
Pointer to the camera structure this callback is associated with.
Definition instrumentPanelManagerStructs.h:325
DtTextureIndexDrawCallback(const DrawCallback &cb, const osg::CopyOp &co)
Copy constructor.
Definition instrumentPanelManagerStructs.h:295
virtual void operator()(osg::RenderInfo &renderInfo) const override
Functor method called by the rendering thread.
Definition instrumentPanelManagerStructs.h:312
DtTextureIndexDrawCallback(makVre::DtCameraStruct *cs)
Constructor with camera structure.
Definition instrumentPanelManagerStructs.h:282
virtual ~DtTextureIndexDrawCallback() override
Destructor.
Definition instrumentPanelManagerStructs.h:304
Definition windowOperation.h:32
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtCameraType
Enumeration of camera types used in instrument panels.
Definition instrumentPanelManagerStructs.h:77
@ Uninitialized
Camera is not yet initialized.
Definition instrumentPanelManagerStructs.h:78
@ PlanView
Top-down map-like view camera.
Definition instrumentPanelManagerStructs.h:81
@ Panel
Instrument panel-specific camera.
Definition instrumentPanelManagerStructs.h:82
@ Gimbal
Camera with gimbal-like movement behavior.
Definition instrumentPanelManagerStructs.h:79
@ Stealth
Camera that follows but doesn't affect the scene.
Definition instrumentPanelManagerStructs.h:80
Definition appLauncherComponent.h:28
Definition DtSceneObjectMimicUpdater.h:31
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.
Structure that manages camera and render-to-texture for instrument panels.
Definition instrumentPanelManagerStructs.h:93
makVre::DtTextureIndexDrawCallback * postDrawCallback
Callback executed after drawing to handle post-render operations.
Definition instrumentPanelManagerStructs.h:209
int textureIndex
Index of the texture in the texture array.
Definition instrumentPanelManagerStructs.h:173
makVrv::DtDe & myDe
Reference to the display engine.
Definition instrumentPanelManagerStructs.h:212
void viewportChanged(int x, int y, int w, int h)
Handles viewport size or position changes.
makVrv::DtCameraNode * overlayCamera
Camera node used for rendering overlays on top of the main view.
Definition instrumentPanelManagerStructs.h:191
std::string channelName
Name of the channel this camera renders to.
Definition instrumentPanelManagerStructs.h:165
const makVrv::DtModelDefinition * modelDef
Pointer to model definition associated with this camera.
Definition instrumentPanelManagerStructs.h:200
std::string windowName
Name of the window this camera renders to.
Definition instrumentPanelManagerStructs.h:159
int textureOffsetX
X-coordinate offset within the texture.
Definition instrumentPanelManagerStructs.h:176
int textureWidth
Width of the render texture in pixels.
Definition instrumentPanelManagerStructs.h:182
int useCount
Reference count for this camera.
Definition instrumentPanelManagerStructs.h:170
std::string rttReplaces
Name of the texture this RTT replaces in the model.
Definition instrumentPanelManagerStructs.h:197
makVrv::DtCameraNode * rttCamera
Camera node used for render-to-texture operations.
Definition instrumentPanelManagerStructs.h:188
void drawCallback(osg::RenderInfo &renderInfo)
Callback executed during the rendering process.
void renderTextureChanged()
Handles changes to the render texture.
int textureHeight
Height of the render texture in pixels.
Definition instrumentPanelManagerStructs.h:185
DtCameraType cameraType
Type of camera (Gimbal, Stealth, PlanView, Panel)
Definition instrumentPanelManagerStructs.h:156
std::string observerName
Name of the observer associated with this camera.
Definition instrumentPanelManagerStructs.h:162
int textureOffsetY
Y-coordinate offset within the texture.
Definition instrumentPanelManagerStructs.h:179
DtCameraStruct(makVrv::DtDe &de)
Constructor.
Definition instrumentPanelManagerStructs.h:100
DtEntityIdentifier ownshipId
Entity identifier of the ownship associated with this camera.
Definition instrumentPanelManagerStructs.h:150
osg::ref_ptr< osg::Texture2D > outputTexture
Reference to the output texture where the camera renders.
Definition instrumentPanelManagerStructs.h:194
bool mipRtt
Flag indicating whether to generate mipmaps for the render texture.
Definition instrumentPanelManagerStructs.h:203
std::string name
Name of this camera.
Definition instrumentPanelManagerStructs.h:153
bool rttIsHud
Flag indicating whether this render texture is for a HUD display.
Definition instrumentPanelManagerStructs.h:206
DtEntityIdentifier panelHostId
Entity identifier of the host entity containing these panels.
Definition instrumentPanelManagerStructs.h:239
DtEntityIdentifier ownshipId
Entity identifier of the ownship associated with these panels.
Definition instrumentPanelManagerStructs.h:236
DtPanelStruct()
Constructor.
Definition instrumentPanelManagerStructs.h:227
std::map< std::string, DtCameraStruct * > CameraMap
Type definition for mapping camera names to camera structures.
Definition instrumentPanelManagerStructs.h:248
std::map< std::string, std::string > WindowNameModelDefMap
Type definition for mapping window names to model definition names.
Definition instrumentPanelManagerStructs.h:242
WindowNameModelDefMap windows
Map of window names to their associated model definition names.
Definition instrumentPanelManagerStructs.h:245
CameraMap cameras
Map of camera names to their associated camera structures.
Definition instrumentPanelManagerStructs.h:251