BVB Source Codes

CRYENGINE Show LookAtSimple.cpp Source code

Return Download CRYENGINE: download LookAtSimple.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.  
  5. #include "LookAtSimple.h"
  6.  
  7. using namespace AnimPoseModifier;
  8.  
  9. /*
  10.    CLookAtSimple
  11.  */
  12.  
  13. CRYREGISTER_CLASS(CLookAtSimple)
  14.  
  15. //
  16.  
  17. CLookAtSimple::CLookAtSimple()
  18. {
  19.         m_state.jointId = -1;
  20.         m_state.jointOffsetRelative.zero();
  21.         m_state.targetGlobal.zero();
  22.         m_state.weight = 1.0f;
  23. };
  24.  
  25. //
  26.  
  27. bool CLookAtSimple::ValidateJointId(IDefaultSkeleton& rIDefaultSkeleton)
  28. {
  29.         if (m_stateExecute.jointId < 0)
  30.                 return false;
  31.         return m_stateExecute.jointId < rIDefaultSkeleton.GetJointCount();
  32. }
  33.  
  34. // IAnimationPoseModifier
  35.  
  36. bool CLookAtSimple::Prepare(const SAnimationPoseModifierParams& params)
  37. {
  38.         m_stateExecute = m_state;
  39.         return true;
  40. }
  41.  
  42. bool CLookAtSimple::Execute(const SAnimationPoseModifierParams& params)
  43. {
  44.         const IDefaultSkeleton& rIDefaultSkeleton = params.GetIDefaultSkeleton();
  45.         const QuatT& transformation = params.pPoseData->GetJointAbsolute(m_stateExecute.jointId);
  46.  
  47.         Vec3 offsetAbsolute = m_stateExecute.jointOffsetRelative * transformation.q;
  48.         Vec3 targetAbsolute = m_stateExecute.targetGlobal - params.location.t;
  49.         Vec3 directionAbsolute = (targetAbsolute - (transformation.t + offsetAbsolute)) * params.location.q;
  50.         directionAbsolute.Normalize();
  51.  
  52.         params.pPoseData->SetJointAbsoluteO(m_stateExecute.jointId, Quat::CreateNlerp(
  53.                                               transformation.q, Quat::CreateRotationVDir(directionAbsolute, -gf_PI * 0.5f), m_stateExecute.weight));
  54.  
  55.         int32 parentJointId = params.GetIDefaultSkeleton().GetJointParentIDByID(m_stateExecute.jointId);
  56.         if (parentJointId < 0)
  57.         {
  58.                 params.pPoseData->SetJointRelative(m_stateExecute.jointId, transformation);
  59.                 return true;
  60.         }
  61.  
  62.         params.pPoseData->SetJointRelative(m_stateExecute.jointId,
  63.                                            params.pPoseData->GetJointAbsolute(parentJointId).GetInverted() * transformation);
  64.         return true;
  65. }
  66.  
  67. void CLookAtSimple::Synchronize()
  68. {
  69. }
  70.  
downloadLookAtSimple.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