BVB Source Codes

CRYENGINE Show VehicleSeatActionRotateTurret.h Source code

Return Download CRYENGINE: download VehicleSeatActionRotateTurret.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description: Implements a seat action to rotate a turret
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 14:12:2005: Created by Mathieu Pinard
  12.  
  13. *************************************************************************/
  14. #ifndef __VEHICLESEATACTIONROTATETURRET_H__
  15. #define __VEHICLESEATACTIONROTATETURRET_H__
  16.  
  17. #include <CryAction/InterpolationHelpers.h>
  18.  
  19. class CVehiclePartBase;
  20. class CVehicle;
  21. class CVehicleSeat;
  22.  
  23. // holds information for each of the rotation types
  24. struct SVehiclePartRotationParameters
  25. {
  26.         SVehiclePartRotationParameters() : m_prevWorldQuat(IDENTITY)
  27.         {
  28.                 m_pPart = NULL;
  29.                 m_action = 0.0f;
  30.                 m_aimAssist = 0.f;
  31.                 m_currentValue = 0.0f;
  32.                 m_speed = 0.0f;
  33.                 m_acceleration = 0.0f;
  34.                 m_minLimitF = 0.0f;
  35.                 m_minLimitB = 0.0f;
  36.                 m_maxLimit = 0.0f;
  37.                 m_relSpeed = 0.0f;
  38.                 m_worldSpace = false;
  39.                 m_orientation = InterpolatedQuat(Quat::CreateIdentity(), 0.75f, 3.0f);
  40.                 m_turnSoundId = InvalidSoundEventId;
  41.                 m_damageSoundId = InvalidSoundEventId;
  42.         }
  43.  
  44.         InterpolatedQuat     m_orientation; //  Interpolated orientation for this part
  45.  
  46.         CVehiclePartBase*    m_pPart; // TODO: IVehiclePart*?
  47.  
  48.         float                m_action;       // what the user input is requesting
  49.         float                m_aimAssist;    // what the aim assist is requesting
  50.         float                m_currentValue; // current rotation
  51.         float                m_speed;        // speed of rotation (from vehicle xml)
  52.         float                m_acceleration; // acceleration of rotation (from vehicle xml)
  53.  
  54.         float                m_minLimitF; // smallest permissable value (from xml), when facing forwards
  55.         float                m_minLimitB; // smallest permissable value (from xml), when facing backwards
  56.         float                m_maxLimit;  // largest permissable value (from xml)
  57.  
  58.         float                m_relSpeed; // used to interpolate the rotation speed (for sound)
  59.  
  60.         Quat                 m_prevWorldQuat; // previous world-space rotation
  61.  
  62.         TVehicleSoundEventId m_turnSoundId;
  63.         TVehicleSoundEventId m_damageSoundId;
  64.  
  65.         bool                 m_worldSpace; // rotation should be calculated in world space
  66. };
  67.  
  68. class CVehicleSeatActionRotateTurret
  69.         : public IVehicleSeatAction
  70. {
  71.         IMPLEMENT_VEHICLEOBJECT
  72. public:
  73.  
  74.         // IVehicleSeatAction
  75.         virtual bool Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams& table) override;
  76.         virtual void Reset() override;
  77.         virtual void Release() override { delete this; }
  78.  
  79.         virtual void StartUsing(EntityId passengerId) override;
  80.         virtual void ForceUsage() override {}
  81.         virtual void StopUsing() override;
  82.         virtual void OnAction(const TVehicleActionId actionId, int activationMode, float value) override;
  83.  
  84.         virtual void Serialize(TSerialize ser, EEntityAspects aspects) override;
  85.         virtual void PostSerialize() override {}
  86.         virtual void Update(const float deltaTime) override;
  87.  
  88.         virtual void UpdateFromPassenger(const float deltaTime, EntityId playerId) override;
  89.  
  90.         virtual void GetMemoryUsage(ICrySizer* s) const override { s->Add(*this); }
  91.         // ~IVehicleSeatAction
  92.  
  93.         void         SetAimGoal(Vec3 aimPos, int priority = 0);
  94.         bool         GetRemainingAnglesToAimGoalInDegrees(float& pitch, float& yaw); // FIXME: should be const, but IVehiclePart::GetLocalTM() is not const
  95.  
  96.         virtual void OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params) override {}
  97.         virtual bool GetRotationLimits(int axis, float& min, float& max);
  98.  
  99. protected:
  100.  
  101.         enum EVehicleTurretRotationType
  102.         {
  103.                 eVTRT_Pitch = 0,
  104.                 eVTRT_Yaw,
  105.                 eVTRT_NumRotationTypes,
  106.         };
  107.  
  108.         void  DoUpdate(const float deltaTime);
  109.  
  110.         void  UpdateAimGoal();
  111.         void  MaintainPartRotationWorldSpace(EVehicleTurretRotationType eType);
  112.         void  UpdatePartRotation(EVehicleTurretRotationType eType, float frameTime);
  113.         float GetDamageSpeedMul(CVehiclePartBase* pPart);
  114.  
  115.         bool  InitRotation(IVehicle* pVehicle, const CVehicleParams& rotationTable, EVehicleTurretRotationType eType);
  116.         bool  InitRotationSounds(const CVehicleParams& rotationParams, EVehicleTurretRotationType eType);
  117.         void  UpdateRotationSound(EVehicleTurretRotationType eType, float speed, float deltaTime);
  118.  
  119.         CVehicle*                      m_pVehicle;
  120.         IEntity*                       m_pUserEntity;
  121.         CVehicleSeat*                  m_pSeat;
  122.  
  123.         Vec3                           m_aimGoal;
  124.         int                            m_aimGoalPriority;
  125.  
  126.         SVehiclePartRotationParameters m_rotations[eVTRT_NumRotationTypes];
  127.  
  128.         IVehicleHelper*                m_rotTestHelpers[2];
  129.         float                          m_rotTestRadius;
  130.  
  131.         friend class CVehiclePartBase;
  132. };
  133.  
  134. #endif
  135.  
downloadVehicleSeatActionRotateTurret.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top