BVB Source Codes

CRYENGINE Show CryModEffMorph.cpp Source code

Return Download CRYENGINE: download CryModEffMorph.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "stdafx.h"
  4. #include "CryModEffMorph.h"
  5.  
  6. // starts the morphing sequence
  7. void CryModEffMorph::StartMorph(int nMorphTargetId, const CryCharMorphParams& rParams)
  8. {
  9.         m_Params = rParams;
  10.         m_nMorphTargetId = nMorphTargetId;
  11.         m_fTime = rParams.m_fStartTime;
  12.         m_nFlags = rParams.m_nFlags;
  13. }
  14.  
  15. void CryModEffMorph::stop()
  16. {
  17.         m_nMorphTargetId = -1;
  18. }
  19.  
  20. // advances the current time of the played animation and returns the blending factor by which this animation affects the bone pose
  21. void CryModEffMorph::Tick(f32 fDeltaTime)
  22. {
  23.         if (m_nMorphTargetId < 0)
  24.                 return;
  25.  
  26.         if (!(m_nFlags & m_Params.FLAGS_FREEZE))
  27.                 m_fTime += fDeltaTime * m_Params.m_fSpeed;
  28.  
  29.         if ((m_nFlags & m_Params.FLAGS_INSTANTANEOUS) ||
  30.             !(m_nFlags & m_Params.FLAGS_NO_BLENDOUT) && m_fTime > m_Params.m_fBlendIn + m_Params.m_fBlendOut + m_Params.m_fLength)
  31.                 // we're finished
  32.                 m_nMorphTargetId = -1;
  33. }
  34.  
  35. // returns the blending for the morph target
  36. f32 CryModEffMorph::getBlending() const
  37. {
  38.         f32 fTimeStable = m_fTime - m_Params.m_fBlendIn;
  39.  
  40.         if (fTimeStable < 0) // blending in...
  41.                 return SmoothBlendValue(m_fTime / m_Params.m_fBlendIn) * m_Params.m_fAmplitude;
  42.  
  43.         if (m_nFlags & m_Params.FLAGS_NO_BLENDOUT)
  44.                 return m_Params.m_fAmplitude; // never blending out - stable morph
  45.  
  46.         f32 fTimeBlendOut = fTimeStable - m_Params.m_fLength;
  47.  
  48.         if (fTimeBlendOut < 0)
  49.                 return m_Params.m_fAmplitude;
  50.  
  51.         return SmoothBlendValue(1 - fTimeBlendOut / m_Params.m_fBlendOut) * m_Params.m_fAmplitude;
  52. }
  53.  
  54. // returns false when this morph target is inactive
  55. bool CryModEffMorph::isActive() const
  56. {
  57.         return m_nMorphTargetId >= 0;
  58. }
  59.  
  60. // returns the morph target, or -1 if none
  61. int CryModEffMorph::getMorphTargetId() const
  62. {
  63.         return m_nMorphTargetId;
  64. }
  65.  
downloadCryModEffMorph.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