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

Detailed Description

DtVrePlayerLaserController provides an interface for VR-Engage players to control a laser designator. It handles messages from the front-end to activate, deactivate, and update the laser's target. The controller sets appropriate output ports that can be connected to a DtLasingController to actually create the laser designation object in the simulation.

#include <vrePlayerLaserController.h>

Inheritance diagram for makVre::DtVrePlayerLaserController:
[legend]

Public Member Functions

 DtVrePlayerLaserController (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 
virtual ~DtVrePlayerLaserController () override
 
virtual const char * type () const override
 
virtual void preFirstTickInit () override
 
virtual void tick () override
 
virtual bool init () override
 
- Public Member Functions inherited from makVre::DtVreSimComponent< DtControllerComponent >
 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
 

Static Public Member Functions

static DtSimComponent * creator (const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
 
static void setRestoreCallback (DtSimMessage *msg, void *usrData)
 
static void setLaserCodeRequestCallback (DtSimMessage *msg, void *usrData)
 

Protected Member Functions

virtual makVre::DtVreMessageResult handleStartLasing (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleStopLasing (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleUpdateLasingState (makVre::DtVreMessage *msg)
 
virtual void processSetRestore (DtSimMessage *msg)
 
virtual void processSetLaserCodeRequestMessage (DtSimMessage *msg)
 
virtual bool createPorts () override
 
void getProcessSR ()
 

Protected Attributes

DtLasingPSR * myProcessState
 
bool myPlayerIsLasing
 
bool myLasingTargetLastTick
 
DtBooleanOutputPort * myLaserOnOutputPort
 
DtVectorOutputPort * myTargetLocationOutputPort
 
DtStringOutputPort * myTargetObjectOutputPort
 

Private Member Functions

 DtVrePlayerLaserController ()
 
 DtVrePlayerLaserController (const DtVrePlayerLaserController &orig)
 
const DtVrePlayerLaserControlleroperator= (const DtVrePlayerLaserController &orig)
 

Constructor & Destructor Documentation

◆ DtVrePlayerLaserController() [1/3]

makVre::DtVrePlayerLaserController::DtVrePlayerLaserController ( )
private

Default constructor (not implemented)

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

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

◆ DtVrePlayerLaserController() [2/3]

makVre::DtVrePlayerLaserController::DtVrePlayerLaserController ( const DtVrePlayerLaserController & orig)
private

Copy constructor (not implemented)

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

References DtVrePlayerLaserController().

◆ DtVrePlayerLaserController() [3/3]

makVre::DtVrePlayerLaserController::DtVrePlayerLaserController ( 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 player laser controller component with the specified parameters.

◆ ~DtVrePlayerLaserController()

virtual makVre::DtVrePlayerLaserController::~DtVrePlayerLaserController ( )
overridevirtual

Virtual destructor.

Cleans up resources used by the player laser controller component.

Member Function Documentation

◆ operator=()

const DtVrePlayerLaserController & makVre::DtVrePlayerLaserController::operator= ( const DtVrePlayerLaserController & orig)
private

Assignment operator (not implemented)

Returns
Reference to this object

Assignment operator is private and not implemented to prevent assignment.

References DtVrePlayerLaserController().

◆ type()

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

Gets the type identifier for this component.

Returns
String identifying the component type (DtVrePlayerLaserControllerType)

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

◆ preFirstTickInit()

virtual void makVre::DtVrePlayerLaserController::preFirstTickInit ( )
overridevirtual

Performs initialization before the first simulation tick.

Gets initial laser designator code from the Process State Repository (PSR) and copies it to the state property "laserCode". This ensures that the GUI displays the correct laser code when the simulation starts.

◆ tick()

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

Updates the controller state each simulation frame.

Processes laser controller logic each simulation frame, updating output ports based on the current lasing state and target information.

◆ init()

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

Initializes the player laser controller.

Returns
True if initialization is successful, false otherwise

Sets the state property named "HasLaser" to True. This property is defined in the platform sysdef file under state-data and is used by the VR-Engage menu system to determine whether to show laser designation options in the user interface. Also creates necessary ports and registers message callbacks.

◆ creator()

static DtSimComponent * makVre::DtVrePlayerLaserController::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.

◆ setRestoreCallback()

static void makVre::DtVrePlayerLaserController::setRestoreCallback ( DtSimMessage * msg,
void * usrData )
static

Callback for entity restoration events.

Parameters
msgThe message containing restoration information
usrDataUser data pointer, typically pointing to the instance of this class

Static callback function invoked when an entity is restored. This function forwards the message to the instance's processSetRestore method to reinitialize state properties.

◆ setLaserCodeRequestCallback()

static void makVre::DtVrePlayerLaserController::setLaserCodeRequestCallback ( DtSimMessage * msg,
void * usrData )
static

Callback for laser code change requests.

Parameters
msgThe message containing the new laser code
usrDataUser data pointer, typically pointing to the instance of this class

Static callback function invoked when a request to change the laser code is received. This function forwards the message to the instance's processSetLaserCodeRequestMessage method.

◆ handleStartLasing()

virtual makVre::DtVreMessageResult makVre::DtVrePlayerLaserController::handleStartLasing ( makVre::DtVreMessage * msg)
protectedvirtual

Handles messages to start lasing.

Parameters
msgThe message containing lasing start request
Returns
Message processing result indicating success or failure

Processes StartLasing messages from the front-end, which activate the laser designator. Sets the appropriate output ports to enable the laser in the simulation.

◆ handleStopLasing()

virtual makVre::DtVreMessageResult makVre::DtVrePlayerLaserController::handleStopLasing ( makVre::DtVreMessage * msg)
protectedvirtual

Handles messages to stop lasing.

Parameters
msgThe message containing lasing stop request
Returns
Message processing result indicating success or failure

Processes StopLasing messages from the front-end, which deactivate the laser designator. Sets the appropriate output ports to disable the laser in the simulation.

◆ handleUpdateLasingState()

virtual makVre::DtVreMessageResult makVre::DtVrePlayerLaserController::handleUpdateLasingState ( makVre::DtVreMessage * msg)
protectedvirtual

Handles messages to update the lasing state.

Parameters
msgThe message containing updated lasing information
Returns
Message processing result indicating success or failure

Processes UpdateLasingState messages from the front-end, which update the location being designated by the laser. Updates the appropriate output ports with the new target information.

◆ processSetRestore()

virtual void makVre::DtVrePlayerLaserController::processSetRestore ( DtSimMessage * msg)
protectedvirtual

Processes entity restoration messages.

Parameters
msgThe message containing restoration information

Reinitializes the state property "HasLaser" when a set restore operation is executed. This ensures that the entity's laser capabilities are properly restored after entity restoration, allowing the VR-Engage menu to correctly display laser options.

◆ processSetLaserCodeRequestMessage()

virtual void makVre::DtVrePlayerLaserController::processSetLaserCodeRequestMessage ( DtSimMessage * msg)
protectedvirtual

Processes laser code change requests.

Parameters
msgThe message containing the new laser code

Sets the state property for laser code based on the message contents, so the updated code can be reflected in the GUI. This allows users to change laser codes through the user interface, ensuring that laser-guided weapons are properly configured for the selected code.

◆ createPorts()

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

Creates input and output ports for the component.

Returns
True if ports are successfully created, false otherwise

Creates and initializes all the output ports needed by this component, including ports for laser state (on/off), target location, and target object. These ports connect to the actual laser controller component.

◆ getProcessSR()

void makVre::DtVrePlayerLaserController::getProcessSR ( )
protected

Retrieves the process state repository.

Gets the process state repository (PSR) for this component, storing it in the myProcessState member variable for later access. The PSR contains persistent state information for the controller.

Member Data Documentation

◆ myProcessState

DtLasingPSR* makVre::DtVrePlayerLaserController::myProcessState
protected

Pointer to the lasing process state repository.

Contains the persistent state information for the laser controller, including the laser code and target information.

◆ myPlayerIsLasing

bool makVre::DtVrePlayerLaserController::myPlayerIsLasing
protected

Flag indicating whether the player is currently lasing.

When true, indicates that the player has activated the laser designator and is currently designating a target.

◆ myLasingTargetLastTick

bool makVre::DtVrePlayerLaserController::myLasingTargetLastTick
protected

Flag indicating whether the player was lasing a target in the previous tick.

Used to track changes in lasing state between ticks, for determining when state transitions occur.

◆ myLaserOnOutputPort

DtBooleanOutputPort* makVre::DtVrePlayerLaserController::myLaserOnOutputPort
protected

Output port for the laser on/off state.

Boolean output port that controls whether the laser is active. When true, the laser is on and designating a target.

◆ myTargetLocationOutputPort

DtVectorOutputPort* makVre::DtVrePlayerLaserController::myTargetLocationOutputPort
protected

Output port for the laser target location.

Vector output port that specifies the 3D location being designated by the laser when targeting a location rather than an object.

◆ myTargetObjectOutputPort

DtStringOutputPort* makVre::DtVrePlayerLaserController::myTargetObjectOutputPort
protected

Output port for the laser target object.

String output port that specifies the unique identifier of an object being designated by the laser when targeting an object rather than a location.


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