BVB Source Codes

CRYENGINE Show LipSync_TransitionQueue.h Source code

Return Download CRYENGINE: download LipSync_TransitionQueue.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   LipSync_TransitionQueue.h
  5. //  Version:     v1.00
  6. //  Created:     2014-08-29 by Christian Werle.
  7. //  Description: Automatic start of facial animation when a sound is being played back.
  8. // -------------------------------------------------------------------------
  9. //  History:
  10. //
  11. ////////////////////////////////////////////////////////////////////////////
  12.  
  13. #pragma once
  14.  
  15. #include <CryAction/ILipSyncProvider.h>
  16.  
  17. /// The CLipSyncProvider_TransitionQueue communicates with sound proxy to play synchronized facial animation directly on the transition queue
  18. class CLipSyncProvider_TransitionQueue : public ILipSyncProvider
  19. {
  20. public:
  21.         explicit CLipSyncProvider_TransitionQueue(EntityId entityId);
  22.  
  23.         // ILipSyncProvider
  24.         void RequestLipSync(IEntityAudioComponent* pProxy, const AudioControlId audioTriggerId, const ELipSyncMethod lipSyncMethod) override;
  25.         void StartLipSync(IEntityAudioComponent* pProxy, const AudioControlId audioTriggerId, const ELipSyncMethod lipSyncMethod) override;
  26.         void PauseLipSync(IEntityAudioComponent* pProxy, const AudioControlId audioTriggerId, const ELipSyncMethod lipSyncMethod) override;
  27.         void UnpauseLipSync(IEntityAudioComponent* pProxy, const AudioControlId audioTriggerId, const ELipSyncMethod lipSyncMethod) override;
  28.         void StopLipSync(IEntityAudioComponent* pProxy, const AudioControlId audioTriggerId, const ELipSyncMethod lipSyncMethod) override;
  29.         void UpdateLipSync(IEntityAudioComponent* pProxy, const AudioControlId audioTriggerId, const ELipSyncMethod lipSyncMethod) override;
  30.         // ~ILipSyncProvider
  31.  
  32.         void FullSerialize(TSerialize ser);
  33.  
  34. private:
  35.         IEntity*            GetEntity();
  36.         ICharacterInstance* GetCharacterInstance();
  37.         void                FindMatchingAnim(const AudioControlId audioTriggerId, const ELipSyncMethod lipSyncMethod, ICharacterInstance& character, int* pAnimIdOut, CryCharAnimationParams* pAnimParamsOut) const;
  38.         void                FillCharAnimationParams(const bool isDefaultAnim, CryCharAnimationParams* pParams) const;
  39.         void                SynchronizeAnimationToSound(const AudioControlId audioTriggerId);
  40.  
  41. private:
  42.         enum EState
  43.         {
  44.                 eS_Init,
  45.                 eS_Requested,
  46.                 eS_Started,
  47.                 eS_Paused,
  48.                 eS_Unpaused,
  49.                 eS_Stopped,
  50.         };
  51.  
  52.         static uint32 s_lastAnimationToken;
  53.  
  54.         EntityId      m_entityId;
  55.         int           m_nCharacterSlot;   // the lip-sync animation will be played back on the character residing in this slot of the entity
  56.         int           m_nAnimLayer;       // the lip-sync animation will be played back on this layer of the character
  57.         string        m_sDefaultAnimName; // fallback animation to play if there is no animation matching the currently playing sound in the character's database
  58.  
  59.         EState        m_state;
  60.         bool          m_isSynchronized;
  61.  
  62.         // Filled when request comes in:
  63.         int                    m_requestedAnimId;
  64.         CryCharAnimationParams m_requestedAnimParams;
  65.         CAutoResourceCache_CAF m_cachedAnim;
  66.  
  67.         // Filled when animation is started:
  68.         uint32         m_nCurrentAnimationToken;
  69.         AudioControlId m_soundId;
  70. };
  71. DECLARE_SHARED_POINTERS(CLipSyncProvider_TransitionQueue);
  72.  
  73. class CLipSync_TransitionQueue : public CGameObjectExtensionHelper<CLipSync_TransitionQueue, IGameObjectExtension>
  74. {
  75. public:
  76.         // IGameObjectExtension
  77.         virtual void                 GetMemoryUsage(ICrySizer* pSizer) const override;
  78.         virtual bool                 Init(IGameObject* pGameObject) override;
  79.         virtual void                 PostInit(IGameObject* pGameObject) override;
  80.         virtual void                 InitClient(int channelId) override;
  81.         virtual void                 PostInitClient(int channelId) override;
  82.         virtual bool                 ReloadExtension(IGameObject* pGameObject, const SEntitySpawnParams& params) override;
  83.         virtual void                 PostReloadExtension(IGameObject* pGameObject, const SEntitySpawnParams& params) override;
  84.         virtual void                 FullSerialize(TSerialize ser) override;
  85.         virtual bool                 NetSerialize(TSerialize ser, EEntityAspects aspect, uint8 profile, int pflags) override;
  86.         virtual void                 PostSerialize() override;
  87.         virtual void                 SerializeSpawnInfo(TSerialize ser) override;
  88.         virtual ISerializableInfoPtr GetSpawnInfo() override;
  89.         virtual void                 Update(SEntityUpdateContext& ctx, int updateSlot) override;
  90.         virtual void                 HandleEvent(const SGameObjectEvent& event) override;
  91.         virtual void                 ProcessEvent(SEntityEvent& event) override;
  92.         virtual void                 SetChannelId(uint16 id) override;
  93.         virtual void                 SetAuthority(bool auth) override;
  94.         virtual void                 PostUpdate(float frameTime) override;
  95.         virtual void                 PostRemoteSpawn() override;
  96.         // ~IGameObjectExtension
  97.  
  98.         // IEntityComponent
  99.         virtual void OnShutDown() override;
  100.         // ~IEntityComponent
  101.  
  102. private:
  103.         void InjectLipSyncProvider();
  104.  
  105. private:
  106.         CLipSyncProvider_TransitionQueuePtr m_pLipSyncProvider;
  107. };
  108.  
downloadLipSync_TransitionQueue.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