VR-Engage  2.2
Loading...
Searching...
No Matches
vreAimWeaponController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreAimWeaponController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for aiming weapons at target points
9//!
10//! This file defines the DtVreAimWeaponController class which is responsible for
11//! controlling the aiming of weapons at specified target points. It supports both
12//! AI-controlled and player-controlled aiming behaviors, with special handling for
13//! VR controller input.
14
15#pragma once
16
17#include "vreVrfmodel/export.h"
19#include <vrfModel/aimWeaponController.h>
20
21namespace makVrf
22{
23class DtArticulatedPartStateRepository;
24}
25
26namespace makVre
27{
28
29//! \brief Type identifier for the VRE aim weapon controller component
30const char DtVreAimWeaponControllerType[] = "vre-aim-weapon-controller";
31
32//! \brief Controller for aiming weapons at target points
33//!
34//! DtVreAimWeaponController is responsible for controlling the aiming of a weapon
35//! at a specified target point. It manages the articulated parts of the weapon
36//! to ensure proper orientation toward the target. This controller supports both
37//! AI-controlled and player-controlled aiming, with special handling for VR input.
38//! It also provides functionality for aiming the entity itself when it doesn't
39//! have a specific weapon to aim.
40//!
41//! Uses Descriptor Type: DtAimWeaponControllerDescriptor
42class VREVRFMODEL_DLL DtVreAimWeaponController : public DtVreSimComponent<DtAimWeaponController>
43{
44public:
45 //! \brief Constructor
46 //! \param name The name of this component
47 //! \param owner The local object that owns this component
48 //! \param simManager The simulation services manager
49 //! \param desc Component descriptor with configuration parameters
50 //! \param parentRegistry Optional parent registry for reader/writer functionality
51 //!
52 //! Creates a new aim weapon controller component with the specified parameters.
53 DtVreAimWeaponController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
54 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
55
56 //! \brief Virtual destructor
57 //!
58 //! Cleans up resources used by the aim weapon controller component.
59 virtual ~DtVreAimWeaponController() override;
60
61 //! \brief Gets the type identifier for this component
62 //! \return String identifying the component type (DtVreAimWeaponControllerType)
63 //!
64 //! Implements the DtSimComponent::type() method to return the
65 //! type identifier for this component.
66 virtual const char* type() const override { return DtVreAimWeaponControllerType; }
67
68 //! \brief Updates the weapon aiming each simulation frame
69 //!
70 //! Controls the aiming of the weapon toward its target point. If a player is
71 //! acting in the gunner role for this entity, the function returns immediately
72 //! to allow player control. Otherwise, it performs AI-controlled aiming with
73 //! additional handling for VR controller input. This override also allows aiming
74 //! the entity itself even when it doesn't have a dedicated weapon to aim.
75 //! Overridden for the following:
76 //! * Checks if player is acting in the gunner role for this entity. If so, returns immediately.
77 //! * Contains a fix for yaw aiming using VR controllers.
78 //! * Allow aiming the entity itself even if it does not have a weapon to aim.
79 virtual void tick() override;
80
81 //! \brief Factory method to create a new instance of this component
82 //! \param name The name for the new component
83 //! \param owner The local object that will own this component
84 //! \param simManager The simulation services manager
85 //! \param desc Optional component descriptor
86 //! \param parentRegistry Optional parent registry for reader/writer functionality
87 //! \return Pointer to the newly created component
88 //!
89 //! Static factory method used by the component creation system to instantiate
90 //! new instances of this component type.
91 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
92 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
93
94protected:
95 //! \brief Retrieves the articulated part state repository for the gun
96 //! \return Pointer to the articulated part state repository for the gun
97 //!
98 //! Gets the articulated part state repository that represents the gun part
99 //! that this controller is responsible for aiming. This method is used internally
100 //! to access the part for applying rotation and aiming adjustments.
101 virtual makVrf::DtArticulatedPartStateRepository* getGunPart();
102
103private:
104 //! \brief Default constructor (not implemented)
105 //!
106 //! Default constructor is private and not implemented to prevent
107 //! creation of instances without proper initialization.
109
110 //! \brief Copy constructor (not implemented)
111 //!
112 //! Copy constructor is private and not implemented to prevent
113 //! copy construction.
115
116 //! \brief Assignment operator (not implemented)
117 //! \return Reference to this object
118 //!
119 //! Assignment operator is private and not implemented to prevent assignment.
121
122protected:
123};
124
125} // namespace makVre
const DtVreAimWeaponController & operator=(const DtVreAimWeaponController &orig)
Assignment operator (not implemented)
virtual ~DtVreAimWeaponController() override
Virtual destructor.
virtual makVrf::DtArticulatedPartStateRepository * getGunPart()
Retrieves the articulated part state repository for the gun.
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Factory method to create a new instance of this component.
DtVreAimWeaponController()
Default constructor (not implemented)
virtual const char * type() const override
Gets the type identifier for this component.
Definition vreAimWeaponController.h:66
virtual void tick() override
Updates the weapon aiming each simulation frame.
DtVreAimWeaponController(const DtVreAimWeaponController &orig)
Copy constructor (not implemented)
DtVreAimWeaponController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
DtVreSimComponent(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Definition vreSimComponent.h:54
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const char DtVreAimWeaponControllerType[]
Type identifier for the VRE aim weapon controller component.
Definition vreAimWeaponController.h:30
Definition connectorAccessory.h:39
Base template class for VR-Engage simulation components.