Hands model as separate viewmodel entity

Grab your favourite IDE and tinker with the innards of game engines

Hands model as separate viewmodel entity

Postby atrblizzard on Fri Nov 25, 2011 12:20 am

Hello,
Basicly, what I want to achieve is to have a separate client model entity, which will use a hand model, which gets attached to the weapon viewmodel entity. Both the hands and the weapon models have their own animations, and the hands models have all the animations for the weapon viewmodels.
From what I know, the entity has to be created, initialized as client entity, have its parent set to the viewmodel, and have the bones merged to the viewmodel.
But I am unsure where this has to be spawned and initialized and how exactly it needs to be done in order to get the proper result.

Code: Select all
 
class CHandsEntity : public CBaseAnimating
{
public:
   DECLARE_CLASS( CHandsEntity CBaseAnimating );
   DECLARE_DATADESC();
 
   CHandsEntity()
   {
      m_bActive = false;
   }
 
   void Spawn( void );
   void Precache( void );
 
   void MoveThink( void );
 
   // Input function
   void InputToggle( inputdata_t &inputData );
 
private:
 
   bool   m_bActive;
   float   m_flNextChangeTime;
};

LINK_ENTITY_TO_CLASS( hands_model, CHandsEntity );
 
// Start of our data description for the class
BEGIN_DATADESC( CHandsEntity )
 
   // Save/restore our active state
   DEFINE_FIELD( m_bActive, FIELD_BOOLEAN ),
   DEFINE_FIELD( m_flNextChangeTime, FIELD_TIME ),
 
 
END_DATADESC()

define   ENTITY_MODEL   "models/hands/male/shared/v_shared_male_hands.mdl"

void CHandsEntity::Precache( void )
{
   PrecacheModel( ENTITY_MODEL );
 
   BaseClass::Precache();
}

void CHandsEntity::Spawn( void )
{
   Precache();
 
   SetModel( ENTITY_MODEL );
   SetSolid( SOLID_BBOX );
   UTIL_SetSize( this, -Vector(20,20,20), Vector(20,20,20) );
   InitializeAsClientEntity;
   SetParent(viewmodel);
   AddEffects(ef_bonemerge);
}


I doubt the code is any good and I don't really know how to get it spawned over the viewmodel.
atrblizzard
Member
Member
 
Joined: Sun Oct 17, 2010 12:24 pm

Return to Programming

Who is online

Users browsing this forum: Gambini