![]() |
VR-Forces Developer's Guide
|
Models weapon accuracy and bullet spread over time.
Tracks a spread angle that grows with each shot and recovers between shots, producing less accuracy during sustained fire.
Public Member Functions | |
| DtAccuracyModel () | |
| virtual | ~DtAccuracyModel () |
| virtual void | setBaseSpread (double spreadAngle) |
| virtual double | baseSpread () const |
| virtual void | setMovementSpreadMultiplier (double multiplier) |
| virtual double | movementSpreadMultiplier () const |
| virtual void | setRecoilAccumulation (double amount) |
| virtual double | recoilAccumulation () const |
| virtual void | setRecoilRecovery (double rate) |
| virtual double | recoilRecovery () const |
| virtual void | setMaxSpread (double maxSpread) |
| virtual double | maxSpread () const |
| virtual void | setIsMoving (bool isMoving) |
| virtual bool | isMoving () const |
| virtual dvec3 | applySpread (const dvec3 &idealDirection, const DtCoordinateFrame &weaponFrame) |
| virtual void | onShot () |
| virtual void | update (double deltaTime) |
| virtual double | currentSpread () const |
| virtual double | currentSpreadValue () const |
| virtual void | setCurrentSpread (double spread) |
| virtual void | resetSpread () |
Protected Member Functions | |
| virtual dvec3 | randomInCone (const dvec3 &direction, double angle) |
Protected Attributes | |
| double | myBaseSpread |
| double | myCurrentSpread |
| double | myMaxSpread |
| double | myRecoilAccumulation |
| double | myRecoilRecovery |
| double | myMovementMultiplier |
| bool | myIsMoving |
| makVrv::DtAccuracyModel::DtAccuracyModel | ( | ) |
Default constructor.
|
virtual |
Destructor.
|
virtual |
Sets the base spread angle in radians.
|
virtual |
Returns the base spread angle in radians.
|
virtual |
Sets the spread multiplier applied while the weapon is moving.
| multiplier | Spread multiplier; clamped to a minimum of 1.0. |
|
virtual |
Returns the spread multiplier applied while the weapon is moving.
|
virtual |
Sets the spread increase per shot.
|
virtual |
Returns the spread increase per shot.
|
virtual |
Sets the rate at which spread recovers toward the base value per second.
| rate | Recovery amount subtracted from current spread each second. |
|
virtual |
Returns the spread recovery rate per second.
|
virtual |
Sets the maximum spread angle in radians.
|
virtual |
Returns the maximum spread angle in radians.
|
virtual |
Sets whether the weapon is currently moving.
|
virtual |
Returns whether the weapon is currently moving.
|
virtual |
Applies random spread to a firing direction using the weapon's local frame.
| idealDirection | World-space ideal firing direction. |
| weaponFrame | Coordinate frame of the weapon. |
|
virtual |
Notifies the model that a shot was fired, accumulating spread.
|
virtual |
Advances the accuracy model by one frame.
| deltaTime | Elapsed time in seconds. |
|
virtual |
Returns the current effective spread angle in radians.
|
virtual |
Returns the raw current spread value.
|
virtual |
Sets the current spread value directly.
|
virtual |
Resets the spread to the base value immediately.
|
protectedvirtual |
Returns a random unit direction within a cone around the given direction.
| direction | Centre direction of the cone. |
| angle | Half-angle of the cone in radians. |
|
protected |
Minimum spread angle in radians.
|
protected |
Current effective spread angle in radians.
|
protected |
Maximum spread angle in radians.
|
protected |
Spread increase per shot.
|
protected |
Spread recovery rate per second.
|
protected |
Spread multiplier when moving.
|
protected |
Whether the weapon is currently moving.