|
VR-Engage
2.2
|
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, pivot steering, and towing hook).
It also maintains vehicle state information through attributes and handles resource updates for systems like fuel levels and towing targets.
#include <driverControlLogic.h>
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) |
| virtual void | setHook (double val) |
Public Member Functions inherited from makVre::DtEntityControlLogic | |
| DtEntityControlLogic () | |
| virtual | ~DtEntityControlLogic () override |
| virtual bool | postInitialize () override |
| virtual void | setExtendedData (const std::string &key, const std::string &value, DtEntityIdentifier entity=DtEntityIdentifier::nullId()) |
| 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 makVre::DtVreMessageResult | handleSimState (makVre::DtVreMessage *msg) |
| virtual makVre::DtVreMessageResult | handleStateMessages (makVre::DtVreMessage *message) |
| virtual makVre::DtVreMessageResult | handleReset (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 () |
| virtual void | setName (const std::string &name) |
| virtual const std::string & | name () |
| virtual DtPlayerStation & | player () |
| virtual DtAttributeHandle & | playerAttributeStore () |
| virtual const DtAttributeHandle & | playerAttributeStore () const |
Protected Member Functions | |
| virtual makVre::DtVreMessageResult | handleResourceUpdate (makVre::DtVreMessage *msg) |
| virtual void | onHookTargetUuidChanged (const std::string &hookTargetUuid) |
Protected Member Functions inherited from makVre::DtEntityControlLogic | |
| virtual void | takeControlOfPlayerEntity () |
| virtual void | releaseControlOfPlayerEntity () |
Protected Member Functions inherited from makVre::DtPlayerComponent | |
| virtual void | initializeStateAttributes () |
Protected Attributes | |
| std::string | myMarkingText |
| DtInputLogic | myDriverInputLogic |
| std::string | myMainJoystickGroup |
| bool | myCanPivot |
| bool | myHasDifferentialLock |
| bool | myHasTowHook |
| bool | myShowInclinometer |
Protected Attributes inherited from makVre::DtEntityControlLogic | |
| std::vector< std::string > | myJoystickFunctionGroups |
| DtInputLogic | myCommonInputLogic |
| std::string | myInputConfigFile |
| bool | myMouseControlEnabled |
| bool | myMouseControlSupportAllowed |
Protected Attributes inherited from makVre::DtPlayerComponent | |
| std::string | myName |
| DtInitTable | myConfig |
| DtPlayerStation * | myPlayer |
| makVrv::DtDe * | myDe |
| DtEntityResolver * | myResolver |
| DtAttributeCallbackManager | myAttributeCallbacks |
| makVre::DtDriverControlLogic::DtDriverControlLogic | ( | ) |
Constructor for DtDriverControlLogic.
Initializes the component with default values and checks out the required VR Engage Ground license.
|
overridevirtual |
Virtual destructor for DtDriverControlLogic.
|
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, pivot steering, and tow hook availability).
| player | Pointer to the player station this component belongs to |
| config | Configuration table containing initialization parameters |
Reimplemented from makVre::DtEntityControlLogic.
References makVre::DtPlayerComponent::player().
|
overridevirtual |
Updates the component state.
Updates the headlight state attribute based on the vehicle's current appearance.
| dt | Delta time in seconds since the last tick |
Reimplemented from makVre::DtEntityControlLogic.
|
overridevirtual |
Shuts down the component.
Unsubscribes from resource updates, removes callbacks, and cleans up input handlers.
Reimplemented from makVre::DtEntityControlLogic.
|
overridevirtual |
Returns the component type identifier.
Reimplemented from makVre::DtEntityControlLogic.
|
virtual |
Input handler functions.
Handles left steering input
Inverts the value and passes it to setSteering().
| val | The input value, typically from 0.0 to 1.0 |
|
virtual |
Handles right steering input.
Passes the value directly to setSteering().
| val | The input value, typically from 0.0 to 1.0 |
|
virtual |
Sets the vehicle's steering value.
Sends a "Steering" joystick message with the provided value.
| val | The steering value, from -1.0 (full left) to 1.0 (full right) |
|
virtual |
Sets the vehicle's throttle value.
Sends a "Throttle" joystick message with the provided value.
| val | The throttle value, typically from 0.0 to 1.0 |
|
virtual |
Sets the vehicle's brake value.
Sends a "Brake" joystick message with the provided value.
| val | The brake value, typically from 0.0 to 1.0 |
|
virtual |
Shifts up to the next gear.
Sends a "GearUp" joystick message with the provided value.
| val | The input value, a value of 1.0 triggers the gear shift |
|
virtual |
Shifts down to the previous gear.
Sends a "GearDown" joystick message with the provided value.
| val | The input value, a value of 1.0 triggers the gear shift |
|
virtual |
Toggles the engine on/off.
Sends an "EngineEnable" joystick message with the provided value.
| val | The input value, a value of 1.0 typically toggles the engine state |
|
virtual |
Toggles the differential lock.
Sends a "DifferentialLock" joystick message with the provided value. Only applies to vehicles with differential lock capability.
| val | The input value, a value of 1.0 typically toggles the differential lock |
|
virtual |
Toggles the parking brake.
Sends a "ParkingBrake" joystick message with the provided value.
| val | The input value, a value of 1.0 typically toggles the parking brake |
|
virtual |
Toggles the headlights.
Sends a "Headlights" joystick message with the provided value.
| val | The input value, a value of 1.0 typically toggles the headlights |
|
virtual |
Controls pivot steering.
Sends a "Pivot" joystick message with the provided value. Only applies to vehicles with pivot steering capability.
| val | The input value |
|
virtual |
Controls the towing hook.
Sends a "Hook" joystick message with the provided value. Only applies to vehicles with towing hook capability.
| val | The input value, typically toggles hook engagement |
|
virtual |
Sends a joystick message to the simulation.
Helper function called by the various control functions to send joystick messages with the appropriate parameters.
| function | The function name to include in the message |
| val | The function value to include in the message |
| delay | Optional delay before sending the message (defaults to 0) |
|
protectedvirtual |
Handles resource update messages.
Processes resource updates, particularly for fuel levels. Updates the "fuel" state attribute with the current amount.
| msg | The resource update message to process |
|
protectedvirtual |
Callback for changes to the hook target UUID.
When a nearby towing target is found, its entity ID (UUID) is published. This callback updates the "hasHookTarget" and "hook-target-marking-text" state attributes accordingly.
| hookTargetUuid | The UUID of the potential hook target |
|
protected |
Marking text for the current entity used in resource subscription.
|
protected |
Input handler logic for processing input device events.
|
protected |
Main joystick function group name from configuration.
Used to identify the function group when sending joystick messages.
|
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.
|
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.
|
protected |
Flag indicating if this vehicle has a tow hook.
When true, enables towing hook functionality. This value is stored in the "hasTowHook" state attribute. Defaults to false.
|
protected |