VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtDriverControlLogic Class Reference

Detailed Description

The DtDriverControlLogic provides functionality for controlling various aspects of ground vehicles. This includes basic driving controls (steering, throttle, braking), transmission controls (gear shifting), and auxiliary systems (engine, differential lock, parking brake, headlights, and pivot steering).

It also maintains vehicle state information through attributes and handles resource updates for systems like fuel levels.

#include <driverControlLogic.h>

Inheritance diagram for makVre::DtDriverControlLogic:
[legend]

Public Member Functions

 DtDriverControlLogic ()
 
virtual ~DtDriverControlLogic () override
 
virtual bool initialize (makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
virtual void sendJoystickMessage (const std::string &function, double val, double delay=0)
 
virtual void steerLeft (float val)
 
virtual void steerRight (float val)
 
virtual void setSteering (double val)
 
virtual void setThrottle (double val)
 
virtual void setBrake (double val)
 
virtual void setGearUp (double val)
 
virtual void setGearDown (double val)
 
virtual void setEngineEnable (double val)
 
virtual void setDifferentialLock (double val)
 
virtual void setParkingBrake (double val)
 
virtual void setHeadlights (double val)
 
virtual void setPivot (double val)
 
- Public Member Functions inherited from makVre::DtEntityControlLogic
 DtEntityControlLogic ()
 
virtual ~DtEntityControlLogic () override
 
virtual bool postInitialize () override
 
virtual void setMouseControlEnabled (bool enabled)
 
virtual bool isMouseControlEnabled ()
 
virtual bool isMouseControlSupportAllowed () const
 
virtual void setMouseControlSupportAllowed (bool enable)
 
virtual const std::vector< std::string > & joystickGroups () const
 
virtual void sendJoystickCommand (const DtEntityIdentifier &id, const std::string &functionGroup, const std::string &function, double val, bool repeat=false)
 
virtual makVre::DtVreMessageResult handleSimState (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleReset (makVre::DtVreMessage *message)
 
virtual makVre::DtVreMessageResult handleCreationStatus (makVre::DtVreMessage *message)
 
virtual void reset (float val)
 
virtual void resetInPlace (float val)
 
virtual void toggleMouseControl (float val)
 
virtual void enableMouseControl (float val)
 
virtual makVre::DtVreMessageResult handleFocusMessage (makVre::DtVreMessage *message)
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
bool componentReady () const
 
void setComponentReady (bool ready)
 
virtual DtInitTickStatus finalizeInitTick (double dt)
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStation & player ()
 
virtual DtAttributeHandle & playerAttributeStore ()
 
virtual const DtAttributeHandle & playerAttributeStore () const
 
virtual const DtAttributeHandle & ownshipState () const
 
virtual void setExtendedData (const std::string &key, const std::string &value, DtEntityIdentifier entity=DtEntityIdentifier::nullId())
 

Protected Attributes

DtInputLogic myDriverInputLogic
 
std::string myMainJoystickGroup
 
bool myCanPivot
 
bool myHasDifferentialLock
 
bool myShowInclinometer
 
DtAttributeHandleType< double > myFuelAttr
 
DtAttributeHandleType< double > myFuelFullAmountAttr
 
DtAttributeHandleType< DtVector > myPositionAttr
 
DtAttributeHandleType< DtTaitBryan > myOrientationAttr
 
DtAttributeHandleType< DtVector > myLocalPositionAttr
 
DtAttributeHandleType< double > myYawAttr
 
DtAttributeHandleType< double > myPitchAttr
 
DtAttributeHandleType< double > myRollAttr
 
DtAttributeHandleType< DtTaitBryan > myLocalOrientationAttr
 
- Protected Attributes inherited from makVre::DtEntityControlLogic
std::vector< std::string > myJoystickFunctionGroups
 
DtInputLogic myCommonInputLogic
 
std::string myInputConfigFile
 
bool myMouseControlEnabled
 
bool myMouseControlSupportAllowed
 
DtAttributeHandle myOwnshipAttr
 
DtAttributeHandleType< bool > myEmbarkedAttr
 
DtAttributeHandleType< DtEntityIdentifier > myEmbarkedHostAttr
 
DtAttributeHandleType< DtEntityType > myEmbarkedHostTypeAttr
 
DtAttributeHandleType< std::string > myEmbarkedHostMarkingAttr
 
DtAttributeHandleType< bool > myEmbarkedOnAircraftAttr
 
DtAttributeHandleType< std::string > myEmbarkedInSlotAttr
 
DtAttributeHandleType< unsigned int > myAppearanceAttr
 
DtAttributeHandleType< DtVector > myPositionAttr
 
DtAttributeHandleType< DtTaitBryan > myOrientationAttr
 
DtAttributeHandleType< double > mySpeedAttr
 
DtAttributeHandleType< DtVector32 > myVelocityAttr
 
DtAttributeHandleType< DtVector32 > myAccelerationAttr
 
DtAttributeHandleType< DtVector32 > myRotVelAttr
 
DtAttributeHandleType< DtEntityType > myEntityTypeAttr
 
DtAttributeHandleType< DtVector32 > myRelativeVelocityAttr
 
DtAttributeHandleType< DtDamageState > myDamageStateAttr
 
DtAttributeHandleType< int > mySimStateUpdateIndexAttr
 
DtAttributeHandleType< bool > myHideOccupantsAttr
 
- Protected Attributes inherited from makVre::DtPlayerComponent
bool myComponentReady = true
 
std::string myName
 
DtInitTable myConfig
 
DtPlayerStation * myPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolver * myResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 
DtVreMessageHandlerGroup myMessageHandlers
 

Additional Inherited Members

- Protected Member Functions inherited from makVre::DtEntityControlLogic
bool requiresControl () const
 
bool isAirborne () const
 
void showNotification (const QString &text, double duration)
 
virtual void takeControlOfPlayerEntity ()
 
virtual void releaseControlOfPlayerEntity ()
 
- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Constructor & Destructor Documentation

◆ DtDriverControlLogic()

makVre::DtDriverControlLogic::DtDriverControlLogic ( )

Constructor for DtDriverControlLogic.

Initializes the component with default values and checks out the required VR Engage Ground license.

◆ ~DtDriverControlLogic()

virtual makVre::DtDriverControlLogic::~DtDriverControlLogic ( )
overridevirtual

Virtual destructor for DtDriverControlLogic.

Member Function Documentation

◆ initialize()

virtual bool makVre::DtDriverControlLogic::initialize ( makVre::DtPlayerStation * player,
makVre::DtInitTable & config )
overridevirtual

Initializes the component with configuration from Lua.

Sets up input handlers, initializes state attributes, and subscribes to resource updates. Configures vehicle capabilities based on Lua settings (differential lock and pivot steering).

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing initialization parameters
Returns
True if initialization succeeds, false otherwise

Reimplemented from makVre::DtEntityControlLogic.

References makVre::DtPlayerComponent::player().

◆ tick()

virtual void makVre::DtDriverControlLogic::tick ( double dt)
overridevirtual

Updates the component state.

Updates the headlight state attribute based on the vehicle's current appearance.

Parameters
dtDelta time in seconds since the last tick

Reimplemented from makVre::DtEntityControlLogic.

◆ shutdown()

virtual void makVre::DtDriverControlLogic::shutdown ( )
overridevirtual

Shuts down the component.

Unsubscribes from resource updates, removes callbacks, and cleans up input handlers.

Reimplemented from makVre::DtEntityControlLogic.

◆ type()

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

Returns the component type identifier.

Returns
The component type string

Reimplemented from makVre::DtEntityControlLogic.

◆ steerLeft()

virtual void makVre::DtDriverControlLogic::steerLeft ( float val)
virtual

Input handler functions.

Handles left steering input

Inverts the value and passes it to setSteering().

Parameters
valThe input value, typically from 0.0 to 1.0

◆ steerRight()

virtual void makVre::DtDriverControlLogic::steerRight ( float val)
virtual

Handles right steering input.

Passes the value directly to setSteering().

Parameters
valThe input value, typically from 0.0 to 1.0

◆ setSteering()

virtual void makVre::DtDriverControlLogic::setSteering ( double val)
virtual

Sets the vehicle's steering value.

Sends a "Steering" joystick message with the provided value.

Parameters
valThe steering value, from -1.0 (full left) to 1.0 (full right)

◆ setThrottle()

virtual void makVre::DtDriverControlLogic::setThrottle ( double val)
virtual

Sets the vehicle's throttle value.

Sends a "Throttle" joystick message with the provided value.

Parameters
valThe throttle value, typically from 0.0 to 1.0

◆ setBrake()

virtual void makVre::DtDriverControlLogic::setBrake ( double val)
virtual

Sets the vehicle's brake value.

Sends a "Brake" joystick message with the provided value.

Parameters
valThe brake value, typically from 0.0 to 1.0

◆ setGearUp()

virtual void makVre::DtDriverControlLogic::setGearUp ( double val)
virtual

Shifts up to the next gear.

Sends a "GearUp" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 triggers the gear shift

◆ setGearDown()

virtual void makVre::DtDriverControlLogic::setGearDown ( double val)
virtual

Shifts down to the previous gear.

Sends a "GearDown" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 triggers the gear shift

◆ setEngineEnable()

virtual void makVre::DtDriverControlLogic::setEngineEnable ( double val)
virtual

Toggles the engine on/off.

Sends an "EngineEnable" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 typically toggles the engine state

◆ setDifferentialLock()

virtual void makVre::DtDriverControlLogic::setDifferentialLock ( double val)
virtual

Toggles the differential lock.

Sends a "DifferentialLock" joystick message with the provided value. Only applies to vehicles with differential lock capability.

Parameters
valThe input value, a value of 1.0 typically toggles the differential lock

◆ setParkingBrake()

virtual void makVre::DtDriverControlLogic::setParkingBrake ( double val)
virtual

Toggles the parking brake.

Sends a "ParkingBrake" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 typically toggles the parking brake

◆ setHeadlights()

virtual void makVre::DtDriverControlLogic::setHeadlights ( double val)
virtual

Toggles the headlights.

Sends a "Headlights" joystick message with the provided value.

Parameters
valThe input value, a value of 1.0 typically toggles the headlights

◆ setPivot()

virtual void makVre::DtDriverControlLogic::setPivot ( double val)
virtual

Controls pivot steering.

Sends a "Pivot" joystick message with the provided value. Only applies to vehicles with pivot steering capability.

Parameters
valThe input value

◆ sendJoystickMessage()

virtual void makVre::DtDriverControlLogic::sendJoystickMessage ( const std::string & function,
double val,
double delay = 0 )
virtual

Sends a joystick message to the simulation.

Helper function called by the various control functions to send joystick messages with the appropriate parameters.

Parameters
functionThe function name to include in the message
valThe function value to include in the message
delayOptional delay before sending the message (defaults to 0)

Member Data Documentation

◆ myDriverInputLogic

DtInputLogic makVre::DtDriverControlLogic::myDriverInputLogic
protected

Input handler logic for processing input device events.

◆ myMainJoystickGroup

std::string makVre::DtDriverControlLogic::myMainJoystickGroup
protected

Main joystick function group name from configuration.

Used to identify the function group when sending joystick messages.

◆ myCanPivot

bool makVre::DtDriverControlLogic::myCanPivot
protected

Flag indicating if this vehicle is capable of pivot steering.

When true, enables pivot steering functionality. This value is stored in the "canPivot" state attribute. Defaults to false.

◆ myHasDifferentialLock

bool makVre::DtDriverControlLogic::myHasDifferentialLock
protected

Flag indicating if this vehicle has a differential lock.

When true, enables differential lock functionality. This value is stored in the "hasDifferentialLock" state attribute. Defaults to false.

◆ myShowInclinometer

bool makVre::DtDriverControlLogic::myShowInclinometer
protected

◆ myFuelAttr

DtAttributeHandleType<double> makVre::DtDriverControlLogic::myFuelAttr
protected

Attribute handle storing the current fuel amount.

Attribute Store Keyfuel

◆ myFuelFullAmountAttr

DtAttributeHandleType<double> makVre::DtDriverControlLogic::myFuelFullAmountAttr
protected

Attribute handle storing the full-tank fuel capacity.

Attribute Store KeyfuelFullAmount

◆ myPositionAttr

DtAttributeHandleType<DtVector> makVre::DtDriverControlLogic::myPositionAttr
protected
Attribute Store Keyownship.position

◆ myOrientationAttr

DtAttributeHandleType<DtTaitBryan> makVre::DtDriverControlLogic::myOrientationAttr
protected
Attribute Store Keyownship.orientation

◆ myLocalPositionAttr

DtAttributeHandleType<DtVector> makVre::DtDriverControlLogic::myLocalPositionAttr
protected
Attribute Store Keyownship.localPosition

◆ myYawAttr

DtAttributeHandleType<double> makVre::DtDriverControlLogic::myYawAttr
protected
Attribute Store Keyownship.yaw

◆ myPitchAttr

DtAttributeHandleType<double> makVre::DtDriverControlLogic::myPitchAttr
protected
Attribute Store Keyownship.pitch

◆ myRollAttr

DtAttributeHandleType<double> makVre::DtDriverControlLogic::myRollAttr
protected
Attribute Store Keyownship.roll

◆ myLocalOrientationAttr

DtAttributeHandleType<DtTaitBryan> makVre::DtDriverControlLogic::myLocalOrientationAttr
protected
Attribute Store Keyownship.localOrientation

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