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.

169 lines
5.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. #if 0
  11. class C_AI_BaseHumanoid : public C_AI_BaseNPC
  12. {
  13. public:
  14. DECLARE_CLASS( C_AI_BaseHumanoid, C_AI_BaseNPC );
  15. DECLARE_CLIENTCLASS();
  16. C_AI_BaseHumanoid();
  17. // model specific
  18. virtual bool Interpolate( float currentTime );
  19. virtual void StandardBlendingRules( CStudioHdr *pStudioHdr, Vector pos[], Quaternion q[], float currentTime, int boneMask );
  20. float m_recanimtime[3];
  21. AnimationLayer_t m_Layer[4][3];
  22. };
  23. C_AI_BaseHumanoid::C_AI_BaseHumanoid()
  24. {
  25. memset(m_recanimtime, 0, sizeof(m_recanimtime));
  26. memset(m_Layer, 0, sizeof(m_Layer));
  27. }
  28. BEGIN_RECV_TABLE_NOBASE(AnimationLayer_t, DT_Animationlayer)
  29. RecvPropInt(RECVINFO_NAME(nSequence,sequence)),
  30. RecvPropFloat(RECVINFO_NAME(flCycle,cycle)),
  31. RecvPropFloat(RECVINFO_NAME(flPlaybackrate,playbackrate)),
  32. RecvPropFloat(RECVINFO_NAME(flWeight,weight))
  33. END_RECV_TABLE()
  34. IMPLEMENT_CLIENTCLASS_DT(C_AI_BaseHumanoid, DT_BaseHumanoid, CAI_BaseHumanoid)
  35. /*
  36. RecvPropDataTable(RECVINFO_DTNAME(m_Layer[0][2],m_Layer0),0, &REFERENCE_RECV_TABLE(DT_Animationlayer)),
  37. RecvPropDataTable(RECVINFO_DTNAME(m_Layer[1][2],m_Layer1),0, &REFERENCE_RECV_TABLE(DT_Animationlayer)),
  38. RecvPropDataTable(RECVINFO_DTNAME(m_Layer[2][2],m_Layer2),0, &REFERENCE_RECV_TABLE(DT_Animationlayer)),
  39. RecvPropDataTable(RECVINFO_DTNAME(m_Layer[3][2],m_Layer3),0, &REFERENCE_RECV_TABLE(DT_Animationlayer)),
  40. */
  41. RecvPropInt(RECVINFO_NAME(m_Layer[0][2].nSequence,sequence0)),
  42. RecvPropFloat(RECVINFO_NAME(m_Layer[0][2].flCycle,cycle0)),
  43. RecvPropFloat(RECVINFO_NAME(m_Layer[0][2].flPlaybackrate,playbackrate0)),
  44. RecvPropFloat(RECVINFO_NAME(m_Layer[0][2].flWeight,weight0)),
  45. RecvPropInt(RECVINFO_NAME(m_Layer[1][2].nSequence,sequence1)),
  46. RecvPropFloat(RECVINFO_NAME(m_Layer[1][2].flCycle,cycle1)),
  47. RecvPropFloat(RECVINFO_NAME(m_Layer[1][2].flPlaybackrate,playbackrate1)),
  48. RecvPropFloat(RECVINFO_NAME(m_Layer[1][2].flWeight,weight1)),
  49. RecvPropInt(RECVINFO_NAME(m_Layer[2][2].nSequence,sequence2)),
  50. RecvPropFloat(RECVINFO_NAME(m_Layer[2][2].flCycle,cycle2)),
  51. RecvPropFloat(RECVINFO_NAME(m_Layer[2][2].flPlaybackrate,playbackrate2)),
  52. RecvPropFloat(RECVINFO_NAME(m_Layer[2][2].flWeight,weight2)),
  53. RecvPropInt(RECVINFO_NAME(m_Layer[3][2].nSequence,sequence3)),
  54. RecvPropFloat(RECVINFO_NAME(m_Layer[3][2].flCycle,cycle3)),
  55. RecvPropFloat(RECVINFO_NAME(m_Layer[3][2].flPlaybackrate,playbackrate3)),
  56. RecvPropFloat(RECVINFO_NAME(m_Layer[3][2].flWeight,weight3))
  57. END_RECV_TABLE()
  58. //-----------------------------------------------------------------------------
  59. // Purpose:
  60. //-----------------------------------------------------------------------------
  61. void C_AI_BaseHumanoid::StandardBlendingRules( CStudioHdr *pStudioHdr, Vector pos[], Quaternion q[], float currentTime, int boneMask )
  62. {
  63. VPROF( "C_AI_BaseHumanoid::StandardBlendingRules" );
  64. BaseClass::StandardBlendingRules( pStudioHdr, pos, q, currentTime, boneMask );
  65. if ( !hdr )
  66. {
  67. return;
  68. }
  69. #if 0
  70. float poseparam[MAXSTUDIOPOSEPARAM];
  71. if ( GetSequence() >= hdr->numseq )
  72. {
  73. SetSequence( 0 );
  74. }
  75. // interpolate pose parameters
  76. for (int i = 0; i < hdr->numposeparameters; i++)
  77. {
  78. poseparam[ i ] = m_flPoseParameter[i];
  79. }
  80. // build root animation
  81. float fCycle = GetCycle();
  82. CalcPose( hdr, NULL, pos, q, GetSequence(), fCycle, poseparam );
  83. // debugoverlay->AddTextOverlay( GetAbsOrigin() + Vector( 0, 0, 64 ), 0, 0, "%30s %6.2f : %6.2f", hdr->pSeqdesc( GetSequence() )->pszLabel( ), fCycle, 1.0 );
  84. MaintainSequenceTransitions( hdr, fCycle, poseparam, pos, q, boneMask );
  85. #if 1
  86. for (i = 0; i < 4; i++)
  87. {
  88. if (m_Layer[i][2].nSequence != m_Layer[i][1].nSequence)
  89. {
  90. if (m_Layer[i][2].flWeight > 0.5) m_Layer[i][1].flWeight = 1.0; else m_Layer[i][1].flWeight = 0;
  91. }
  92. }
  93. #endif
  94. #if 1
  95. for (i = 0; i < 4; i++)
  96. {
  97. Vector pos2[MAXSTUDIOBONES];
  98. Quaternion q2[MAXSTUDIOBONES];
  99. float fWeight = m_Layer[i][1].flWeight * (1 - dadt) + m_Layer[i][2].flWeight * dadt;
  100. /*
  101. debugoverlay->AddTextOverlay( GetAbsOrigin() + Vector( 0, 0, 64 ), -i - 1, 0,
  102. "%2d %6.2f %6.2f : %2d %6.2f %6.2f : %2d %6.2f %6.2f",
  103. m_Layer[i][0].nSequence, m_Layer[i][0].flCycle, m_Layer[i][0].flWeight,
  104. m_Layer[i][1].nSequence, m_Layer[i][1].flCycle, m_Layer[i][1].flWeight,
  105. m_Layer[i][2].nSequence, m_Layer[i][2].flCycle, m_Layer[i][2].flWeight );
  106. */
  107. if (fWeight > 0)
  108. {
  109. mstudioseqdesc_t *pseqdesc = hdr->pSeqdesc( m_Layer[i][2].nSequence );
  110. float fCycle = m_Layer[i][2].flCycle;
  111. // UNDONE: Do IK here.
  112. CalcPose( hdr, NULL, pos2, q2, m_Layer[i][2].nSequence, fCycle, poseparam );
  113. if (fWeight > 1)
  114. fWeight = 1;
  115. SlerpBones( hdr, q, pos, pseqdesc, q2, pos2, fWeight );
  116. engine->Con_NPrintf( 10 + i, "%30s %6.2f : %6.2f", pseqdesc->pszLabel(), fCycle, fWeight );
  117. }
  118. else
  119. {
  120. engine->Con_NPrintf( 10 + i, "%30s %6.2f : %6.2f", " ", 0, 0 );
  121. }
  122. }
  123. #endif
  124. CIKContext auto_ik;
  125. auto_ik.Init( hdr, GetRenderAngles(), GetRenderOrigin(), gpGlobals->curtime );
  126. CalcAutoplaySequences( hdr, &auto_ik, pos, q, poseparam, boneMask, currentTime );
  127. float controllers[MAXSTUDIOBONECTRLS];
  128. GetBoneControllers(controllers);
  129. CalcBoneAdj( hdr, pos, q, controllers );
  130. #endif
  131. }
  132. #endif