VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtHumanGunJoyActuator Class Reference

Detailed Description

DtHumanGunJoyActuator provides a model of a handheld gun/weapon that can be controlled via joystick inputs.

Component Type: human-gun-Joystick-actuator

Descriptor Class: DtHumanGunActuatorDescriptor, Type: vre-human-gun-actuator-descriptor

#include <humanGunJoyActuator.h>

Inheritance diagram for makVre::DtHumanGunJoyActuator:
[legend]

Classes

struct  DtFireResult
 

Public Member Functions

 DtHumanGunJoyActuator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 
virtual ~DtHumanGunJoyActuator () override
 
virtual bool init () override
 
virtual const char * type () const override
 
virtual void tick () override
 
- Public Member Functions inherited from makVre::DtVreSimComponent< DtBallisticGunJoy >
 DtVreSimComponent (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 
virtual ~DtVreSimComponent ()
 
bool isPlayerControlled (const std::string &role="") const
 
DtString entitySystemName () const
 
- Public Member Functions inherited from makVre::DtBallisticGunJoy
 DtBallisticGunJoy (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *const parentRegistry=0)
 
virtual ~DtBallisticGunJoy () override
 
virtual void setComponentDescriptor (DtComponentDescriptor *descriptor) override
 
virtual DtReal setTarget (makVrf::DtArticulatedPartStateRepository *rotBody)
 
virtual makVrfEvents::DtFireEvent * manualFireInteraction (makVrf::DtArticulatedPartStateRepository *rotBody)
 
virtual makVrfEvents::DtDetonationEvent * manualDetonationInteraction (makVrf::DtArticulatedPartStateRepository *rotBody, DtReal &detTime, DtReal dist)
 
virtual DtUUID targetSelection (makVrf::DtArticulatedPartStateRepository *rotBody, DtReal &dist)
 
virtual DtReal distanceToTarget ()
 

Static Public Member Functions

static DtSimComponent * creator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 
- Static Public Member Functions inherited from makVre::DtBallisticGunJoy
static void detonationCallback (DtTimer *timer)
 
static DtSimComponent * creator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 

Protected Member Functions

virtual bool createPSR () override
 
virtual makVre::DtVreMessageResult handleFireInput (makVre::DtVreMessage *msg)
 
virtual bool aimGunElevation ()
 
virtual bool createPorts () override
 
virtual bool aimGun () override
 
virtual void getFireResult (const DtVector &shooterPosition, const DtTaitBryan shooterOrienation, DtFireResult &fireResult)
 
virtual makVrfEvents::DtFireEvent * createFireInteraction (const DtVector &firingPosition, const DtTaitBryan firingOrientation)
 
virtual makVrfEvents::DtDetonationEvent * createDetonationInteraction (const DtVector &firingPosition, const DtTaitBryan firingOrientation, const DtFireResult &fireResult, DtReal &detTime)
 
virtual void depleteResource (int amount=1)
 
virtual void setRestored ()
 
virtual bool allowWeaponFiring ()
 
virtual makVre::DtVreMessageResult fire ()
 
virtual DtTaitBryan recoilEffect (DtVector worldShooterPosition, DtTaitBryan worldShooterOrientation)
 
 DtHumanGunJoyActuator ()
 
 DtHumanGunJoyActuator (const DtHumanGunJoyActuator &orig)
 
const DtHumanGunJoyActuatoroperator= (const DtHumanGunJoyActuator &orig)
 

Protected Attributes

DtVreHumanGunActuatorDescriptormyHumanGunDescriptor
 
DtRwInt * myFirepowerHealth
 
int myBurstRoundsRemaining
 
DtEntityType myTriggerMunition
 
DtVector myTriggerWorldPosition
 
DtTaitBryan myTriggerWorldOrientation
 
DtHumanLocalObjectFacade myHumanLocalObjectFacade
 
bool myPlayerControlled
 
DtVreMunitionLoadermyVreMunitionLoader
 
Ports and Port Groups
DtAnalogInputPort * myAimAzimuthInputPort
 
- Protected Attributes inherited from makVre::DtBallisticGunJoy
bool myReportedNoArticulation
 
DtConstrainedAnalogInputPort * myElevationPort
 
DtBooleanInputPort * myActiveJoystickPort
 

Constructor & Destructor Documentation

◆ DtHumanGunJoyActuator() [1/3]

makVre::DtHumanGunJoyActuator::DtHumanGunJoyActuator ( const DtString & name,
DtLocalObject * owner,
DtSimulationServices * simManager,
DtComponentDescriptor * desc = 0,
DtReaderWriterRegistry * parentRegistry = 0 )

Constructor.

Parameters
nameThe name of this component
ownerThe local object that owns this component
simManagerThe simulation services manager
descComponent descriptor with configuration parameters
parentRegistryOptional parent registry for reader/writer functionality

Creates a new human gun joystick actuator component with the specified parameters.

Referenced by DtHumanGunJoyActuator(), and operator=().

◆ ~DtHumanGunJoyActuator()

virtual makVre::DtHumanGunJoyActuator::~DtHumanGunJoyActuator ( )
overridevirtual

Virtual destructor.

Cleans up resources used by the human gun joystick actuator component.

◆ DtHumanGunJoyActuator() [2/3]

makVre::DtHumanGunJoyActuator::DtHumanGunJoyActuator ( )
protected

Default constructor (not implemented)

Default constructor is private and not implemented to prevent creation of instances without proper initialization.

◆ DtHumanGunJoyActuator() [3/3]

makVre::DtHumanGunJoyActuator::DtHumanGunJoyActuator ( const DtHumanGunJoyActuator & orig)
protected

Copy constructor (not implemented)

Copy constructor is private and not implemented to prevent copy construction.

References DtHumanGunJoyActuator().

Member Function Documentation

◆ init()

virtual bool makVre::DtHumanGunJoyActuator::init ( )
overridevirtual

Initializes the component.

Returns
True if initialization is successful, false otherwise

Performs component initialization, setting up message handlers for fire input and initializing internal state for weapon operation.

◆ type()

virtual const char * makVre::DtHumanGunJoyActuator::type ( ) const
overridevirtual

Gets the type identifier for this component.

Returns
String identifying the component type (DtHumanGunJoyActuatorType)

Implements the DtSimComponent::type() method to return the type identifier for this component.

Reimplemented from makVre::DtBallisticGunJoy.

◆ tick()

virtual void makVre::DtHumanGunJoyActuator::tick ( )
overridevirtual

Updates the component state each simulation frame.

Checks for transitions to/from player control. Upon taking control as a player, disables thresholding of ammo counts (clip state properties) to ensure the most accurate information possible for display in the HUD. Upon leaving player control, restores thresholding of ammo counts to reduce network load for CGF entities that don't require the same degree of precision.

Reimplemented from makVre::DtBallisticGunJoy.

◆ creator()

static DtSimComponent * makVre::DtHumanGunJoyActuator::creator ( const DtString & name,
DtLocalObject * owner,
DtSimulationServices * simManager,
DtComponentDescriptor * desc = 0,
DtReaderWriterRegistry * parentRegistry = 0 )
static

Factory method to create a new instance of this component.

Parameters
nameThe name for the new component
ownerThe local object that will own this component
simManagerThe simulation services manager
descOptional component descriptor
parentRegistryOptional parent registry for reader/writer functionality
Returns
Pointer to the newly created component

Static factory method used by the component creation system to instantiate new instances of this component type.

◆ createPSR()

virtual bool makVre::DtHumanGunJoyActuator::createPSR ( )
overrideprotectedvirtual

Creates the process state repository for this component.

Returns
True if PSR was created successfully, false otherwise

Creates the process state repository for this component and adds it to the process state repository manager. Uses the name and type specified in the component descriptor if they exist, otherwise uses appropriate default strings defined in procSRTypes.h.

◆ handleFireInput()

virtual makVre::DtVreMessageResult makVre::DtHumanGunJoyActuator::handleFireInput ( makVre::DtVreMessage * msg)
protectedvirtual

Processes fire input messages.

Parameters
msgPointer to the fire input message
Returns
Message processing result

Handles FireInputMessage sent from role logic (human, tank, etc.) and updates myTriggerMunition, myTriggerWorldPosition, and myTriggerWorldOrientation parameters used for rapid fire in the tick function.

◆ aimGunElevation()

virtual bool makVre::DtHumanGunJoyActuator::aimGunElevation ( )
protectedvirtual

Aims the gun in elevation.

Returns
True if aiming in elevation is complete, false otherwise

Adjusts the gun's elevation based on input port values or pre-calculated values.

◆ createPorts()

virtual bool makVre::DtHumanGunJoyActuator::createPorts ( )
overrideprotectedvirtual

Creates input and output ports for this component.

Returns
True if ports were created successfully, false otherwise

Creates the required input and output ports for this component, particularly the azimuth aiming port specific to the human gun actuator.

Reimplemented from makVre::DtBallisticGunJoy.

◆ aimGun()

virtual bool makVre::DtHumanGunJoyActuator::aimGun ( )
overrideprotectedvirtual

Aims the gun based on input port values.

Returns
True if aiming is complete, false otherwise

Aims the gun based on input port values. Uses the myAimElevationInputPort to determine the correct elevation and the myAimAzimuthInputPort to determine the correct azimuth, combining them to aim the weapon appropriately.

◆ getFireResult()

virtual void makVre::DtHumanGunJoyActuator::getFireResult ( const DtVector & shooterPosition,
const DtTaitBryan shooterOrienation,
DtFireResult & fireResult )
protectedvirtual

Calculates the result of firing the weapon.

Parameters
shooterPositionThe position of the shooter in world coordinates
shooterOrienationThe orientation of the shooter in world coordinates
fireResultOutput parameter to store the fire result data

Performs the ballistic calculations to determine what happens when the weapon is fired from the given position and orientation.

◆ createFireInteraction()

virtual makVrfEvents::DtFireEvent * makVre::DtHumanGunJoyActuator::createFireInteraction ( const DtVector & firingPosition,
const DtTaitBryan firingOrientation )
protectedvirtual

Creates a fire event to send to the simulation.

Parameters
firingPositionThe position from which the weapon is fired
firingOrientationThe orientation of the weapon when fired
Returns
Pointer to the newly created fire event

Creates a fire event interaction based on the firing position and orientation, which will be sent to the simulation to notify other components about the firing.

◆ createDetonationInteraction()

virtual makVrfEvents::DtDetonationEvent * makVre::DtHumanGunJoyActuator::createDetonationInteraction ( const DtVector & firingPosition,
const DtTaitBryan firingOrientation,
const DtFireResult & fireResult,
DtReal & detTime )
protectedvirtual

Creates a detonation event to send to the simulation.

Parameters
firingPositionThe position from which the weapon was fired
firingOrientationThe orientation of the weapon when fired
fireResultResult data from the fire calculation
detTimeOutput parameter to store the detonation time
Returns
Pointer to the newly created detonation event

Creates a detonation event interaction based on the firing position, orientation, and fire result data. This event notifies other components about the impact of the projectile.

◆ depleteResource()

virtual void makVre::DtHumanGunJoyActuator::depleteResource ( int amount = 1)
protectedvirtual

Reduces ammunition count after firing.

Parameters
amountNumber of ammunition units to deplete (default: 1)

Reduces the ammunition count in the current magazine by the specified amount, reflecting the consumption of ammunition when firing the weapon.

◆ setRestored()

virtual void makVre::DtHumanGunJoyActuator::setRestored ( )
protectedvirtual

Re-initializes pointers after a restore operation.

Re-assigns pointers to extended state data since the pointers could have become invalid during a save/restore operation.

◆ allowWeaponFiring()

virtual bool makVre::DtHumanGunJoyActuator::allowWeaponFiring ( )
protectedvirtual

Checks if the weapon is allowed to fire.

Returns
True if the weapon can fire, false otherwise

Determines whether the weapon is currently allowed to fire based on ammunition availability, weapon state, and other conditions.

◆ fire()

virtual makVre::DtVreMessageResult makVre::DtHumanGunJoyActuator::fire ( )
protectedvirtual

Initiates the weapon firing sequence.

Returns
Message processing result

Creates and sends a fire interaction event, representing the firing of the weapon. This method is used only by VR Engage controlled entities.

◆ recoilEffect()

virtual DtTaitBryan makVre::DtHumanGunJoyActuator::recoilEffect ( DtVector worldShooterPosition,
DtTaitBryan worldShooterOrientation )
protectedvirtual

Calculates weapon recoil effects.

Parameters
worldShooterPositionThe position of the shooter in world coordinates
worldShooterOrientationThe orientation of the shooter in world coordinates
Returns
Modified orientation accounting for recoil

Creates a hit offset to simulate weapon recoil. The offset increases with the number of rounds fired in rapid succession, simulating the cumulative effect of recoil on accuracy.

◆ operator=()

const DtHumanGunJoyActuator & makVre::DtHumanGunJoyActuator::operator= ( const DtHumanGunJoyActuator & orig)
protected

Assignment operator (not implemented)

Returns
Reference to this object

Assignment operator is private and not implemented to prevent assignment.

References DtHumanGunJoyActuator().

Member Data Documentation

◆ myHumanGunDescriptor

DtVreHumanGunActuatorDescriptor* makVre::DtHumanGunJoyActuator::myHumanGunDescriptor
protected

Pointer to the human gun actuator descriptor.

Contains configuration parameters for this human gun actuator component.

◆ myAimAzimuthInputPort

DtAnalogInputPort* makVre::DtHumanGunJoyActuator::myAimAzimuthInputPort
protected

Input port for controlling weapon azimuth aim.

Receives the azimuth at which to aim the weapon, in radians. Range: -pi to pi, with default value of 0.

◆ myFirepowerHealth

DtRwInt* makVre::DtHumanGunJoyActuator::myFirepowerHealth
protected

Pointer to the firepower health state value.

Tracks the health/damage state of the weapon's firing capability.

◆ myBurstRoundsRemaining

int makVre::DtHumanGunJoyActuator::myBurstRoundsRemaining
protected

Number of rounds remaining in current burst.

Tracks how many more rounds can be fired in the current burst firing sequence.

◆ myTriggerMunition

DtEntityType makVre::DtHumanGunJoyActuator::myTriggerMunition
protected

Type of munition selected for firing.

Stores the munition type received from FireInputMessage to use for subsequent firing operations.

◆ myTriggerWorldPosition

DtVector makVre::DtHumanGunJoyActuator::myTriggerWorldPosition
protected

World position for weapon firing.

Stores the location of the first burst fire received from FireInputMessage, used for subsequent rounds in a burst sequence.

◆ myTriggerWorldOrientation

DtTaitBryan makVre::DtHumanGunJoyActuator::myTriggerWorldOrientation
protected

World orientation for weapon firing.

Stores the orientation of the first burst fire received from FireInputMessage, used for subsequent rounds in a burst sequence.

◆ myHumanLocalObjectFacade

DtHumanLocalObjectFacade makVre::DtHumanGunJoyActuator::myHumanLocalObjectFacade
protected

Facade for human local object access.

Provides simplified access to human-specific functionality of the local object.

◆ myPlayerControlled

bool makVre::DtHumanGunJoyActuator::myPlayerControlled
protected

Flag indicating if this entity is currently player-controlled.

Tracks whether the entity is currently under player control, which affects how ammunition state is reported and other behaviors.

◆ myVreMunitionLoader

DtVreMunitionLoader* makVre::DtHumanGunJoyActuator::myVreMunitionLoader
protected

Pointer to the munition loader component.

Convenience pointer to the munition loader component, which must be of type DtVreMunitionLoader. Used to manage ammunition loading and state.


The documentation for this class was generated from the following file: