FTEQW - check active player view
Posted: Mon Mar 09, 2015 1:05 am
Hi guys! I would like to display full skeletal player if view is not in first person and displaying hands model(for now just display a null model) if view is the active one (I'm looking through player's view camera). But I cannot understand how to display player model, seen from an external view (for example when a player sees another player)
I only be able to hemi-accomplished this on predraw function but I think it's not the right place to put this, right?
Should it be placed in CSQC_Update_View(), right?
then I added, in StartupPlayer() function
In CSQC_Ent_Update I called Startup_Player
My CSQC_Update_View
But If I remove the code in PredrawPlayer
Camerais not connected to player entity anymore (Maybe I should put this check in CSQC_UpdateView)and whole player model is displayed even in fps.
Where am I wrong?
Thanks a bunch in advance guys!
I only be able to hemi-accomplished this on predraw function but I think it's not the right place to put this, right?
Code: Select all
// in PredrawPlayer function
if (self.entnum == player_localentnum){
playeViewOrigin = self.origin; //without this, camera is not connected to player entity anymore!!
setmodel(self,"");//no whole person model
}
then I added, in StartupPlayer() function
Code: Select all
void Startup_Player(float newent)
{
if (newent)
{
if (self.entnum == player_localentnum){
playerActive = self;
setmodel(self,"");//display no model
}
else{
setmodel(self,PLAYER_MODEL);//display whole model
}
self.classname = "player";
self.drawmask = MASK_NORMAL; // makes the entity visible
}
}
Code: Select all
void CSQC_Ent_Update (float isnew)
{
local float i = readbyte();
if (i == ENT_PLAYER){
//read here all send values from client.c in ssqc
//movements
self.origin_x = readcoord();
self.origin_y = readcoord();
self.origin_z = readcoord();
self.angles_x = readcoord();
self.angles_y = readcoord();
self.angles_z = readcoord();
self.velocity_x = readcoord();
self.velocity_y = readcoord();
self.velocity_z = readcoord();
//additionals
self.modelindex = readbyte();
self.skeletonindex = readbyte();
//functions
self.drawmask = MASK_NORMAL;
self.predraw = Predraw_Player;
Startup_Player(isnew);
}
}
Code: Select all
void CSQC_UpdateView(float vwidth, float vheight, float notmenu)
{
clearscene();
if (playerActive){
setviewprop(VF_ORIGIN, playeViewOrigin + PLAYER_HEIGHT);//player position frame by frame
setviewprop(VF_ANGLES, view_angles); //player orientation frame by frame
makevectors(view_angles);
SetListener(playeViewOrigin, v_forward, v_right, v_up);
setviewprop(VF_DRAWCROSSHAIR,1);
}
else{
addentities(MASK_VIEWMODEL);
}
addentities(MASK_NORMAL|MASK_ENGINE); //withoutMASK_ENGINE, map entities models won't be displayed!
renderscene();
}
Code: Select all
if (self.entnum == player_localentnum){
playeViewOrigin = self.origin; //without this, when another client connects, player active view becomes crazy.
setmodel(self,"");//no whole person model
}
Where am I wrong?
Thanks a bunch in advance guys!