NSRenderableEntity: add inputs SetAnimation and SetBodyInGroup

This commit is contained in:
Marco Cawthorne 2023-09-27 13:07:53 -07:00
parent 4dcaefe368
commit 9d6133054c
Signed by: eukara
GPG key ID: CE2032F0A2882A22
2 changed files with 44 additions and 17 deletions

View file

@ -112,7 +112,9 @@ private:
float m_flBaseTime; float m_flBaseTime;
#ifdef CLIENT #ifdef CLIENT
float m_iNumBones;
nonvirtual void _UpdateGeomset(); nonvirtual void _UpdateGeomset();
nonvirtual void _UpdateBoneCount();
#endif #endif
#ifdef SERVER #ifdef SERVER

View file

@ -14,6 +14,8 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
void void
NSRenderableEntity::NSRenderableEntity(void) NSRenderableEntity::NSRenderableEntity(void)
{ {
@ -58,6 +60,15 @@ void NSRenderableEntity::_UpdateGeomset(void)
sprintf("geomset 0 %i\ngeomset 1 %i\ngeomset 2 %i\ngeomset 3 %i\n", firstBody, secondBody, thirdBody, fourthBody) sprintf("geomset 0 %i\ngeomset 1 %i\ngeomset 2 %i\ngeomset 3 %i\n", firstBody, secondBody, thirdBody, fourthBody)
); );
} }
void
NSRenderableEntity::_UpdateBoneCount(void)
{
skeletonindex = skel_create(modelindex);
m_iNumBones = skel_get_numbones(skeletonindex) + 1;
//print(sprintf("UPDATED GEOMSET FOR MODELINDEX %d, %d BONES\n", modelindex, m_iNumBones));
skel_delete(skeletonindex);
}
#endif #endif
/* /*
@ -298,6 +309,8 @@ NSRenderableEntity::ReceiveEntity(float flNew, float flChanged)
setsize(this, mins * scale, maxs * scale); setsize(this, mins * scale, maxs * scale);
if (flChanged & RDENT_CHANGED_BODY) if (flChanged & RDENT_CHANGED_BODY)
_UpdateGeomset(); _UpdateGeomset();
if (flChanged & RDENT_CHANGED_MODELINDEX)
_UpdateBoneCount();
} }
/* /*
@ -767,6 +780,7 @@ NSRenderableEntity::SetBodyInGroup(int groupID, int bodyValue)
{ {
/* pack our half bytes */ /* pack our half bytes */
m_iBody |= (bodyValue << (4 * groupID)); m_iBody |= (bodyValue << (4 * groupID));
m_iBody_net = 0;
//print(sprintf("NEW BODY: %i %i %i\n", m_iBody, groupID, bodyValue)); //print(sprintf("NEW BODY: %i %i %i\n", m_iBody, groupID, bodyValue));
} }
@ -946,44 +960,38 @@ void
NSRenderableEntity::HandleAnimEvent(float flTimeStamp, int iCode, string strData) NSRenderableEntity::HandleAnimEvent(float flTimeStamp, int iCode, string strData)
{ {
switch(iCode) { switch(iCode) {
#ifdef CLIENT
case 1004: /* plays a sound on CHAN_BODY */ case 1004: /* plays a sound on CHAN_BODY */
#ifdef CLIENT
if (substring(strData, 0, 1) == "*") if (substring(strData, 0, 1) == "*")
sound(self, CHAN_BODY, substring(strData, 1, -1), 1.0f, ATTN_NORM); sound(self, CHAN_BODY, substring(strData, 1, -1), 1.0f, ATTN_NORM);
else else
sound(self, CHAN_BODY, strData, 1.0f, ATTN_NORM); sound(self, CHAN_BODY, strData, 1.0f, ATTN_NORM);
#endif
break; break;
case 1008: /* plays a sound on CHAN_VOICE */ case 1008: /* plays a sound on CHAN_VOICE */
#ifdef CLIENT
if (substring(strData, 0, 1) == "*") if (substring(strData, 0, 1) == "*")
sound(self, CHAN_VOICE, substring(strData, 1, -1), 1.0f, ATTN_NORM); sound(self, CHAN_VOICE, substring(strData, 1, -1), 1.0f, ATTN_NORM);
else else
sound(self, CHAN_VOICE, strData, 1.0f, ATTN_NORM); sound(self, CHAN_VOICE, strData, 1.0f, ATTN_NORM);
#endif
break; break;
#if 0 #ifdef CLIENT
case 5004: /* view model sound? */ case 5004: /* view model sound? */
localsound(strData, CHAN_AUTO, 1.0); sound(this, CHAN_AUTO, strData, 1.0, ATTN_NORM);
break; break;
case 5001: /* muzzle flash on attachment 0 */ case 5001: /* muzzle flash on attachment 0 */
pSeat->m_eMuzzleflash.alpha = 1.0f; vector muzzleOrg = gettaginfo(this, m_iNumBones);
pSeat->m_eMuzzleflash.scale = 0.25;
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones;
break; break;
case 5011: /* muzzle flash on attachment 1 */ case 5011: /* muzzle flash on attachment 1 */
pSeat->m_eMuzzleflash.alpha = 1.0f; vector muzzleOrg = gettaginfo(this, m_iNumBones + 1);
pSeat->m_eMuzzleflash.scale = 0.25;
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 1;
break; break;
case 5021: /* muzzle flash on attachment 2 */ case 5021: /* muzzle flash on attachment 2 */
pSeat->m_eMuzzleflash.alpha = 1.0f; vector muzzleOrg = gettaginfo(this, m_iNumBones + 2);
pSeat->m_eMuzzleflash.scale = 0.25;
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 2;
break; break;
case 5031: /* muzzle flash on attachment 3 */ case 5031: /* muzzle flash on attachment 3 */
pSeat->m_eMuzzleflash.alpha = 1.0f; vector muzzleOrg = gettaginfo(this, m_iNumBones + 3);
pSeat->m_eMuzzleflash.scale = 0.25;
pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 3;
break; break;
#endif
#else #else
case 1003: /* trigger SSQC entity with specific targetname */ case 1003: /* trigger SSQC entity with specific targetname */
for (entity f = world; (f = find(f, ::targetname, strData));) { for (entity f = world; (f = find(f, ::targetname, strData));) {
@ -1016,12 +1024,14 @@ NSRenderableEntity::HandleAnimEvent(float flTimeStamp, int iCode, string strData
Input(this, testInput, strData); /* no parms passed. */ Input(this, testInput, strData); /* no parms passed. */
tokenize(m_strModelEventCB); /* ensure argv() is 'rewound'... */ tokenize(m_strModelEventCB); /* ensure argv() is 'rewound'... */
return;
} }
} }
//print(sprintf("Received: %f %i %S\n", flTimeStamp, iCode, strData)); //print(sprintf("Received: %f %i %S\n", flTimeStamp, iCode, strData));
NSLog("SSQC model event: %f %i %S", flTimeStamp, iCode, strData);
#else #else
NSLog("Unknown model event: %f %i %S", flTimeStamp, iCode, strData); NSLog("CSQC model event: %f %i %S", flTimeStamp, iCode, strData);
#endif #endif
} }
} }
@ -1118,6 +1128,21 @@ NSRenderableEntity::Input(entity eAct, string strInput, string strData)
case "EnableShadow": case "EnableShadow":
effects &= ~EF_NOSHADOW; effects &= ~EF_NOSHADOW;
break; break;
case "SetAnimation":
float animFrame = frameforname(modelindex, strcat("@", strData));
SetFrame(animFrame);
print(sprintf("SetAnimation: %S (%d) on %S\n",strData, animFrame, model));
break;
case "SetBodyInGroup":
int argC = tokenize(strData);
if (argC == 2) {
int bodyGroup = stoi(argv(0));
int bodyModel = stoi(argv(1));
SetBodyInGroup(bodyGroup, bodyModel);
//print(sprintf("SetBodyInGroup %i to %i\n", bodyGroup, bodyModel));
}
break;
default: default:
super::Input(eAct, strInput, strData); super::Input(eAct, strInput, strData);
} }