Ok thanks a lot Spike, it worked!
1) removed send field .skeletonindex from ssqc to csqc
2) in CSQC_Ent_Update added
Code: Select all
local float mdli = readbyte();
setmodelindex(self,mdli);
instead of reading self.modeling=readbyte();
Thanks! Now I've last problem and it seems that it's related to the original issue: understand how the active player works. When I move the mouse, the player, in third person view, bends his spine.
I'm creating a spine bending animation based on input_angles.
I used 2 methods and both gave same result: when I launch a dedicated server and I connect to it more than 1 client, if I (in first person view) bend the visual, all the other clients present in the map (but in the same client window) bend their spines(all of them)!
But if I look at the other client windows (when I test my game I place all the client windows one near the other) all the players are not bending their spines! So, only the clients (not the active one) inside the active window bend their spines when active player moves mouse on Y axis! What a mess!!
FIRST METHOD (PREDRAW)
I tried creating the skeletal code in the predraw function following your indications on specs/skeletal.txt
Code: Select all
float Predraw_Player()
{
self.angles_x = 0;//avoid the rotation of the whole model on x axis while mouse moves(we'll use skel_mul_bone for rotate only spine and head)
if (!self.skeletonindex){//|| isnotskeletal(self)
self.skeletonindex = skel_create(self.modelindex);
skel_build(self.skeletonindex, self, self.modelindex, 0, 0, 0, 1);
addentity(self);
}
float spine = skel_find_bone(self.skeletonindex, "spine");
float spine2 = skel_find_bone(self.skeletonindex, "spine2");
float foot_l = skel_find_bone(self.skeletonindex,"foot_l");
float neck = skel_find_bone(self.skeletonindex,"neck");
float head = skel_find_bone(self.skeletonindex,"head");
float hand_l = skel_find_bone(self.skeletonindex,"hand_l");
float lastbone = 38;
float bones = skel_get_numbones(self.skeletonindex);
skel_build(self.skeletonindex, self, self.modelindex, 0, spine2,hand_l, 1);
gettaginfo(self, spine2); //set v_forward, v_right, v_up. discard world coord
local vector spineang = vectoangles(v_forward, v_up);
makevectors([0, 0, -input_angles_x - spineang_z]);
skel_mul_bone(self.skeletonindex, spine2, '0 0 0');
skel_build(self.skeletonindex, self, self.modelindex, 0, spine, foot_l, 1);
PlayerModelMovements();
return PREDRAW_AUTOADD;
}
SECOND METHOD (CSQC_UpdateView)
I also tried same thing, but instead of using predraw (because I thought it was a wrong place to place skeletal animation) I created a function with an entity parameters called in CSQC_UpdateView
Code: Select all
void PlayerModelMovements2(entity ent)
{
float vell = vlen(ent.velocity);
ent.frame1time += frametime;
if(vell <= 0){
ent.frame = 0;
}
else if(vell > 0 && vell < 10){
ent.frame = 1;
}
else if(vell > 10){
ent.frame = 2;
}
}
void AnimatePlayer(entity ent)
{
float spine = skel_find_bone(ent.skeletonindex, "spine");
float spine2 = skel_find_bone(ent.skeletonindex, "spine2");
float foot_l = skel_find_bone(ent.skeletonindex,"foot_l");
float hand_l = skel_find_bone(ent.skeletonindex,"hand_l");
float lastbone = 38;
skel_build(ent.skeletonindex, ent, ent.modelindex, 0, spine2,hand_l, 1);
gettaginfo(ent, spine2); //set v_forward, v_right, v_up. discard world coord
local vector spineang = vectoangles(v_forward, v_up); //convert the orientation to eular angles. lets hope its correctly normalised (in which case v_right is surplus to requirements).
makevectors([0, 0, -input_angles_x - spineang_z]);
skel_mul_bone(ent.skeletonindex, spine2, '0 0 0');
skel_build(ent.skeletonindex, ent, ent.modelindex, 0, spine, foot_l, 1);
PlayerModelMovements2(ent);
}
Then, I changed my Startup_Player function (called by CSQC_EntUpdate) to add here the skel_create, instead of placing it in predraw
Code: Select all
void Startup_Player(float newent)
{
if (newent)
{
if (self.entnum == player_localentnum){
playerActive = self;
self.renderflags = RF_EXTERNALMODEL;
}
else{
self.renderflags = 0;
}
if (!self.skeletonindex){
self.skeletonindex = skel_create(self.modelindex);
skel_build(self.skeletonindex, self, self.modelindex, 0, 0, 0, 1);
addentity(self);
}
self.classname = "player";
self.drawmask = MASK_NORMAL; // makes the entity visible
}
}
I created finally a UpdatePlayer function where to identify the subject of skeletal animation (the player)
Code: Select all
void UpdatePlayer()
{
local entity ent;
ent = nextent(world);
while (ent)
{
if (ent.classname == "player")
{
AnimatePlayer (ent);
}
ent = nextent(ent);
}
}
And I put UpdatePlayer in CSQC_UpdateView, BEFORE clearscene
None of this 2 methods solve the problem. If I remove the spine skeletal stuff and I retest with multiple windows, players behave correctly: only the active player bends(the whole model,obviously) in other client windows, while the active camera rotates. So it's of course an error of mine when I created the bending code but I can't figure out where's my mistake
Thanks a lot Spike, you're helping me so much!