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