Client: add a vertical camera bobbing effect.
This commit is contained in:
parent
bef240a1de
commit
0452916719
3 changed files with 61 additions and 7 deletions
|
@ -77,3 +77,15 @@ Camera_StrafeRoll(__inout vector camera_angle)
|
|||
|
||||
camera_angle[2] += roll;
|
||||
}
|
||||
|
||||
float Viewmodel_GetBob(void);
|
||||
|
||||
/* tilts the camera for a head-bob like effect when moving */
|
||||
void
|
||||
Camera_RunPosBob(vector angles, __inout vector camera_pos)
|
||||
{
|
||||
int s = (float)getproperty(VF_ACTIVESEAT);
|
||||
pCamBob = &g_camBobVars[s];
|
||||
makevectors(view_angles);
|
||||
camera_pos += (v_up * Viewmodel_GetBob());
|
||||
}
|
||||
|
|
|
@ -81,6 +81,14 @@ Viewmodel_CalcBob(void)
|
|||
pViewBob->m_flBob *= autocvar_cg_viewmodelScale;
|
||||
}
|
||||
|
||||
float
|
||||
Viewmodel_GetBob(void)
|
||||
{
|
||||
int s = (float)getproperty(VF_ACTIVESEAT);
|
||||
pViewBob = &g_viewBobVars[s];
|
||||
return pViewBob->m_flBob;
|
||||
}
|
||||
|
||||
void
|
||||
Viewmodel_ApplyBob(entity gun)
|
||||
{
|
||||
|
|
|
@ -157,14 +157,15 @@ class player:NSClientPlayer
|
|||
//virtual float() predraw;
|
||||
//virtual void(void) postdraw;
|
||||
virtual void UpdatePlayerAttachments(bool);
|
||||
virtual void(float,float) ReceiveEntity;
|
||||
virtual void(void) PredictPreFrame;
|
||||
virtual void(void) PredictPostFrame;
|
||||
virtual void ReceiveEntity(float,float);
|
||||
virtual void PredictPreFrame(void);
|
||||
virtual void PredictPostFrame(void);
|
||||
virtual void UpdateAliveCam(void);
|
||||
#else
|
||||
virtual void(void) EvaluateEntity;
|
||||
virtual float(entity, float) SendEntity;
|
||||
virtual void(float) Save;
|
||||
virtual void(string,string) Restore;
|
||||
virtual void EvaluateEntity(void);
|
||||
virtual float SendEntity(entity, float);
|
||||
virtual void Save(float);
|
||||
virtual void Restore(string,string);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -181,6 +182,39 @@ player::UpdatePlayerAnimation(float timelength)
|
|||
}
|
||||
|
||||
#ifdef CLIENT
|
||||
void Camera_RunPosBob(vector angles, __inout vector camera_pos);
|
||||
void Camera_StrafeRoll(__inout vector camera_angle);
|
||||
void Shake_Update(NSClientPlayer);
|
||||
|
||||
void
|
||||
player::UpdateAliveCam(void)
|
||||
{
|
||||
vector cam_pos = GetEyePos();
|
||||
Camera_RunPosBob(view_angles, cam_pos);
|
||||
|
||||
g_view.SetCameraOrigin(cam_pos);
|
||||
Camera_StrafeRoll(view_angles);
|
||||
g_view.SetCameraAngle(view_angles);
|
||||
|
||||
if (vehicle) {
|
||||
NSVehicle veh = (NSVehicle)vehicle;
|
||||
|
||||
if (veh.UpdateView)
|
||||
veh.UpdateView();
|
||||
} else if (health) {
|
||||
if (autocvar_pm_thirdPerson == TRUE) {
|
||||
makevectors(view_angles);
|
||||
vector vStart = [pSeat->m_vecPredictedOrigin[0], pSeat->m_vecPredictedOrigin[1], pSeat->m_vecPredictedOrigin[2] + 16] + (v_right * 4);
|
||||
vector vEnd = vStart + (v_forward * -48) + [0,0,16] + (v_right * 4);
|
||||
traceline(vStart, vEnd, FALSE, this);
|
||||
g_view.SetCameraOrigin(trace_endpos + (v_forward * 5));
|
||||
}
|
||||
}
|
||||
|
||||
Shake_Update(this);
|
||||
g_view.AddPunchAngle(punchangle);
|
||||
}
|
||||
|
||||
.string oldmodel;
|
||||
string Weapons_GetPlayermodel(player, int);
|
||||
|
||||
|
|
Loading…
Reference in a new issue