BVB Source Codes

CRYENGINE Show ProceduralClipForceFeedback.cpp Source code

Return Download CRYENGINE: download ProceduralClipForceFeedback.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. //
  4. ////////////////////////////////////////////////////////////////////////////
  5.  
  6. #include "StdAfx.h"
  7.  
  8. #include "ICryMannequin.h"
  9. #include "IForceFeedbackSystem.h"
  10.  
  11. #include <Mannequin/Serialization.h>
  12.  
  13. struct SForceFeedbackClipParams : public IProceduralParams
  14. {
  15.         SForceFeedbackClipParams()
  16.                 : scale(1.f)
  17.                 , delay(0.f)
  18.                 , onlyLocal(true)
  19.         {
  20.         }
  21.  
  22.         virtual void Serialize(Serialization::IArchive& ar) override
  23.         {
  24.                 ar(Serialization::Decorators::ForceFeedbackIdName<TProcClipString>(forceFeedbackId), "ForceFeedbackID", "ForceFeedbackID");
  25.                 ar(scale, "Scale", "Scale");
  26.                 ar(delay, "Delay", "Delay");
  27.                 ar(onlyLocal, "OnlyLocal", "OnlyLocal");
  28.         }
  29.  
  30.         virtual void GetExtraDebugInfo(StringWrapper& extraInfoOut) const override
  31.         {
  32.                 extraInfoOut = forceFeedbackId.c_str();
  33.         }
  34.  
  35.         TProcClipString forceFeedbackId;
  36.         float           scale;
  37.         float           delay;
  38.         bool            onlyLocal;
  39. };
  40.  
  41. class CProceduralClipForceFeedback : public TProceduralClip<SForceFeedbackClipParams>
  42. {
  43. public:
  44.         CProceduralClipForceFeedback()
  45.         {
  46.         }
  47.  
  48.         virtual void OnEnter(float blendTime, float duration, const SForceFeedbackClipParams& params)
  49.         {
  50.                 IGameFramework* pGameFrameWork = gEnv->pGameFramework;
  51.  
  52.                 if ((gEnv->IsEditor() && pGameFrameWork->GetMannequinInterface().IsSilentPlaybackMode())
  53.                     || (params.onlyLocal && pGameFrameWork->GetClientActorId() != m_entity->GetId()))
  54.                 {
  55.                         return;
  56.                 }
  57.  
  58.                 IForceFeedbackSystem* pForceFeedback = CCryAction::GetCryAction()->GetIForceFeedbackSystem();
  59.                 CRY_ASSERT(pForceFeedback);
  60.                 ForceFeedbackFxId fxId = pForceFeedback->GetEffectIdByName(params.forceFeedbackId.c_str());
  61.  
  62.                 if (fxId != InvalidForceFeedbackFxId)
  63.                 {
  64.                         float actionScale = 0.f;
  65.                         float ffScale = params.scale;
  66.  
  67.                         if (GetParam("ffScale", actionScale))
  68.                         {
  69.                                 ffScale *= actionScale;
  70.                         }
  71.  
  72.                         SForceFeedbackRuntimeParams runtimeParams(ffScale, params.delay);
  73.                         pForceFeedback->PlayForceFeedbackEffect(fxId, runtimeParams);
  74.                 }
  75.         }
  76.  
  77.         virtual void OnExit(float blendTime)  {}
  78.  
  79.         virtual void Update(float timePassed) {}
  80.  
  81. };
  82.  
  83. REGISTER_PROCEDURAL_CLIP(CProceduralClipForceFeedback, "ForceFeedback");
  84.  
downloadProceduralClipForceFeedback.cpp 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