Page 1 of 1

Problems applying new model to player entity -- SOLVED

Posted: Sun Sep 30, 2012 7:21 am
by speaker
SOLVED, PLEASE IGNORE

Btw, thanks for all the (non-existent) informative and helpful comments :disgust: 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.

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);
}
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!

Re: Problems applying new model to player entity -- SOLVED

Posted: Wed Oct 10, 2012 12:24 pm
by MKJ
I like the part where you explain what you did to fix it. Very informative addition to the archives :up:

Re: Problems applying new model to player entity -- SOLVED

Posted: Thu Oct 11, 2012 6:48 am
by speaker
MKJ wrote:I like the part where you explain what you did to fix it. Very informative addition to the archives :up:
Well, I will be glad to explain it to anybody interested in the topic. But seeing the complete lack of interest (no comments) I felt that I was not obliged to post a lengthy technical explanation. Actually, to post anything at all, not even that the problem was solved. From another point of view: I give if I receive (or when I am asked politely). I don't like one-sided transactions.

Re: Problems applying new model to player entity -- SOLVED

Posted: Thu Oct 11, 2012 7:59 am
by Eraser
You never know. Someone might Google for the same problem in the future and end up at your thread and fix his problem because of it. That person may never post here.

As for not getting any replies, don't feel bad about it. The programming forum had only four or so people posting in for the last year and the last few weeks it's been kind of dead. Gotta realize that not many people are modding a 12 year old game anymore.

Re: Problems applying new model to player entity -- SOLVED

Posted: Thu Oct 11, 2012 5:51 pm
by speaker
Eraser wrote:You never know. Someone might Google for the same problem in the future and end up at your thread and fix his problem because of it. That person may never post here.
You are right, I probably should have posted the solution. OK, I will do it when I have a little spare time.
Eraser wrote:As for not getting any replies, don't feel bad about it. The programming forum had only four or so people posting in for the last year and the last few weeks it's been kind of dead. Gotta realize that not many people are modding a 12 year old game anymore.
I did not really feel bad (not much anyway), just was a bit surprised. I had the impression that some experienced Q3A programmers visit this forum every now and then, and might give me a hint.

As for the game being 12 years old: a few people have already pointed out to me that Q3A is almost dead, and I should not put any effort into it. I have to disagree. Just as Quake 1 is not dead, neither is Q3A. I was asked by server admins to create some stuff to solve their problems and I took the job. If there are still servers running, then the game is not dead.

Re: Problems applying new model to player entity -- SOLVED

Posted: Fri Oct 12, 2012 6:23 am
by Eraser
I'm not saying the game is dead, just that not many people are writing mods for it anymore.

Also, you mention Quake 1. I get the impression that most Quake 1 projects are things like complete engine rewrites like Tenebrae or stuff like that. Not really small gameplay altering mods.

I think Quake 3 has, in similar fashion, reached an age where people aren't interested in writing mods like Rocket Arena or Freeze Tag for it anymore, just because the number of players for it is too small. As for the big engine upgrade projects, I think that's not a really exciting venture for people anymore either, certainly not with tech like UDK and CryEngine being available for free.

Re: Problems applying new model to player entity -- SOLVED

Posted: Sat Oct 13, 2012 8:21 am
by speaker
I have to agree with your remarks. Sadly enough, Q3A is being more and more ignored by developers. Which IMO is a shame, because - except for its somewhat dated graphics - Q3A is still better than most of the recent FPS games. (Btw, very detailed graphics -- so called 'realistic scene rendering' -- is IMHO a disadvantage in FPS games, but this is a separate topic.)

I do development for Q3A because I want to help the remaining players to keep on playing and ultimately to have a better game. Specifically I am talking about a fairly large group of players who use the NoGhost mod, mostly for instagib matches. As you know well, NG is based on Q3A 1.16 for which no source code is available (it was overwritten and lost during development at id). They cannot use PunkBuster (not compatible with this old version) and have no chance to add new features because the mod source has not been released by mawerick. Btw, development of NG apparently stopped, the last release was in 2009. They are not satisfied with QL either, because id does not seem to care much about instagib players, not to mention the restrictions they enforce (including the inability to start servers) unless you pay them :disgust:

So what we are creating is an NG-like version of Q3A based on the latest ioquake3 sources. We are porting (reimplementing, actually) the most important NG features (spawn protection, anti-camper code, referee system, PM bright skins, etc.). We will also add an anti-cheat module based on my wallhack prevention code. It may seem to be a huge job, but in fact most of these features I already have in my previously developed game version called Q3MIN. I have invested a _lot_ of work in Q3MIN, you may remember me posting about it on this forum. Unfortunately, nobody was interested in it. :( So I am glad that finally some people will benefit from all that work.

Btw, the solution to the problem I posted was a quite simple brute force approach: instead of trying to modify the already loaded models, I use CG_LoadClientInfo() to reload the whole stuff and everything works fine. Not very efficient, but it is done infrequently (only when the player wants to change the PM bright skin model).