VR-Engage  2.2
Loading...
Searching...
No Matches
centerOfViewTickable.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file centerOfViewTickable.h
7//! \brief Defines a tickable component that centers the view on an entity
8//!
9//! This file contains the DtCenterOfViewTickable class which provides functionality
10//! to keep the camera view centered on a specified entity. It periodically updates
11//! the view center point to follow the target entity's position.
12
13#pragma once
14
16
17#include <vrvCore/DtTickable.h>
18
19namespace makVrv
20{
21class DtSceneObjectAgent;
22class DtChannelManager;
23class DtChannel;
24} // namespace makVrv
25
26namespace makVre
27{
28//! \brief Tickable component that keeps the view centered on an entity
29//!
30//! DtCenterOfViewTickable is a component that updates the display channels
31//! to keep the view centered on a specified scene object (typically an entity).
32//! It inherits from DtTickable, allowing it to receive regular update calls
33//! from the display engine's main loop. This is useful for keeping the camera
34//! focused on a moving entity, such as the player's vehicle or avatar.
35class PLAYERSTATION_DLL DtCenterOfViewTickable : public makVrv::DtTickable
36{
37public:
38 //! \brief Constructor
39 //! \param de Reference to the display engine
40 //!
41 //! Creates a new center-of-view tickable component associated with the
42 //! specified display engine. The component starts without a target scene object.
43 DtCenterOfViewTickable(makVrv::DtDe& de);
44
45 //! \brief Virtual destructor
46 //!
47 //! Ensures proper cleanup of resources used by derived classes.
48 virtual ~DtCenterOfViewTickable() override;
49
50 //! \brief Updates the center of view
51 //! \param tNow Current simulation time
52 //!
53 //! Called by the tickable manager to update the view center. This method
54 //! updates the view to keep it centered on the target scene object.
55 //! If no scene object is set, this method does nothing.
56 virtual void update(DtTime tNow) override;
57
58 //! \brief Checks if an update is needed
59 //! \param tNow Current simulation time
60 //! \return True if an update should be performed, false otherwise
61 //!
62 //! Determines whether the view center needs to be updated at the current time.
63 //! This helps optimize performance by avoiding unnecessary updates.
64 virtual bool needsUpdate(DtTime tNow) override;
65
66 //! \brief Sets the target scene object
67 //! \param obj Pointer to the scene object to center on
68 //!
69 //! Sets the scene object that the view should be centered on. This can be
70 //! changed at any time to switch the focus to a different entity. Setting
71 //! this to NULL disables the centering functionality.
72 virtual void setSceneObject(makVrv::DtSceneObjectAgent* obj);
73
74protected:
75 //! \brief Performs the actual view update
76 //! \param mgr Pointer to the channel manager
77 //! \param channel Pointer to the channel being updated
78 //!
79 //! Internal method that performs the actual work of updating a specific
80 //! display channel to center on the target scene object. This method is
81 //! called for each relevant channel by the update method.
82 virtual void actualUpdate(makVrv::DtChannelManager* mgr, makVrv::DtChannel* channel);
83
84 //! \brief Time of the last update
85 //!
86 //! Stores the simulation time of the last performed update to control
87 //! update frequency and avoid redundant updates.
89
90 //! \brief Reference to the display engine
91 //!
92 //! Provides access to channels, scene objects, and other display resources.
93 makVrv::DtDe& myDe;
94
95 //! \brief Target scene object to center on
96 //!
97 //! The scene object that the view should be centered on. May be NULL if
98 //! no centering is currently desired.
99 makVrv::DtSceneObjectAgent* mySceneObject;
100};
101} // namespace makVre
virtual ~DtCenterOfViewTickable() override
Virtual destructor.
makVrv::DtDe & myDe
Reference to the display engine.
Definition centerOfViewTickable.h:93
DtCenterOfViewTickable(makVrv::DtDe &de)
Constructor.
DtTime myLastUpdatedTime
Time of the last update.
Definition centerOfViewTickable.h:88
makVrv::DtSceneObjectAgent * mySceneObject
Target scene object to center on.
Definition centerOfViewTickable.h:99
virtual void update(DtTime tNow) override
Updates the center of view.
virtual bool needsUpdate(DtTime tNow) override
Checks if an update is needed.
virtual void setSceneObject(makVrv::DtSceneObjectAgent *obj)
Sets the target scene object.
virtual void actualUpdate(makVrv::DtChannelManager *mgr, makVrv::DtChannel *channel)
Performs the actual view update.
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.