VR-Engage  2.2
Loading...
Searching...
No Matches
humanRenderUpdater.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*****************************************************************************/
5//! \file humanRenderUpdater.h
6//! \brief Defines DtHumanRenderUpdater for managing human-specific rendering and visual effects
7//! \ingroup vreHumanFrontend
8
9#pragma once
10
12
15
17
19
20#include <vrvCore/DtUniqueID.h>
21
22class diguyCharacter;
23
24namespace makVrv
25{
26//! \brief Forward declaration of the display element class
27class DtDe;
28
29//! \brief Forward declaration of the character model agent class
30class DtCharacterModelAgent;
31
32//! \brief Forward declaration of the scene object agent class
33class DtSceneObjectAgent;
34
35//! \brief Forward declaration of the scene object class
36class DtSceneObject;
37
38//! \brief Forward declaration of the dead reckon updater agent class
39class DtDeadReckonUpdaterAgent;
40
41//! \brief Forward declaration of the dead reckon updater class
42class DtDeadReckonUpdater;
43
44//! \brief Forward declaration of the terrain scaling updater class
45class DtTerrainScalingUpdater;
46
47//! \brief Forward declaration of the OSG channel class
48class DtOsgChannel;
49}; // namespace makVrv
50
52{
53//! \ingroup RoleConfigParams
54//! \defgroup HumanRenderUpdaterRoleParams Human Render Updater Role Parameters
55//! \roleInherits{PlayerComponentRoleParams}
56//! Configuration Options for human render updater role.
57//! @{
58
59//! \vreRoleParamRequired{firstPersonModelMap,DtInitTable,humanRenderUpdater,"Table",Mapping between weapons and model definitions for first-person view.}
60constexpr const char* firstPersonModelMap = "firstPersonModelMap";
61
62//! \vreRoleParam{healthEffectHealthMaximum,double,0.85,humanRenderUpdater,Maximum health value for health effect visibility.}
63constexpr const char* healthEffectHealthMaximum = "healthEffectHealthMaximum";
64
65//! \vreRoleParam{healthEffectHealthMinimum,double,0.15,humanRenderUpdater,Minimum health value for health effect visibility to prevent screen from going completely opaque.}
66constexpr const char* healthEffectHealthMinimum = "healthEffectHealthMinimum";
67
68//! \vreRoleParam{healthEffectOpacityMaximum,double,0.4,humanRenderUpdater,Maximum opacity value for health effects overlay.}
69constexpr const char* healthEffectOpacityMaximum = "healthEffectOpacityMaximum";
70
71//! \vreRoleParam{hideFirstPersonModelWhileAiming,bool,false,humanRenderUpdater,Whether to hide the first-person player model when aiming. Not applicable in VR mode.}
72constexpr const char* hideFirstPersonModelWhileAiming = "hideFirstPersonModelWhileAiming";
73
74//! \vreRoleParam{hitEffectDuration,double,4.0,humanRenderUpdater,Duration of hit effects in seconds.}
75constexpr const char* hitEffectDuration = "hitEffectDuration";
76
77//! @}
78} // namespace HumanRenderUpdaterConfig
79
80namespace makVre
81{
82//! \brief Forward declaration of the first-person updater agent class
83class DtFpsFirstPersonUpdaterAgent;
84
85//! \brief Forward declaration of the orientation updater agent class
86class DtFpsOrientationUpdaterAgent;
87
88//! \brief Type identifier constant for DtHumanRenderUpdater components
89//!
90//! This constant defines the string identifier used to identify DtHumanRenderUpdater
91//! component types within the VR-Engage framework. It is used for component
92//! registration, type checking, and serialization operations.
93constexpr const char* DtHumanRenderUpdaterType = "DtHumanRenderUpdater";
94
95//! \brief DtHumanRenderUpdater manages model and visual effects for Human role player.
96//!
97//! The primary function of this class is management of first person arms and gun model.
98//! This class owns the first person model agent and first person mimic model updater,
99//! and is responsible for selecting the appropriate first person model depending on
100//! active gun and/or equipment, hiding or showing the model based on 1st/3rd person
101//! view mode or other condition such as death, (re)positioning model relative to camera
102//! based on posture, and setting aiming and firing state of first person model when
103//! necessary. This class also manages overlay effects such as sniper rifle sights and
104//! blood overlay effects that indicate when and from where the player is taking hits.
106{
107public:
108 //! \brief Default constructor
110
111 //! \brief Virtual destructor
112 virtual ~DtHumanRenderUpdater() override;
113
114 //! \brief Initializes the render updater component
115 //! \param player Pointer to the player station
116 //! \param config Configuration settings for initialization
117 //! \return True if initialization was successful, false otherwise
119
120 //! \brief Updates rendering elements for the current frame
121 //! \param dt Delta time since the last frame in seconds
122 virtual void tick(double dt) override;
123
124 //! \brief Cleans up resources when the component is being shut down
125 virtual void shutdown() override;
126
127 //! \brief Returns the component type identifier
128 //! \return String identifier for this component type
129 //!
130 //! Returns the type identifier string for this component, which is used
131 //! by the VR-Engage framework for component identification and management.
132 //! The returned value matches DtHumanRenderUpdaterType.
133 virtual const char* type() const override;
134
135 //! \brief Shows the first-person model
137
138 //! \brief Hides the first-person model
140
141 //! \brief Shows the third-person model
143
144 //! \brief Sets the visibility of the third-person model
145 //! \param visible True to show the model, false to hide it
146 void setThirdPersonVisible(bool visible);
147
148 //! \brief Sets the offset of the first-person model
149 //! \param translation Translation offset vector
150 //! \param rotation Rotation offset in Tait-Bryan angles
151 void setFirstPersonModelOffset(DtVector translation, DtTaitBryan rotation = DtTaitBryan());
152
153 //! \brief Finds the appropriate first-person model offset for the given state
154 //! \param posture Current human posture
155 //! \param aiming True if the player is currently aiming
156 //! \param usingVr True if VR mode is active
157 //! \param translation [out] Pointer to receive the translation offset, can be nullptr
158 //! \param rotation [out] Pointer to receive the rotation offset, can be nullptr
159 //! \return True if offsets were found, false otherwise
160 bool findFirstPersonModelOffset(HumanPosture posture, bool aiming, bool usingVr, DtVector* translation = nullptr,
161 DtTaitBryan* rotation = nullptr);
162
163protected:
164 //! \brief Enumeration of hit effect positions
165 //!
166 //! Used to track the timers for each hit effect location
167 using HitEffectEnum = enum {
168 HIT_EFFECT_LEFT_SIDE, //!< Hit effect on the left side of the screen
169 HIT_EFFECT_RIGHT_SIDE, //!< Hit effect on the right side of the screen
170 HIT_EFFECT_ALL_SIDES, //!< Hit effect on all sides of the screen
171 HIT_EFFECT_NUMBER_EFFECTS //!< Total number of hit effect types (must be last)
172 };
173
174
175 //! \brief Initializes render objects like models and effects
176 //! \return True if initialization was successful, false otherwise
178
179 //! \brief Clears any active scene selections
181
182 //! \brief Configures dead reckoning and movement smoothing
184
185 //! \brief Updates blood sight (damage) overlay effects
187
188 //! \brief Updates the first-person model state and position
189 //! \param dt Delta time since the last frame in seconds
190 void updateFirstPersonModel(double dt);
191
192 //! \brief Updates the third-person model state and position
193 //! \param dt Delta time since the last frame in seconds
194 void updateThirdPersonModel(double dt);
195
196 //! \brief Updates aiming-related visual effects
198
199 //! \brief Updates equipment-related visual effects
201 //! \brief Updates health-related visual effects
202 //!
203 //! Updates the effect that shows when the human's damage state is slight or moderate
205
206 //! \brief Updates hit-related visual effects
207 //! \param dt Delta time since the last frame in seconds
208 //!
209 //! Updates the hit effect when the human is hit by a munition. It shows effects on
210 //! the right, left, or all corners of the GUI.
211 void updateHitEffects(double dt);
212
213 //! \brief Starts a hit effect timer
214 //! \param hitEffect The hit effect type to start
215 virtual void startHitEffect(HitEffectEnum hitEffect);
216
217 //! \brief Stops a hit effect timer
218 //! \param hitEffect The hit effect type to stop
219 virtual void stopHitEffect(HitEffectEnum hitEffect);
220
221 //! \brief Handles fire messages
222 //! \param msg Pointer to the message being processed
223 //! \return Message processing result
225
226 //! \brief Handles detonation location messages
227 //! \param msg Pointer to the message being processed
228 //! \return Message processing result
230
231 //! \brief Handles changes in player health
232 //! \param val New health value
233 void onHealthChanged(double val);
234
235 //! \brief Looks up the dead reckoning updater for a scene object
236 //! \param myDisSceneObject Pointer to the scene object
237 //! \return Pointer to the dead reckoning updater, or nullptr if not found
238 const makVrv::DtDeadReckonUpdater* lookupDeadReckonUpdater(makVrv::DtSceneObject* myDisSceneObject);
239
240 //! \brief Handles scene object deletion notifications
241 //! \param id Unique ID of the scene object being deleted
242 virtual void slot_disSceneObjectToBeDeleted(const makVrv::DtUniqueID& id);
243
244 //! \brief Duration of hit effects in seconds
246
247 //! \brief Minimum health value for health effect visibility
248 //!
249 //! The minimum health that the health effect will change. Don't want the screen to go completely opaque
251
252 //! \brief Maximum health value for health effect visibility
253 //!
254 //! The maximum health that the health effect will change
256
257 //! \brief Maximum opacity value for health effects
259
260 //! \brief Mapping between weapons and model definitions
262
263 //! \brief Configuration table for first-person models
265
266 //! \brief Agent managing the first-person character model
267 makVrv::DtCharacterModelAgent* myFirstPersonModelAgent;
268
269 //! \brief Agent managing the first-person scene object
270 makVrv::DtSceneObjectAgent* myFirstPersonSceneObjectAgent;
271
272 //! \brief Agent managing first-person model updates
274
275 //! \brief Agent managing orientation updates
277
278 //! \brief Main scene object for the player entity
279 makVrv::DtSceneObject* myDisSceneObject;
280
281 //! \brief Current weapon identifier
282 std::string myDisGun;
283
284 //! \brief Current appearance identifier
285 std::string myDisAppearance;
286
287 //! \brief Finds the appropriate first-person model definition
288 //! \param gun Current weapon identifier
289 //! \param appearance Current appearance identifier
290 //! \return Model definition identifier string
291 std::string findFirstPersonModelDef(const std::string& gun, const std::string& appearance);
292
293 //! \brief Finds the DI-Guy character for the player
294 //! \return Pointer to the DI-Guy character, or nullptr if not found
295 diguyCharacter* findDisDiguyCharacter();
296
297 //! \brief Flag indicating if first-person view is currently shown
299
300 //! \brief Current posture of the arms model
302
303 //! \brief Flag indicating if weapon is in the down position
305
306 //! \brief Last known aiming state
308
309 //! \brief Flag indicating if render objects have been initialized
311
312 //! \brief Flag indicating if first-person objects have been initialized
314
315 //! \brief Pointer to the main rendering channel
316 makVrv::DtOsgChannel* myChannel;
317
318 //! \brief Time when the sight effect should end
320
321 //! \brief Last known equipment state
323
324 //! \brief Delay before switching models in seconds
326
327 //! \brief Delay before showing models in seconds
329
330 //! \brief Current pitch angle of the arms model
332
333 //! \brief Additional pitch angle for arc aiming
335
336 //! \brief Pitch offset for the first-person model
338
339 //! \brief Heading (yaw) offset for the first-person model
341
342 //! \brief Flag indicating if VR mode is active
344
345 //! \brief Flag indicating whether to hide the first-person player model while aiming (not applicable in VR)
347
348 //! \brief Tracks whether first-person model was visible before entering aiming mode
350
351 //! \brief Enumeration of hit effect states
352 //!
353 //! These states are necessary to have interruptible hit effects
354 using HitEffectState = enum {
355 HIT_EFFECT_STATE_OFF, //!< Hit effect is disabled
356 HIT_EFFECT_STATE_ON, //!< Hit effect is enabled
357 HIT_EFFECT_STATE_INTERRUPT //!< Hit effect is being interrupted
358 //!< This state is used to give the Post Processor state to run once when
359 //!< the post processor effect is disabled. This allows its state machine
360 //!< to reset and the effect to play correctly when interrupted.
361 };
362
363 //! \brief Structure containing hit effect information
365 {
366 //! \brief Default constructor
368 : hitEffectState(HIT_EFFECT_STATE_OFF)
369 , timer(0.0)
370 {
371 }
372
373 std::string effectName; //!< The Post Processor name. Used to enable/disable the effect.
374 double timer; //!< The timer to determine when the effect should be removed.
375 //!< This timer needs to be coordinated with any front-end timers.
376 HitEffectState hitEffectState; //!< Current state of this hit effect
377 };
378
379 //! \brief Collection of hit effects and their information
380 //!
381 //! Timer used to control the hit effect which appears in the corners of the GUI
382 std::vector<std::pair<HitEffectEnum, HitEffectInfo>> myHitEffect;
383};
384}; // namespace makVre
Type-specific handle class for attributes.
Definition attributeHandle.h:181
Agent class for remote control of DtFpsFirstPersonUpdater objects.
Definition DtFpsFirstPersonUpdaterAgent.hpp:31
Agent class for remote control of DtFpsOrientationUpdater objects.
Definition DtFpsOrientationUpdaterAgent.hpp:31
double myHealthEffectOpacityMaximum
Maximum opacity value for health effects.
Definition humanRenderUpdater.h:258
double myArcPitchAddition
Additional pitch angle for arc aiming.
Definition humanRenderUpdater.h:334
double myFirstPersonModelPitchOffset
Pitch offset for the first-person model.
Definition humanRenderUpdater.h:337
double myEndSightEffect
Time when the sight effect should end.
Definition humanRenderUpdater.h:319
void updateEquipmentEffects()
Updates equipment-related visual effects.
std::string findFirstPersonModelDef(const std::string &gun, const std::string &appearance)
Finds the appropriate first-person model definition.
virtual const char * type() const override
Returns the component type identifier.
bool myUsingVr
Flag indicating if VR mode is active.
Definition humanRenderUpdater.h:343
enum { HIT_EFFECT_LEFT_SIDE, HIT_EFFECT_RIGHT_SIDE, HIT_EFFECT_ALL_SIDES, HIT_EFFECT_NUMBER_EFFECTS } HitEffectEnum
Enumeration of hit effect positions.
Definition humanRenderUpdater.h:167
double myFirstPersonModelHeadingOffset
Heading (yaw) offset for the first-person model.
Definition humanRenderUpdater.h:340
std::string myDisGun
Current weapon identifier.
Definition humanRenderUpdater.h:282
virtual ~DtHumanRenderUpdater() override
Virtual destructor.
bool myLastKnownAiming
Last known aiming state.
Definition humanRenderUpdater.h:307
std::vector< std::pair< HitEffectEnum, HitEffectInfo > > myHitEffect
Collection of hit effects and their information.
Definition humanRenderUpdater.h:382
void setFirstPersonModelOffset(DtVector translation, DtTaitBryan rotation=DtTaitBryan())
Sets the offset of the first-person model.
bool findFirstPersonModelOffset(HumanPosture posture, bool aiming, bool usingVr, DtVector *translation=nullptr, DtTaitBryan *rotation=nullptr)
Finds the appropriate first-person model offset for the given state.
int myArmsPosture
Current posture of the arms model.
Definition humanRenderUpdater.h:301
void updateFirstPersonModel(double dt)
Updates the first-person model state and position.
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the render updater component.
void updateHitEffects(double dt)
Updates hit-related visual effects.
void showThirdPerson()
Shows the third-person model.
makVrv::DtOsgChannel * myChannel
Pointer to the main rendering channel.
Definition humanRenderUpdater.h:316
bool myWeaponDown
Flag indicating if weapon is in the down position.
Definition humanRenderUpdater.h:304
double myHealthEffectHealthMinimum
Minimum health value for health effect visibility.
Definition humanRenderUpdater.h:250
DtInitTable myFirstPersonModelTable
Configuration table for first-person models.
Definition humanRenderUpdater.h:264
DtFpsOrientationUpdaterAgent * myOrientationUpdaterAgent
Agent managing orientation updates.
Definition humanRenderUpdater.h:276
bool myFirstPersonVisibleBeforeAiming
Tracks whether first-person model was visible before entering aiming mode.
Definition humanRenderUpdater.h:349
virtual void tick(double dt) override
Updates rendering elements for the current frame.
bool myShowingFirstPerson
Flag indicating if first-person view is currently shown.
Definition humanRenderUpdater.h:298
void clearSceneSelection()
Clears any active scene selections.
double myModelSwitchDelay
Delay before switching models in seconds.
Definition humanRenderUpdater.h:325
DtHumanRenderUpdater()
Default constructor.
Equipment myLastKnownEquipment
Last known equipment state.
Definition humanRenderUpdater.h:322
void setThirdPersonVisible(bool visible)
Sets the visibility of the third-person model.
std::string myDisAppearance
Current appearance identifier.
Definition humanRenderUpdater.h:285
virtual makVre::DtVreMessageResult handleReportDetonationLocationMessage(makVre::DtVreMessage *msg)
Handles detonation location messages.
double myModelShowDelay
Delay before showing models in seconds.
Definition humanRenderUpdater.h:328
const makVrv::DtDeadReckonUpdater * lookupDeadReckonUpdater(makVrv::DtSceneObject *myDisSceneObject)
Looks up the dead reckoning updater for a scene object.
virtual void slot_disSceneObjectToBeDeleted(const makVrv::DtUniqueID &id)
Handles scene object deletion notifications.
DtAttributeHandleType< bool > myHideFirstPersonModelWhileAiming
Flag indicating whether to hide the first-person player model while aiming (not applicable in VR)
Definition humanRenderUpdater.h:346
DtInitTable myFirstPersonModelMap
Mapping between weapons and model definitions.
Definition humanRenderUpdater.h:261
virtual void shutdown() override
Cleans up resources when the component is being shut down.
bool myRenderObjectsInitialized
Flag indicating if render objects have been initialized.
Definition humanRenderUpdater.h:310
bool myFirstPersonObjectsInitialized
Flag indicating if first-person objects have been initialized.
Definition humanRenderUpdater.h:313
DtFpsFirstPersonUpdaterAgent * myFirstPersonUpdaterAgent
Agent managing first-person model updates.
Definition humanRenderUpdater.h:273
void showFirstPerson()
Shows the first-person model.
virtual void startHitEffect(HitEffectEnum hitEffect)
Starts a hit effect timer.
double myHealthEffectHealthMaximum
Maximum health value for health effect visibility.
Definition humanRenderUpdater.h:255
virtual void stopHitEffect(HitEffectEnum hitEffect)
Stops a hit effect timer.
makVrv::DtSceneObject * myDisSceneObject
Main scene object for the player entity.
Definition humanRenderUpdater.h:279
void configureDeadReckoningAndSmoothing()
Configures dead reckoning and movement smoothing.
void onHealthChanged(double val)
Handles changes in player health.
makVrv::DtCharacterModelAgent * myFirstPersonModelAgent
Agent managing the first-person character model.
Definition humanRenderUpdater.h:267
void hideFirstPerson()
Hides the first-person model.
diguyCharacter * findDisDiguyCharacter()
Finds the DI-Guy character for the player.
void updateBloodSightEffects()
Updates blood sight (damage) overlay effects.
double myArmsPitch
Current pitch angle of the arms model.
Definition humanRenderUpdater.h:331
virtual makVre::DtVreMessageResult handleFireMessage(makVre::DtVreMessage *msg)
Handles fire messages.
bool initializeRenderObjects()
Initializes render objects like models and effects.
void updateThirdPersonModel(double dt)
Updates the third-person model state and position.
enum { HIT_EFFECT_STATE_OFF, HIT_EFFECT_STATE_ON, HIT_EFFECT_STATE_INTERRUPT } HitEffectState
Enumeration of hit effect states.
Definition humanRenderUpdater.h:354
void updateAimingEffects()
Updates aiming-related visual effects.
double myHitEffectDuration
Duration of hit effects in seconds.
Definition humanRenderUpdater.h:245
void updateHealthEffects()
Updates health-related visual effects.
makVrv::DtSceneObjectAgent * myFirstPersonSceneObjectAgent
Agent managing the first-person scene object.
Definition humanRenderUpdater.h:270
Table-based access to Lua state for configuration data.
Definition initializer.h:38
Base class for all role components in VR-Engage.
Definition playerComponent.h:78
virtual DtPlayerStation & player()
Gets the player station.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Provides coordinate conversion functionality between different coordinate systems.
constexpr const char * firstPersonModelMap
Definition humanRenderUpdater.h:60
constexpr const char * healthEffectOpacityMaximum
Definition humanRenderUpdater.h:69
constexpr const char * healthEffectHealthMinimum
Definition humanRenderUpdater.h:66
constexpr const char * healthEffectHealthMaximum
Definition humanRenderUpdater.h:63
constexpr const char * hitEffectDuration
Definition humanRenderUpdater.h:75
constexpr const char * hideFirstPersonModelWhileAiming
Definition humanRenderUpdater.h:72
Defines export macros for the Human Frontend library.
#define HUMAN_DLL
Definition export.h:19
Definition humanRenderUpdater.h:52
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
HumanPosture
Enumeration of human posture states.
Definition stateDefines.h:30
constexpr const char * DtHumanRenderUpdaterType
Type identifier constant for DtHumanRenderUpdater components.
Definition humanRenderUpdater.h:93
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Equipment
Enumeration of equipment types that can be held or used.
Definition stateDefines.h:55
Definition appLauncherComponent.h:28
Defines the DtPlayerComponent base class for VR-Engage role components.
Common enumeration definitions used throughout the VREngage system.
HitEffectInfo()
Default constructor.
Definition humanRenderUpdater.h:367
std::string effectName
The Post Processor name. Used to enable/disable the effect.
Definition humanRenderUpdater.h:373
HitEffectState hitEffectState
Current state of this hit effect.
Definition humanRenderUpdater.h:376
double timer
The timer to determine when the effect should be removed. This timer needs to be coordinated with any...
Definition humanRenderUpdater.h:374
Defines the base class for all VREngage messages.