My first foray into the world of Skeletal Animation, and for my first project, I've decided to start with (what I thought would be) the simple task of making a (skeletal) model's head turn to match the players POV. Unfortunately, in spite of all the new code, I cant see any difference. Here's the story so far (this is all CSQC):
1. In CSQC_Init, we intercept the (SSQC) player model
Code: Select all
deltalisten("progs/player.mdl", UpdatePlayer, 0);
2. In UpdatePlayer:
Code: Select all
float(float isnew) UpdatePlayer =
{
setmodel(self, IQM_TEST_BOD);
if(isnew)
{
// make the skeleton
self.skeletonobject = skel_create(self.modelindex);
PrintSkelInfo(); // a diagnostic function which proves the bones are there (see below)
self.predraw = PlayerPredraw;
}
// trying to make the head spin using a global number. Why? Because since the whole model moves when the player turns, I wasn't sure if the head was moving or not, so this is just a way to get *any* indication that the skel is being rendered
if(global_float > 360)
global_float = 0;
else
global_float+= 1;
vector a_vec;
a_vec_x = global_float; // I tried a_vec_y as well, no diff
makevectors(self.angles); // not sure this is even needed
//makevectors([-self.v_angle_x*0.2, 0, 0]); // copied from toneddu200's (working?) code - no diff
// I suspect this line might be the problem:
skel_set_bone_world (self, 24, self.origin); // 24 is the head bone, proved by PrintSkelInfo()
//skel_set_bone_world (self, 24, v_forward + v_up); no diff
self.drawmask = 1; // draw self
// is self the local player?
if (self.entnum == player_localentnum)
self.renderflags = RF_EXTERNALMODEL; // dont draw it
else
self.renderflags = 0;
return TRUE;
}
Code: Select all
float () PlayerPredraw =
{
skel_build(self.skeletonindex, self, self.modelindex, 0, 23, 25); // 24 is the head bone
// also tried:
// skel_build(self.skeletonindex, self, self.modelindex, 0, 24, 24, 1);
//self.drawmask = MASK_ENGINE;
//return TRUE; // cant see the player with this
return PREDRAW_AUTOADD;
}
Possibility 1. The skel head isn't being rotated. Either skel_set_bone_world is being called incorrectly .. or maybe there's some problem with the way the bones were set up in the (Captn Bubs Quake1 replacement) model, which I exported as an IQM ( download it from here if you want to check it out)
Possibility 2. The head IS being rotated, but something, somewhere else is overriding the info. Or maybe skel_build isn't passing on the info to the head bone.
Possibility 3. The skeleton's animations are not being rendered ie something wrong/missing in PlayerPredraw
Diagnostics do seem to indicate that the head bone is NOT moving (http://pastebin.com/UcDDxMRH)
any response appreciated
OneManClan
ps: the following function PrintSkelInfo() prints all the bones in an IQM, and their parents. Output shows that the bones *are* being read:
Code: Select all
void (entity e) PrintSkelInfo =
{
string bone_name, parent_name;
// how many bones?
float num_of_bones = skel_get_numbones(e.skeletonobject);
print(e.classname, " has ", ftos(num_of_bones), "bones:\n");
// print all the bone names
for(float i = 0; i < num_of_bones; i++)
{
bone_name = skel_get_bonename(e.skeletonobject, i);
parent_name = skel_get_bonename(e.skeletonobject, skel_get_boneparent(e.skeletonobject, i));
print(ftos(i), ": ", bone_name, ". Parent: ", parent_name, "\n");
}
}