2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2012-05-20 10:17:41 +00:00
|
|
|
cl_view.c
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
player eye positioning
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/msg.h"
|
2001-04-15 08:04:15 +00:00
|
|
|
#include "QF/screen.h"
|
2001-05-13 22:57:27 +00:00
|
|
|
|
2022-02-28 03:12:51 +00:00
|
|
|
#include "QF/plugin/vid_render.h"
|
|
|
|
#include "QF/scene/transform.h"
|
2021-03-11 07:19:49 +00:00
|
|
|
#include "QF/simd/vec4f.h"
|
|
|
|
|
2001-08-07 18:53:22 +00:00
|
|
|
#include "compat.h"
|
2021-03-12 02:48:53 +00:00
|
|
|
|
2022-02-22 06:23:09 +00:00
|
|
|
#include "client/chase.h"
|
2022-02-28 03:12:51 +00:00
|
|
|
#include "client/entities.h"
|
|
|
|
#include "client/hud.h"
|
|
|
|
#include "client/input.h"
|
|
|
|
#include "client/view.h"
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "client/world.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-05-30 20:55:28 +00:00
|
|
|
The view is allowed to move slightly from it's true position for bobbing,
|
|
|
|
but if it exceeds 8 pixels linear distance (spherical, not box), the list
|
|
|
|
of entities sent from the server may not include everything in the pvs,
|
|
|
|
especially when crossing a water boudnary.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
|
|
|
|
2012-05-31 23:19:22 +00:00
|
|
|
cvar_t *scr_ofsx;
|
|
|
|
cvar_t *scr_ofsy;
|
|
|
|
cvar_t *scr_ofsz;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *cl_rollspeed;
|
|
|
|
cvar_t *cl_rollangle;
|
|
|
|
|
|
|
|
cvar_t *cl_bob;
|
|
|
|
cvar_t *cl_bobcycle;
|
|
|
|
cvar_t *cl_bobup;
|
|
|
|
|
2001-08-07 18:53:22 +00:00
|
|
|
cvar_t *v_centermove;
|
|
|
|
cvar_t *v_centerspeed;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *v_kicktime;
|
|
|
|
cvar_t *v_kickroll;
|
|
|
|
cvar_t *v_kickpitch;
|
|
|
|
|
2022-02-28 03:12:51 +00:00
|
|
|
cvar_t *cl_cshift_bonus;
|
|
|
|
cvar_t *cl_cshift_contents;
|
|
|
|
cvar_t *cl_cshift_damage;
|
|
|
|
cvar_t *cl_cshift_powerup;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *v_iyaw_cycle;
|
|
|
|
cvar_t *v_iroll_cycle;
|
|
|
|
cvar_t *v_ipitch_cycle;
|
|
|
|
cvar_t *v_iyaw_level;
|
|
|
|
cvar_t *v_iroll_level;
|
|
|
|
cvar_t *v_ipitch_level;
|
|
|
|
|
|
|
|
cvar_t *v_idlescale;
|
|
|
|
|
2001-05-20 00:34:40 +00:00
|
|
|
float v_dmg_time, v_dmg_roll, v_dmg_pitch;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t v_idle_yaw;
|
|
|
|
vec4f_t v_idle_roll;
|
|
|
|
vec4f_t v_idle_pitch;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
static cshift_t cshift_empty = { {130, 80, 50}, 0};
|
|
|
|
static cshift_t cshift_water = { {130, 80, 50}, 128};
|
|
|
|
static cshift_t cshift_slime = { { 0, 25, 5}, 150};
|
|
|
|
static cshift_t cshift_lava = { {255, 80, 0}, 150};
|
|
|
|
static cshift_t cshift_bonus = { {215, 186, 60}, 50};
|
|
|
|
|
|
|
|
static cshift_t armor_blood[] = {
|
|
|
|
{ {255, 0, 0} }, // blood
|
|
|
|
{ {220, 50, 50} }, // armor + blood
|
|
|
|
{ {200, 100, 100} }, // armor > blood need two for logic
|
|
|
|
{ {200, 100, 100} }, // armor > blood need two for logic
|
|
|
|
};
|
|
|
|
|
|
|
|
static cshift_t powerup[] = {
|
|
|
|
{ { 0, 0, 0}, 0},
|
|
|
|
{ {100, 100, 100}, 100}, // IT_INVISIBILITY
|
|
|
|
{ {255, 255, 0}, 30}, // IT_INVULNERABILITY
|
|
|
|
{ {255, 255, 0}, 30}, // IT_INVULNERABILITY
|
|
|
|
{ { 0, 255, 0}, 20}, // IT_SUIT
|
|
|
|
{ { 0, 255, 0}, 20}, // IT_SUIT
|
|
|
|
{ { 0, 255, 0}, 20}, // IT_SUIT
|
|
|
|
{ { 0, 255, 0}, 20}, // IT_SUIT
|
|
|
|
{ { 0, 0, 255}, 30}, // IT_QUAD
|
|
|
|
{ { 0, 0, 255}, 30}, // IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
{ {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD
|
|
|
|
};
|
2001-05-13 22:57:27 +00:00
|
|
|
|
2012-06-02 04:43:25 +00:00
|
|
|
#define sqr(x) ((x) * (x))
|
2001-08-28 23:05:45 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
float
|
2021-03-12 02:48:53 +00:00
|
|
|
V_CalcRoll (const vec3_t angles, vec4f_t velocity)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2012-05-21 13:00:58 +00:00
|
|
|
float side, sign, value;
|
|
|
|
vec3_t forward, right, up;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
AngleVectors (angles, forward, right, up);
|
|
|
|
side = DotProduct (velocity, right);
|
|
|
|
sign = side < 0 ? -1 : 1;
|
|
|
|
side = fabs (side);
|
|
|
|
|
|
|
|
value = cl_rollangle->value;
|
|
|
|
|
|
|
|
if (side < cl_rollspeed->value)
|
|
|
|
side = side * value / cl_rollspeed->value;
|
|
|
|
else
|
|
|
|
side = value;
|
|
|
|
|
|
|
|
return side * sign;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static float
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcBob (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
vec4f_t velocity = vs->velocity;
|
2011-06-19 10:04:49 +00:00
|
|
|
float cycle;
|
2012-06-02 04:43:25 +00:00
|
|
|
static double bobtime;
|
2011-06-19 10:04:49 +00:00
|
|
|
static float bob;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (!vs->bob_enabled)
|
2001-02-19 21:15:25 +00:00
|
|
|
return 0;
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->onground == -1)
|
2001-02-19 21:15:25 +00:00
|
|
|
return bob; // just use old value
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
bobtime += vs->frametime;
|
2001-08-28 23:05:45 +00:00
|
|
|
cycle = bobtime - (int) (bobtime / cl_bobcycle->value) *
|
|
|
|
cl_bobcycle->value;
|
2001-02-19 21:15:25 +00:00
|
|
|
cycle /= cl_bobcycle->value;
|
|
|
|
if (cycle < cl_bobup->value)
|
2012-06-02 04:43:25 +00:00
|
|
|
cycle = cycle / cl_bobup->value;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2012-06-02 04:43:25 +00:00
|
|
|
cycle = 1 + (cycle - cl_bobup->value) / (1.0 - cl_bobup->value);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-02 04:43:25 +00:00
|
|
|
// bob is proportional to velocity in the xy plane
|
2001-08-25 02:47:11 +00:00
|
|
|
// (don't count Z, or jumping messes it up)
|
2021-03-11 07:19:49 +00:00
|
|
|
velocity[2] = 0;
|
|
|
|
bob = sqrt (dotf (velocity, velocity)[0]) * cl_bob->value;
|
2012-06-02 04:43:25 +00:00
|
|
|
bob = bob * 0.3 + bob * 0.7 * sin (cycle * M_PI);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (bob > 4)
|
|
|
|
bob = 4;
|
|
|
|
else if (bob < -7)
|
|
|
|
bob = -7;
|
|
|
|
return bob;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_StartPitchDrift (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->laststop == vs->time) {
|
2001-08-25 02:47:11 +00:00
|
|
|
return; // something else is keeping it from drifting
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-08-25 02:47:11 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->nodrift || !vs->pitchvel) {
|
|
|
|
vs->pitchvel = v_centerspeed->value;
|
|
|
|
vs->nodrift = false;
|
|
|
|
vs->driftmove = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
static void
|
|
|
|
V_StartPitchDrift_f (void *data)
|
|
|
|
{
|
|
|
|
V_StartPitchDrift (data);
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_StopPitchDrift (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->laststop = vs->time;
|
|
|
|
vs->nodrift = true;
|
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_DriftPitch
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
Moves the client pitch angle towards vs->idealpitch sent by the server.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
If the user is adjusting pitch manually, either with lookup/lookdown,
|
|
|
|
mlook and mouse, or klook and keyboard, pitch drifting is constantly
|
|
|
|
stopped.
|
|
|
|
|
|
|
|
Drifting is enabled when the center view key is hit, mlook is released
|
2012-05-21 23:23:22 +00:00
|
|
|
and lookspring is non 0, or when
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DriftPitch (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-06-18 13:22:47 +00:00
|
|
|
float delta, move;
|
2022-02-25 06:48:57 +00:00
|
|
|
float forwardmove = vs->movecmd[0];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (noclip_anglehack || vs->onground == -1 || !vs->drift_enabled) {
|
|
|
|
vs->driftmove = 0;
|
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-05-13 22:57:27 +00:00
|
|
|
|
|
|
|
// don't count small mouse motion
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->nodrift) {
|
2021-03-19 11:18:45 +00:00
|
|
|
if (fabs (forwardmove) < cl_forwardspeed->value)
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->driftmove = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->driftmove += vs->frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->driftmove > v_centermove->value) {
|
|
|
|
V_StartPitchDrift (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-01 02:43:23 +00:00
|
|
|
delta = vs->idealpitch - vs->player_angles[PITCH];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!delta) {
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
move = vs->frametime * vs->pitchvel;
|
|
|
|
vs->pitchvel += vs->frametime * v_centerspeed->value;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (delta > 0) {
|
|
|
|
if (move > delta) {
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
move = delta;
|
|
|
|
}
|
2022-03-01 02:43:23 +00:00
|
|
|
vs->player_angles[PITCH] += move;
|
2001-02-19 21:15:25 +00:00
|
|
|
} else if (delta < 0) {
|
|
|
|
if (move > -delta) {
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->pitchvel = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
move = -delta;
|
|
|
|
}
|
2022-03-01 02:43:23 +00:00
|
|
|
vs->player_angles[PITCH] -= move;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
/* PALETTE FLASHES */
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void
|
2022-02-28 03:12:51 +00:00
|
|
|
V_ParseDamage (qmsg_t *net_message, viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-06-19 10:04:49 +00:00
|
|
|
float count, side;
|
|
|
|
int armor, blood;
|
2022-03-01 02:43:23 +00:00
|
|
|
vec4f_t origin = vs->player_origin;
|
|
|
|
vec_t *angles = vs->player_angles;
|
2011-06-19 10:04:49 +00:00
|
|
|
vec3_t from, forward, right, up;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
armor = MSG_ReadByte (net_message);
|
|
|
|
blood = MSG_ReadByte (net_message);
|
2011-06-18 13:22:47 +00:00
|
|
|
MSG_ReadCoordV (net_message, from);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
count = blood * 0.5 + armor * 0.5;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (count < 10)
|
|
|
|
count = 10;
|
|
|
|
|
|
|
|
if (cl_cshift_damage->int_val
|
2022-02-25 06:48:57 +00:00
|
|
|
|| (vs->force_cshifts & INFO_CSHIFT_DAMAGE)) {
|
|
|
|
cshift_t *cshift = &vs->cshifts[CSHIFT_DAMAGE];
|
|
|
|
int percent = cshift->percent;
|
|
|
|
*cshift = armor_blood[(2 * (armor > blood)) + (armor > 0)];
|
|
|
|
cshift->percent = percent + 3 * count;
|
|
|
|
cshift->percent = bound (0, cshift->percent, 150);
|
2012-06-11 12:01:45 +00:00
|
|
|
cshift->initialpct = cshift->percent;
|
2022-02-25 06:48:57 +00:00
|
|
|
cshift->time = vs->time;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-05-13 22:57:27 +00:00
|
|
|
|
|
|
|
// calculate view angle kicks
|
2012-06-02 10:46:57 +00:00
|
|
|
VectorSubtract (from, origin, from);
|
2001-11-07 08:24:56 +00:00
|
|
|
VectorNormalize (from);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-02 10:46:57 +00:00
|
|
|
AngleVectors (angles, forward, right, up);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
side = DotProduct (from, right);
|
2001-02-19 21:15:25 +00:00
|
|
|
v_dmg_roll = count * side * v_kickroll->value;
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
side = DotProduct (from, forward);
|
2001-02-19 21:15:25 +00:00
|
|
|
v_dmg_pitch = count * side * v_kickpitch->value;
|
|
|
|
|
|
|
|
v_dmg_time = v_kicktime->value;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
V_cshift_f (void)
|
|
|
|
{
|
|
|
|
cshift_empty.destcolor[0] = atoi (Cmd_Argv (1));
|
|
|
|
cshift_empty.destcolor[1] = atoi (Cmd_Argv (2));
|
|
|
|
cshift_empty.destcolor[2] = atoi (Cmd_Argv (3));
|
|
|
|
cshift_empty.percent = atoi (Cmd_Argv (4));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_BonusFlash_f
|
|
|
|
|
|
|
|
When you run over an item, the server sends this command
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_BonusFlash_f (void *data)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
viewstate_t *vs = data;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!cl_cshift_bonus->int_val
|
2022-02-25 06:48:57 +00:00
|
|
|
&& !(vs->force_cshifts & INFO_CSHIFT_BONUS))
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_BONUS] = cshift_bonus;
|
|
|
|
vs->cshifts[CSHIFT_BONUS].initialpct = vs->cshifts[CSHIFT_BONUS].percent;
|
|
|
|
vs->cshifts[CSHIFT_BONUS].time = vs->time;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_SetContentsColor
|
|
|
|
|
|
|
|
Underwater, lava, etc each has a color shift
|
|
|
|
*/
|
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_SetContentsColor (viewstate_t *vs, int contents)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (!cl_cshift_contents->int_val
|
2022-02-25 06:48:57 +00:00
|
|
|
&& !(vs->force_cshifts & INFO_CSHIFT_CONTENTS)) {
|
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_empty;
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (contents) {
|
|
|
|
case CONTENTS_EMPTY:
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_empty;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
case CONTENTS_LAVA:
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_lava;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
case CONTENTS_SOLID:
|
|
|
|
case CONTENTS_SLIME:
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_slime;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_CONTENTS] = cshift_water;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcPowerupCshift (viewstate_t *vs)
|
2001-05-21 19:53:57 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->cshifts[CSHIFT_POWERUP] = powerup[vs->powerup_index];
|
2001-08-10 00:28:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_CalcBlend
|
|
|
|
|
|
|
|
LordHavoc made this a real, true alpha blend. Cleaned it up
|
|
|
|
a bit, but otherwise this is his code. --KB
|
|
|
|
*/
|
2021-03-12 02:48:53 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcBlend (viewstate_t *vs)
|
2001-08-10 00:28:57 +00:00
|
|
|
{
|
2011-06-18 13:22:47 +00:00
|
|
|
float a2, a3;
|
|
|
|
float r = 0, g = 0, b = 0, a = 0;
|
|
|
|
int i;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_CSHIFTS; i++) {
|
2022-02-25 06:48:57 +00:00
|
|
|
a2 = vs->cshifts[i].percent / 255.0;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
if (!a2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
a2 = min (a2, 1.0);
|
2022-02-25 06:48:57 +00:00
|
|
|
r += (vs->cshifts[i].destcolor[0] - r) * a2;
|
|
|
|
g += (vs->cshifts[i].destcolor[1] - g) * a2;
|
|
|
|
b += (vs->cshifts[i].destcolor[2] - b) * a2;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
a3 = (1.0 - a) * (1.0 - a2);
|
|
|
|
a = 1.0 - a3;
|
2001-05-21 19:53:57 +00:00
|
|
|
}
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
// LordHavoc: saturate color
|
|
|
|
if (a) {
|
|
|
|
a2 = 1.0 / a;
|
|
|
|
r *= a2;
|
|
|
|
g *= a2;
|
|
|
|
b *= a2;
|
|
|
|
}
|
|
|
|
|
2022-02-28 07:55:12 +00:00
|
|
|
vs->cshift_color[0] = min (r, 255.0) / 255.0;
|
|
|
|
vs->cshift_color[1] = min (g, 255.0) / 255.0;
|
|
|
|
vs->cshift_color[2] = min (b, 255.0) / 255.0;
|
|
|
|
vs->cshift_color[3] = bound (0.0, a, 1.0);
|
2001-08-10 00:28:57 +00:00
|
|
|
}
|
|
|
|
|
2012-06-11 12:01:45 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DropCShift (cshift_t *cs, double time, float droprate)
|
2012-06-11 12:01:45 +00:00
|
|
|
{
|
|
|
|
if (cs->time < 0) {
|
|
|
|
cs->percent = 0;
|
|
|
|
} else {
|
2022-02-25 06:48:57 +00:00
|
|
|
cs->percent = cs->initialpct - (time - cs->time) * droprate;
|
2012-06-11 12:01:45 +00:00
|
|
|
if (cs->percent <= 0) {
|
|
|
|
cs->percent = 0;
|
|
|
|
cs->time = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-10 00:28:57 +00:00
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_PrepBlend (viewstate_t *vs)
|
2012-05-21 23:23:22 +00:00
|
|
|
{
|
2011-06-18 13:22:47 +00:00
|
|
|
int i, j;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
if (cl_cshift_powerup->int_val
|
2022-02-25 06:48:57 +00:00
|
|
|
|| (vs->force_cshifts & INFO_CSHIFT_POWERUP))
|
|
|
|
V_CalcPowerupCshift (vs);
|
2001-08-10 00:28:57 +00:00
|
|
|
|
2022-03-18 15:56:30 +00:00
|
|
|
qboolean cshift_changed = false;
|
2001-08-10 00:28:57 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_CSHIFTS; i++) {
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->cshifts[i].percent != vs->prev_cshifts[i].percent) {
|
2022-03-18 15:56:30 +00:00
|
|
|
cshift_changed = true;
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->prev_cshifts[i].percent = vs->cshifts[i].percent;
|
2001-08-10 00:28:57 +00:00
|
|
|
}
|
|
|
|
for (j = 0; j < 3; j++) {
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->cshifts[i].destcolor[j] != vs->prev_cshifts[i].destcolor[j])
|
2001-08-28 23:05:45 +00:00
|
|
|
{
|
2022-03-18 15:56:30 +00:00
|
|
|
cshift_changed = true;
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->prev_cshifts[i].destcolor[j] = vs->cshifts[i].destcolor[j];
|
2001-08-10 00:28:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// drop the damage value
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DropCShift (&vs->cshifts[CSHIFT_DAMAGE], vs->time, 150);
|
2001-08-10 00:28:57 +00:00
|
|
|
// drop the bonus value
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DropCShift (&vs->cshifts[CSHIFT_BONUS], vs->time, 100);
|
2001-08-10 00:28:57 +00:00
|
|
|
|
2022-03-18 15:56:30 +00:00
|
|
|
if (!cshift_changed)
|
2001-08-10 00:28:57 +00:00
|
|
|
return;
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcBlend (vs);
|
2001-05-21 19:53:57 +00:00
|
|
|
}
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
/* VIEW RENDERING */
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
CalcGunAngle (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t rotation = Transform_GetWorldRotation (vs->camera_transform);
|
2021-03-19 11:18:45 +00:00
|
|
|
//FIXME make child of camera
|
2022-02-25 06:48:57 +00:00
|
|
|
Transform_SetWorldRotation (vs->weapon_entity->transform, rotation);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2012-05-31 23:19:22 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_BoundOffsets (viewstate_t *vs)
|
2012-05-31 23:19:22 +00:00
|
|
|
{
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t offset = Transform_GetWorldPosition (vs->camera_transform);
|
2022-03-01 02:43:23 +00:00
|
|
|
offset -= vs->player_origin;
|
2012-05-31 23:19:22 +00:00
|
|
|
|
|
|
|
// absolutely bound refresh reletive to entity clipping hull
|
|
|
|
// so the view can never be inside a solid wall
|
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
offset[0] = bound (-14, offset[0], 14);
|
|
|
|
offset[1] = bound (-14, offset[1], 14);
|
|
|
|
offset[2] = bound (-22, offset[2], 30);
|
2022-03-01 02:43:23 +00:00
|
|
|
Transform_SetWorldPosition (vs->camera_transform,
|
|
|
|
vs->player_origin + offset);
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static vec4f_t
|
2022-02-25 06:48:57 +00:00
|
|
|
idle_quat (vec4f_t axis, cvar_t *cycle, cvar_t *level, double time)
|
2021-03-19 11:18:45 +00:00
|
|
|
{
|
|
|
|
vec4f_t identity = { 0, 0, 0, 1 };
|
|
|
|
if (!level || !cycle) {
|
|
|
|
return identity;
|
|
|
|
}
|
2022-02-25 06:48:57 +00:00
|
|
|
float scale = sin (time * cycle->value);
|
2021-03-19 11:18:45 +00:00
|
|
|
float ang = scale * level->value * v_idlescale->value;
|
2021-07-24 02:38:28 +00:00
|
|
|
float c = cos (ang * M_PI / 360);
|
|
|
|
float s = sin (ang * M_PI / 360);
|
2021-03-19 11:18:45 +00:00
|
|
|
return axis * s + identity * c;
|
2012-05-31 23:19:22 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
V_AddIdle
|
|
|
|
|
|
|
|
Idle swaying
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_AddIdle (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t roll = idle_quat ((vec4f_t) { 1, 0, 0, 0},
|
2022-02-25 06:48:57 +00:00
|
|
|
v_iroll_cycle, v_iroll_level, vs->time);
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t pitch = idle_quat ((vec4f_t) { 0, 1, 0, 0},
|
2022-02-25 06:48:57 +00:00
|
|
|
v_ipitch_cycle, v_ipitch_level, vs->time);
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t yaw = idle_quat ((vec4f_t) { 0, 0, 1, 0},
|
2022-02-25 06:48:57 +00:00
|
|
|
v_iyaw_cycle, v_iyaw_level, vs->time);
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t rot = normalf (qmulf (yaw, qmulf (pitch, roll)));
|
|
|
|
|
|
|
|
// rotate the view
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t rotation = Transform_GetWorldRotation (vs->camera_transform);
|
|
|
|
Transform_SetWorldRotation (vs->camera_transform, qmulf (rot, rotation));
|
2021-03-19 11:18:45 +00:00
|
|
|
|
|
|
|
// counter-rotate the weapon
|
|
|
|
rot = qmulf (qconjf (rot),
|
2022-02-25 06:48:57 +00:00
|
|
|
Transform_GetWorldRotation (vs->weapon_entity->transform));
|
|
|
|
Transform_SetWorldRotation (vs->weapon_entity->transform, rot);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_CalcViewRoll
|
|
|
|
|
|
|
|
Roll is induced by movement and damage
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcViewRoll (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-03-01 02:43:23 +00:00
|
|
|
vec_t *angles = vs->player_angles;
|
2022-02-25 06:48:57 +00:00
|
|
|
vec4f_t velocity = vs->velocity;
|
2021-03-19 11:18:45 +00:00
|
|
|
vec3_t ang = { };
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
ang[ROLL] = V_CalcRoll (angles, velocity);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (v_dmg_time > 0) {
|
2021-03-19 11:18:45 +00:00
|
|
|
ang[ROLL] += v_dmg_time / v_kicktime->value * v_dmg_roll;
|
|
|
|
ang[PITCH] += v_dmg_time / v_kicktime->value * v_dmg_pitch;
|
2022-02-25 06:48:57 +00:00
|
|
|
v_dmg_time -= vs->frametime;
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->flags & VF_DEAD) { // VF_GIB will also set VF_DEAD
|
2021-03-19 11:18:45 +00:00
|
|
|
ang[ROLL] = 80; // dead view angle
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t rot;
|
|
|
|
AngleQuat (ang, &rot[0]);//FIXME
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t rotation = Transform_GetWorldRotation (vs->camera_transform);
|
|
|
|
Transform_SetWorldRotation (vs->camera_transform, qmulf (rotation, rot));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcIntermissionRefdef (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
// vs->player_entity is the player model (visible when out of body)
|
|
|
|
entity_t *ent = vs->player_entity;
|
2001-02-19 21:15:25 +00:00
|
|
|
entity_t *view;
|
|
|
|
float old;
|
2021-07-24 02:33:53 +00:00
|
|
|
vec4f_t origin = Transform_GetWorldPosition (ent->transform);
|
|
|
|
vec4f_t rotation = Transform_GetWorldRotation (ent->transform);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-06-18 13:22:47 +00:00
|
|
|
// view is the weapon model (visible only from inside body)
|
2022-02-25 06:48:57 +00:00
|
|
|
view = vs->weapon_entity;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-28 07:59:38 +00:00
|
|
|
Transform_SetWorldPosition (vs->camera_transform, origin);
|
|
|
|
Transform_SetWorldRotation (vs->camera_transform, rotation);
|
2021-07-24 02:33:53 +00:00
|
|
|
view->renderer.model = NULL;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// always idle in intermission
|
2001-02-19 21:15:25 +00:00
|
|
|
old = v_idlescale->value;
|
|
|
|
Cvar_SetValue (v_idlescale, 1);
|
2022-02-25 06:48:57 +00:00
|
|
|
V_AddIdle (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
Cvar_SetValue (v_idlescale, old);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcRefdef (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2012-05-31 23:20:09 +00:00
|
|
|
// view is the weapon model (visible only from inside body)
|
2022-02-25 06:48:57 +00:00
|
|
|
entity_t *view = vs->weapon_entity;
|
2011-06-18 13:22:47 +00:00
|
|
|
float bob;
|
2001-02-19 21:15:25 +00:00
|
|
|
static float oldz = 0;
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t forward = {}, right = {}, up = {};
|
2022-03-01 02:43:23 +00:00
|
|
|
vec4f_t origin = vs->player_origin;
|
|
|
|
vec_t *viewangles = vs->player_angles;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
V_DriftPitch (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
bob = V_CalcBob (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-02 04:45:52 +00:00
|
|
|
// refresh position
|
2022-02-28 07:59:38 +00:00
|
|
|
origin = origin;
|
|
|
|
origin[2] += vs->height + bob;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
// never let it sit exactly on a node line, because a water plane can
|
|
|
|
// disappear when viewed with the eye exactly on it.
|
2010-01-13 06:42:26 +00:00
|
|
|
// server protocol specifies to only 1/8 pixel, so add 1/16 in each axis
|
2022-02-28 07:59:38 +00:00
|
|
|
origin += (vec4f_t) { 1.0/16, 1.0/16, 1.0/16, 0};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t rotation;
|
2022-03-01 02:43:23 +00:00
|
|
|
AngleQuat (vs->player_angles, &rotation[0]);//FIXME
|
2022-02-28 07:59:38 +00:00
|
|
|
Transform_SetWorldRotation (vs->camera_transform, rotation);
|
2022-02-25 06:48:57 +00:00
|
|
|
V_CalcViewRoll (vs);
|
|
|
|
V_AddIdle (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// offsets
|
2021-03-19 11:18:45 +00:00
|
|
|
//FIXME semi-duplicates AngleQuat (also, vec3_t vs vec4f_t)
|
|
|
|
AngleVectors (viewangles, &forward[0], &right[0], &up[0]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-05-31 23:19:22 +00:00
|
|
|
// don't allow cheats in multiplayer
|
|
|
|
// FIXME check for dead
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->voffs_enabled) {
|
2022-02-28 07:59:38 +00:00
|
|
|
origin += scr_ofsx->value * forward
|
2021-03-19 11:18:45 +00:00
|
|
|
+ scr_ofsy->value * right
|
|
|
|
+ scr_ofsz->value * up;
|
2012-05-31 23:19:22 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
V_BoundOffsets (vs);
|
2012-05-31 23:19:22 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// set up gun position
|
2022-03-01 02:43:23 +00:00
|
|
|
vec4f_t gun_origin = vs->player_origin;
|
2022-02-25 06:48:57 +00:00
|
|
|
CalcGunAngle (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, vs->height, 0 };
|
|
|
|
gun_origin += forward * bob * 0.4f + (vec4f_t) { 0, 0, bob, 0 };
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
// fudge position around to keep amount of weapon visible
|
|
|
|
// roughly equal with different FOV
|
2021-03-19 11:18:45 +00:00
|
|
|
if (hud_sbar->int_val == 0 && r_data->scr_viewsize->int_val >= 100) {
|
2001-02-21 19:13:03 +00:00
|
|
|
;
|
2021-03-19 11:18:45 +00:00
|
|
|
} else if (r_data->scr_viewsize->int_val == 110) {
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, 1, 0};
|
2021-03-19 11:18:45 +00:00
|
|
|
} else if (r_data->scr_viewsize->int_val == 100) {
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, 2, 0};
|
2021-03-19 11:18:45 +00:00
|
|
|
} else if (r_data->scr_viewsize->int_val == 90) {
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, 1, 0};
|
2021-03-19 11:18:45 +00:00
|
|
|
} else if (r_data->scr_viewsize->int_val == 80) {
|
2022-02-28 07:59:38 +00:00
|
|
|
gun_origin += (vec4f_t) { 0, 0, 0.5, 0};
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
model_t *model = vs->weapon_model;
|
|
|
|
if (vs->flags & (VF_GIB | VF_DEAD)) {
|
2021-11-30 16:10:59 +00:00
|
|
|
model = NULL;
|
|
|
|
}
|
|
|
|
if (view->renderer.model != model) {
|
|
|
|
view->animation.pose2 = -1;
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2021-11-30 16:10:59 +00:00
|
|
|
view->renderer.model = model;
|
2022-02-25 06:48:57 +00:00
|
|
|
view->animation.frame = vs->weaponframe;
|
2021-03-09 14:52:40 +00:00
|
|
|
view->renderer.skin = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// set up the refresh position
|
2022-02-28 07:59:38 +00:00
|
|
|
Transform_SetWorldRotation (vs->camera_transform,
|
|
|
|
qmulf (vs->punchangle, rotation));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
// smooth out stair step ups
|
2022-02-28 07:59:38 +00:00
|
|
|
if ((vs->onground != -1) && (gun_origin[2] - oldz > 0)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
float steptime;
|
|
|
|
|
2022-02-25 06:48:57 +00:00
|
|
|
steptime = vs->frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
oldz += steptime * 80;
|
2022-02-28 07:59:38 +00:00
|
|
|
if (oldz > gun_origin[2])
|
|
|
|
oldz = gun_origin[2];
|
|
|
|
if (gun_origin[2] - oldz > 12)
|
|
|
|
oldz = gun_origin[2] - 12;
|
|
|
|
origin[2] += oldz - gun_origin[2];
|
|
|
|
gun_origin[2] += oldz - gun_origin[2];
|
2021-03-19 11:18:45 +00:00
|
|
|
} else {
|
2022-02-28 07:59:38 +00:00
|
|
|
oldz = gun_origin[2];
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
2022-02-28 07:59:38 +00:00
|
|
|
Transform_SetWorldPosition (vs->camera_transform, origin);
|
2021-03-19 11:18:45 +00:00
|
|
|
{
|
|
|
|
// FIXME sort out the alias model specific negation
|
|
|
|
vec3_t ang = {-viewangles[0], viewangles[1], viewangles[2]};
|
2022-02-28 07:59:38 +00:00
|
|
|
CL_TransformEntity (view, 1, ang, gun_origin);
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2022-02-25 06:48:57 +00:00
|
|
|
DropPunchAngle (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
vec4f_t punch = vs->punchangle;
|
2021-03-19 11:18:45 +00:00
|
|
|
float ps = magnitude3f (punch)[0];
|
|
|
|
if (ps < 1e-3) {
|
|
|
|
// < 0.2 degree rotation, not worth worrying about
|
|
|
|
//ensure the quaternion is normalized
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->punchangle = (vec4f_t) { 0, 0, 0, 1 };
|
2021-03-19 11:18:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-02-25 02:39:11 +00:00
|
|
|
float pc = punch[3];
|
2022-02-25 06:48:57 +00:00
|
|
|
float ds = 0.0871557427 * vs->frametime;
|
2021-03-19 11:18:45 +00:00
|
|
|
float dc = sqrt (1 - ds * ds);
|
|
|
|
float s = ps * dc - pc * ds;
|
|
|
|
float c = pc * dc + ps * ds;
|
|
|
|
if (s <= 0 || c >= 1) {
|
2022-02-25 06:48:57 +00:00
|
|
|
vs->punchangle = (vec4f_t) { 0, 0, 0, 1 };
|
2021-03-19 11:18:45 +00:00
|
|
|
} else {
|
|
|
|
punch *= s / ps;
|
|
|
|
punch[3] = c;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
V_RenderView
|
|
|
|
|
|
|
|
The player's clipping box goes from (-16 -16 -24) to (16 16 32) from
|
|
|
|
the entity origin, so any view position inside that will be valid
|
|
|
|
*/
|
|
|
|
void
|
2022-02-25 06:48:57 +00:00
|
|
|
V_RenderView (viewstate_t *vs)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-25 06:48:57 +00:00
|
|
|
if (!vs->active) {
|
2022-02-28 07:59:38 +00:00
|
|
|
vec4f_t base = { 0, 0, 0, 1 };
|
|
|
|
Transform_SetWorldPosition (vs->camera_transform, base);
|
|
|
|
Transform_SetWorldRotation (vs->camera_transform, base);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2021-03-19 11:18:45 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-02-28 03:12:51 +00:00
|
|
|
if (vs->decay_punchangle) {
|
|
|
|
DropPunchAngle (vs);
|
|
|
|
}
|
2022-02-25 06:48:57 +00:00
|
|
|
if (vs->intermission) { // intermission / finale rendering
|
|
|
|
V_CalcIntermissionRefdef (vs);
|
2001-02-19 21:15:25 +00:00
|
|
|
} else {
|
2022-03-01 05:44:53 +00:00
|
|
|
if (vs->chase && chase_active->int_val) {
|
|
|
|
Chase_Update (vs->chasestate);
|
|
|
|
} else {
|
|
|
|
V_CalcRefdef (vs);
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-02-28 03:12:51 +00:00
|
|
|
V_Init (viewstate_t *viewstate)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2022-02-28 03:12:51 +00:00
|
|
|
Cmd_AddDataCommand ("bf", V_BonusFlash_f, viewstate,
|
2022-02-25 06:48:57 +00:00
|
|
|
"Background flash, used when you pick up an item");
|
2022-02-28 03:12:51 +00:00
|
|
|
Cmd_AddDataCommand ("centerview", V_StartPitchDrift_f, viewstate,
|
2022-02-25 06:48:57 +00:00
|
|
|
"Centers the player's "
|
2011-06-18 13:22:47 +00:00
|
|
|
"view ahead after +lookup or +lookdown\n"
|
2001-08-25 02:47:11 +00:00
|
|
|
"Will not work while mlook is active or freelook is 1.");
|
2001-09-10 17:32:22 +00:00
|
|
|
Cmd_AddCommand ("v_cshift", V_cshift_f, "This adjusts all of the colors "
|
|
|
|
"currently being displayed.\n"
|
|
|
|
"Used when you are underwater, hit, have the Ring of "
|
|
|
|
"Shadows, or Quad Damage. (v_cshift r g b intensity)");
|
2022-02-28 07:59:38 +00:00
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
viewstate->camera_transform = Transform_New (cl_world.scene, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
V_Init_Cvars (void)
|
|
|
|
{
|
2001-04-10 23:39:30 +00:00
|
|
|
v_centermove = Cvar_Get ("v_centermove", "0.15", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How far the player must move forward before the "
|
|
|
|
"view re-centers");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_centerspeed = Cvar_Get ("v_centerspeed", "500", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How quickly you return to a center view after "
|
|
|
|
"a lookup or lookdown");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_iyaw_cycle = Cvar_Get ("v_iyaw_cycle", "2", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How far you tilt right and left when "
|
|
|
|
"v_idlescale is enabled");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_iroll_cycle = Cvar_Get ("v_iroll_cycle", "0.5", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How quickly you tilt right and left when "
|
|
|
|
"v_idlescale is enabled");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_ipitch_cycle = Cvar_Get ("v_ipitch_cycle", "1", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How quickly you lean forwards and backwards "
|
|
|
|
"when v_idlescale is enabled");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_iyaw_level = Cvar_Get ("v_iyaw_level", "0.3", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How far you tilt right and left when "
|
|
|
|
"v_idlescale is enabled");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_iroll_level = Cvar_Get ("v_iroll_level", "0.1", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How far you tilt right and left when "
|
|
|
|
"v_idlescale is enabled");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_ipitch_level = Cvar_Get ("v_ipitch_level", "0.3", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How far you lean forwards and backwards when "
|
|
|
|
"v_idlescale is enabled");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_idlescale = Cvar_Get ("v_idlescale", "0", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"Toggles whether the view remains idle");
|
2001-04-10 23:39:30 +00:00
|
|
|
|
2012-05-31 23:19:22 +00:00
|
|
|
scr_ofsx = Cvar_Get ("scr_ofsx", "0", CVAR_NONE, NULL, "None");
|
|
|
|
scr_ofsy = Cvar_Get ("scr_ofsy", "0", CVAR_NONE, NULL, "None");
|
|
|
|
scr_ofsz = Cvar_Get ("scr_ofsz", "0", CVAR_NONE, NULL, "None");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_rollspeed = Cvar_Get ("cl_rollspeed", "200", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How quickly you straighten out after strafing");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_rollangle = Cvar_Get ("cl_rollangle", "2.0", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How much your screen tilts when strafing");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_bob = Cvar_Get ("cl_bob", "0.02", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How much your weapon moves up and down when walking");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_bobcycle = Cvar_Get ("cl_bobcycle", "0.6", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How quickly your weapon moves up and down when "
|
|
|
|
"walking");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_bobup = Cvar_Get ("cl_bobup", "0.5", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How long your weapon stays up before cycling when "
|
|
|
|
"walking");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_kicktime = Cvar_Get ("v_kicktime", "0.5", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How long the kick from an attack lasts");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_kickroll = Cvar_Get ("v_kickroll", "0.6", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How much you lean when hit");
|
2001-04-10 23:39:30 +00:00
|
|
|
v_kickpitch = Cvar_Get ("v_kickpitch", "0.6", CVAR_NONE, NULL,
|
2001-08-25 02:47:11 +00:00
|
|
|
"How much you look up when hit");
|
2022-02-28 03:12:51 +00:00
|
|
|
cl_cshift_bonus = Cvar_Get ("cl_cshift_bonus", "1", CVAR_ARCHIVE, NULL,
|
|
|
|
"Show bonus flash on item pickup");
|
|
|
|
cl_cshift_contents = Cvar_Get ("cl_cshift_content", "1", CVAR_ARCHIVE,
|
|
|
|
NULL, "Shift view colors for contents "
|
|
|
|
"(water, slime, etc)");
|
|
|
|
cl_cshift_damage = Cvar_Get ("cl_cshift_damage", "1", CVAR_ARCHIVE, NULL,
|
|
|
|
"Shift view colors on damage");
|
|
|
|
cl_cshift_powerup = Cvar_Get ("cl_cshift_powerup", "1", CVAR_ARCHIVE, NULL,
|
|
|
|
"Shift view colors for powerups");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|