Problems applying new model to player entity -- SOLVED
Posted: Sun Sep 30, 2012 7:21 am
SOLVED, PLEASE IGNORE
Btw, thanks for all the (non-existent) informative and helpful comments
Honestly, I expected a better response on this forum.
-------------------------------------------
Hi,
I have a problem with player models. I want to change the player model ingame when a certain Cvar changes value. The code I refer to here is in 'cgame/cg_player.c'.
The parameters of the available models (models, skins and animation) are preloaded at level start into an array called 'newmodel'. When a Cvar change is detected, I copy the appropriate data from this array to the clientinfo structure of the player and reset the player entity.
The result is that the new model is applied, but the animation is messed up (wrong leg and torso movement, etc.).
My development system:
Window 7 Ultimate 64-bit
MinGW/Msys
So please, tell me what is wrong with this code. Did I miss something important?
Thanks!
Btw, thanks for all the (non-existent) informative and helpful comments

-------------------------------------------
Hi,
I have a problem with player models. I want to change the player model ingame when a certain Cvar changes value. The code I refer to here is in 'cgame/cg_player.c'.
The parameters of the available models (models, skins and animation) are preloaded at level start into an array called 'newmodel'. When a Cvar change is detected, I copy the appropriate data from this array to the clientinfo structure of the player and reset the player entity.
Code: Select all
typedef struct
{
int valid;
qhandle_t model[3];
qhandle_t skin[3];
qboolean fixedlegs;
qboolean fixedtorso;
vec3_t headOffset;
footstep_t footsteps;
gender_t gender;
animation_t animations[MAX_TOTALANIMATIONS];
} newmodel_t;
newmodel_t newmodel[NEW_MODEL_NUM];
enum { MOD_LEGS, MOD_TORSO, MOD_HEAD };
void
CG_SetModel(centity_t *cent, clientInfo_t *ci, int modelindex)
{
ci->legsModel = newmodel[modelindex].model[MOD_LEGS];
ci->torsoModel = newmodel[modelindex].model[MOD_TORSO];
ci->headModel = newmodel[modelindex].model[MOD_HEAD];
ci->legsSkin = newmodel[modelindex].skin[MOD_LEGS];
ci->torsoSkin = newmodel[modelindex].skin[MOD_TORSO];
ci->headSkin = newmodel[modelindex].skin[MOD_HEAD];
ci->fixedlegs = newmodel[modelindex].fixedlegs;
ci->fixedtorso = newmodel[modelindex].fixedtorso;
VectorCopy(newmodel[modelindex].headOffset, ci->headOffset);
ci->footsteps = newmodel[modelindex].footsteps;
ci->gender = newmodel[modelindex].gender;
memcpy(ci->animations, newmodel[modelindex].animations, sizeof(ci->animations));
CG_ResetPlayerEntity(cent);
}
My development system:
Window 7 Ultimate 64-bit
MinGW/Msys
So please, tell me what is wrong with this code. Did I miss something important?
Thanks!