Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #ifndef C_JIGGLEBONES_H
  9. #define C_JIGGLEBONES_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "studio.h"
  14. #include "utlvector.h"
  15. #include "utllinkedlist.h"
  16. //-----------------------------------------------------------------------------
  17. /**
  18. * JiggleData is the instance-specific data for a jiggle bone
  19. */
  20. struct JiggleData
  21. {
  22. void Init( int initBone, float currenttime, const Vector &initBasePos, const Vector &initTipPos )
  23. {
  24. bone = initBone;
  25. lastUpdate = currenttime;
  26. basePos = initBasePos;
  27. baseLastPos = basePos;
  28. baseVel.Init();
  29. baseAccel.Init();
  30. tipPos = initTipPos;
  31. tipVel.Init();
  32. tipAccel.Init();
  33. lastLeft = Vector( 0, 0, 0 );
  34. lastBoingPos = initBasePos;
  35. boingDir = Vector( 0.0f, 0.0f, 1.0f );
  36. boingVelDir.Init();
  37. boingSpeed = 0.0f;
  38. boingTime = 0.0f;
  39. }
  40. int bone;
  41. float lastUpdate; // based on gpGlobals->realtime
  42. Vector basePos; // position of the base of the jiggle bone
  43. Vector baseLastPos;
  44. Vector baseVel;
  45. Vector baseAccel;
  46. Vector tipPos; // position of the tip of the jiggle bone
  47. Vector tipVel;
  48. Vector tipAccel;
  49. Vector lastLeft; // previous up vector
  50. Vector lastBoingPos; // position of base of jiggle bone last update for tracking velocity
  51. Vector boingDir; // current direction along which the boing effect is occurring
  52. Vector boingVelDir; // current estimation of jiggle bone unit velocity vector for boing effect
  53. float boingSpeed; // current estimation of jiggle bone speed for boing effect
  54. float boingTime;
  55. int useGoalMatrixCount; // Count of times we need to fast draw using goal matrix.
  56. int useJiggleBoneCount; // Count of times we need to draw using real jiggly bones.
  57. };
  58. class CJiggleBones
  59. {
  60. public:
  61. JiggleData * GetJiggleData( int bone, float currenttime, const Vector &initBasePos, const Vector &initTipPos );
  62. void BuildJiggleTransformations( int boneIndex, float currentime, const mstudiojigglebone_t *jiggleParams, const matrix3x4_t &goalMX, matrix3x4_t &boneMX );
  63. CUtlLinkedList< JiggleData > m_jiggleBoneState;
  64. };
  65. extern void DevMsgRT( PRINTF_FORMAT_STRING char const* pMsg, ... );
  66. #endif // C_BASEANIMATING_H