VR-Engage  2.2
Loading...
Searching...
No Matches
aimPointTickable.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file aimPointTickable.h
7//! \brief Defines a tickable component that manages aim point visualization
8//!
9//! This file contains the DtAimPointTickable class which provides functionality
10//! to visualize and update an aim point or targeting reticle for entities in the
11//! simulation. It periodically updates the aim point position and appearance
12//! based on the target entity's location and orientation.
13
14#pragma once
15
17
18#include "vreUtil/attribute.h"
19
20#include <vrvCore/DtTickable.h>
21
22namespace makVrv
23{
24class DtSceneObjectAgent;
25class DtChannelManager;
26class DtChannel;
27} // namespace makVrv
28
29namespace makVre
30{
31//! \brief Tickable component that manages aim point visualization
32//!
33//! DtAimPointTickable is a component that updates the visualization of an aim point
34//! or targeting reticle associated with a specified scene object (typically a weapon
35//! or targeting system). It inherits from DtTickable, allowing it to receive regular
36//! update calls from the display engine's main loop. This is used to provide visual
37//! feedback for aiming and targeting in the simulation.
38class PLAYERSTATION_DLL DtAimPointTickable : public makVrv::DtTickable
39{
40public:
41 //! \brief Orientation options for the aim point
42 //!
43 //! Defines how the aim point should be oriented in the 3D scene.
45 {
46 UP, //!< Aim point is oriented upward regardless of view direction
47 TOWARD_OBSERVER //!< Aim point is oriented to face the observer/camera
48 };
49
50 //! \brief Screen scaling options for the aim point
51 //!
52 //! Defines how the aim point size should be adjusted relative to the screen.
54 {
55 SCALED, //!< Aim point size scales with distance (appears smaller at greater distances)
56 CONSTANT //!< Aim point size remains constant regardless of distance
57 };
58
59 //! \brief Constructor
60 //! \param de Reference to the display engine
61 //! \param state Reference to the attribute handle for state tracking
62 //! \param ori Orientation option for the aim point
63 //! \param screenScale Scaling option for the aim point
64 //!
65 //! Creates a new aim point tickable component associated with the specified
66 //! display engine and attribute state. The orientation and screen scaling
67 //! options control the appearance of the aim point.
69 makVrv::DtDe& de, DtAttributeHandle& state, Orientation ori = UP, ScreenScale screenScale = SCALED);
70
71 //! \brief Virtual destructor
72 //!
73 //! Ensures proper cleanup of resources used by derived classes.
74 virtual ~DtAimPointTickable() override;
75
76 //! \brief Updates the aim point
77 //! \param tNow Current simulation time
78 //!
79 //! Called by the tickable manager to update the aim point visualization.
80 //! This method updates the aim point's position, orientation, and appearance
81 //! based on the target scene object's current state. If no scene object is set,
82 //! this method does nothing.
83 virtual void update(DtTime tNow) override;
84
85 //! \brief Checks if an update is needed
86 //! \param tNow Current simulation time
87 //! \return True if an update should be performed, false otherwise
88 //!
89 //! Determines whether the aim point needs to be updated at the current time.
90 //! This helps optimize performance by avoiding unnecessary updates.
91 virtual bool needsUpdate(DtTime tNow) override;
92
93 //! \brief Sets the target scene object
94 //! \param obj Pointer to the scene object to associate with the aim point
95 //!
96 //! Sets the scene object that the aim point should be associated with. This can be
97 //! changed at any time to switch the aim point to a different entity. Setting
98 //! this to NULL disables the aim point visualization.
99 virtual void setSceneObject(makVrv::DtSceneObjectAgent* obj);
100
101protected:
102 //! \brief Performs the actual aim point update
103 //!
104 //! Internal method that performs the actual work of updating the aim point
105 //! visualization based on the current state of the target scene object.
106 //! This handles positioning, orientation, and scaling of the aim point.
107 virtual void actualUpdate();
108
109 //! \brief Time of the last update
111
112 //! \brief Reference to the attribute handle for state tracking
114
115 //! \brief Reference to the display engine
116 makVrv::DtDe& myDe;
117
118 //! \brief Target scene object to associate with the aim point
119 makVrv::DtSceneObjectAgent* mySceneObject;
120
121 //! \brief Current screen scaling option
123
124 //! \brief Current orientation option
126
127 //! \brief Flag indicating whether model depth has been initialized
129
130 //! \brief Flag indicating whether scaling has been initialized
132};
133} // namespace makVre
Provides attribute handling system for hierarchical data storage and manipulation.
virtual void actualUpdate()
Performs the actual aim point update.
DtAimPointTickable(makVrv::DtDe &de, DtAttributeHandle &state, Orientation ori=UP, ScreenScale screenScale=SCALED)
Constructor.
virtual void update(DtTime tNow) override
Updates the aim point.
ScreenScale myScreenScale
Current screen scaling option.
Definition aimPointTickable.h:122
bool myInitializedScaling
Flag indicating whether scaling has been initialized.
Definition aimPointTickable.h:131
makVrv::DtDe & myDe
Reference to the display engine.
Definition aimPointTickable.h:116
Orientation myOrientation
Current orientation option.
Definition aimPointTickable.h:125
virtual ~DtAimPointTickable() override
Virtual destructor.
makVrv::DtSceneObjectAgent * mySceneObject
Target scene object to associate with the aim point.
Definition aimPointTickable.h:119
virtual bool needsUpdate(DtTime tNow) override
Checks if an update is needed.
ScreenScale
Screen scaling options for the aim point.
Definition aimPointTickable.h:54
@ CONSTANT
Aim point size remains constant regardless of distance.
Definition aimPointTickable.h:56
@ SCALED
Aim point size scales with distance (appears smaller at greater distances)
Definition aimPointTickable.h:55
bool myInitModelDepth
Flag indicating whether model depth has been initialized.
Definition aimPointTickable.h:128
virtual void setSceneObject(makVrv::DtSceneObjectAgent *obj)
Sets the target scene object.
DtAttributeHandle myState
Reference to the attribute handle for state tracking.
Definition aimPointTickable.h:113
DtTime myLastUpdatedTime
Time of the last update.
Definition aimPointTickable.h:110
Orientation
Orientation options for the aim point.
Definition aimPointTickable.h:45
@ UP
Aim point is oriented upward regardless of view direction.
Definition aimPointTickable.h:46
@ TOWARD_OBSERVER
Aim point is oriented to face the observer/camera.
Definition aimPointTickable.h:47
Handle class for safe access to attributes.
Definition attributeHandle.h:30
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
Definition appLauncherComponent.h:28
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.