2001-12-31 16:16:59 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
2001-12-31 16:28:42 +00:00
|
|
|
// $Log$
|
2007-02-08 23:49:59 +00:00
|
|
|
// Revision 1.52 2007/02/08 23:49:59 jbravo
|
|
|
|
// Removing cg_RQ3_avidemo
|
|
|
|
//
|
2007-02-03 15:02:21 +00:00
|
|
|
// Revision 1.51 2007/02/03 15:02:21 jbravo
|
|
|
|
// Renamed RQ3 to Reaction, Dropped loading of various baseq3 media, disabled the follow command, fixed grenades killing teammates and some cleanups
|
|
|
|
//
|
2005-09-07 22:19:16 +00:00
|
|
|
// Revision 1.50 2005/09/07 22:19:15 makro
|
|
|
|
// Dead player view offset tweaks
|
|
|
|
//
|
2005-09-07 20:29:05 +00:00
|
|
|
// Revision 1.49 2005/09/07 20:29:05 makro
|
|
|
|
// Stuff I can't remember
|
|
|
|
//
|
2005-02-15 16:33:39 +00:00
|
|
|
// Revision 1.48 2005/02/15 16:33:38 makro
|
|
|
|
// Tons of updates (entity tree attachment system, UI vectors)
|
|
|
|
//
|
2004-03-09 01:05:21 +00:00
|
|
|
// Revision 1.47 2004/03/09 01:05:21 makro
|
|
|
|
// Flares
|
|
|
|
//
|
2004-03-09 00:39:47 +00:00
|
|
|
// Revision 1.46 2004/03/09 00:39:47 makro
|
|
|
|
// Flares
|
|
|
|
//
|
2004-03-07 17:39:11 +00:00
|
|
|
// Revision 1.45 2004/03/07 17:39:11 makro
|
|
|
|
// no message
|
|
|
|
//
|
2004-01-28 23:26:33 +00:00
|
|
|
// Revision 1.44 2004/01/28 23:26:33 makro
|
|
|
|
// Made flares additive
|
|
|
|
//
|
2004-01-26 21:26:09 +00:00
|
|
|
// Revision 1.43 2004/01/26 21:26:08 makro
|
|
|
|
// no message
|
|
|
|
//
|
2003-09-20 19:38:16 +00:00
|
|
|
// Revision 1.42 2003/09/20 19:38:16 makro
|
|
|
|
// Lens flares, what else ?
|
|
|
|
//
|
2003-09-19 21:22:52 +00:00
|
|
|
// Revision 1.41 2003/09/19 21:22:52 makro
|
|
|
|
// Flares
|
|
|
|
//
|
2003-09-19 00:54:23 +00:00
|
|
|
// Revision 1.40 2003/09/19 00:54:23 makro
|
|
|
|
// Flares again
|
|
|
|
//
|
2003-09-18 19:08:40 +00:00
|
|
|
// Revision 1.39 2003/09/18 19:05:10 makro
|
|
|
|
// Lens flares
|
|
|
|
//
|
2003-09-17 23:49:29 +00:00
|
|
|
// Revision 1.38 2003/09/17 23:49:29 makro
|
|
|
|
// Lens flares. Opendoor trigger_multiple fixes
|
|
|
|
//
|
2003-09-07 22:19:27 +00:00
|
|
|
// Revision 1.37 2003/09/07 22:19:27 makro
|
|
|
|
// Typo !
|
|
|
|
//
|
2003-09-07 19:51:40 +00:00
|
|
|
// Revision 1.36 2003/09/07 19:51:40 makro
|
|
|
|
// no message
|
|
|
|
//
|
2003-08-10 20:13:26 +00:00
|
|
|
// Revision 1.35 2003/08/10 20:13:26 makro
|
|
|
|
// no message
|
|
|
|
//
|
2003-04-23 17:50:32 +00:00
|
|
|
// Revision 1.34 2003/04/23 17:49:38 slicer
|
|
|
|
// Added new cvar cg_RQ3_ssgZoomSensLock
|
|
|
|
//
|
2003-04-19 15:27:31 +00:00
|
|
|
// Revision 1.33 2003/04/19 15:27:30 jbravo
|
|
|
|
// Backing out of most of unlagged. Only optimized prediction and smooth clients
|
|
|
|
// remains.
|
|
|
|
//
|
2003-04-13 21:58:00 +00:00
|
|
|
// Revision 1.32 2003/04/13 21:58:00 slicer
|
|
|
|
// Added a Zoom Sensitivity Lock during fire sequence of ssg; removed unnecessary code
|
|
|
|
//
|
2003-03-28 22:26:24 +00:00
|
|
|
// Revision 1.31 2003/03/28 22:25:10 makro
|
|
|
|
// no message
|
|
|
|
//
|
2003-03-09 21:30:39 +00:00
|
|
|
// Revision 1.30 2003/03/09 21:30:38 jbravo
|
|
|
|
// Adding unlagged. Still needs work.
|
|
|
|
//
|
2002-09-01 21:15:08 +00:00
|
|
|
// Revision 1.29 2002/09/01 21:14:37 makro
|
|
|
|
// Sky portal tweaks
|
|
|
|
//
|
2002-08-30 00:00:16 +00:00
|
|
|
// Revision 1.28 2002/08/29 23:58:28 makro
|
|
|
|
// Sky portals
|
|
|
|
//
|
2002-08-29 04:42:41 +00:00
|
|
|
// Revision 1.27 2002/08/29 04:42:41 blaze
|
|
|
|
// Anti OGC code
|
|
|
|
//
|
2002-08-25 00:47:00 +00:00
|
|
|
// Revision 1.26 2002/08/25 00:45:40 niceass
|
|
|
|
// q3f atmosphere
|
|
|
|
//
|
2002-08-07 03:35:57 +00:00
|
|
|
// Revision 1.25 2002/08/07 03:35:57 jbravo
|
|
|
|
// Added dynamic radio and stopped all radio usage during lca
|
|
|
|
//
|
2002-07-13 22:43:59 +00:00
|
|
|
// Revision 1.24 2002/07/13 22:42:18 makro
|
|
|
|
// Semi-working fog hull, semi-working sky portals (cgame code commented out)
|
|
|
|
// Basically, semi-working stuff :P
|
|
|
|
//
|
2002-06-16 20:06:15 +00:00
|
|
|
// Revision 1.23 2002/06/16 20:06:13 jbravo
|
|
|
|
// Reindented all the source files with "indent -kr -ut -i8 -l120 -lc120 -sob -bad -bap"
|
|
|
|
//
|
2002-06-12 23:05:14 +00:00
|
|
|
// Revision 1.22 2002/06/12 23:01:06 slicer
|
|
|
|
// SSG Zooming final tweak
|
|
|
|
//
|
2002-05-23 15:54:35 +00:00
|
|
|
// Revision 1.21 2002/05/23 15:54:35 makro
|
|
|
|
// cg_RQ3_avidemo tweak
|
|
|
|
//
|
2002-05-21 14:59:12 +00:00
|
|
|
// Revision 1.20 2002/05/21 14:59:11 makro
|
|
|
|
// cg_RQ3_avidemo
|
|
|
|
//
|
2002-03-07 14:51:57 +00:00
|
|
|
// Revision 1.19 2002/03/07 14:51:57 makro
|
|
|
|
// no message
|
|
|
|
//
|
2002-02-23 18:07:46 +00:00
|
|
|
// Revision 1.18 2002/02/23 18:07:46 slicer
|
|
|
|
// Changed Sniper code and Cam code
|
|
|
|
//
|
2002-01-12 20:00:49 +00:00
|
|
|
// Revision 1.17 2002/01/12 20:00:49 hal9000
|
|
|
|
// Fixed a few more instances of strcmp(blah,NULL)
|
|
|
|
//
|
2002-01-11 19:48:33 +00:00
|
|
|
// Revision 1.16 2002/01/11 19:48:29 jbravo
|
|
|
|
// Formatted the source in non DOS format.
|
|
|
|
//
|
2001-12-31 16:28:42 +00:00
|
|
|
// Revision 1.15 2001/12/31 16:28:41 jbravo
|
|
|
|
// I made a Booboo with the Log tag.
|
|
|
|
//
|
2001-12-31 16:16:59 +00:00
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
2001-05-06 20:50:27 +00:00
|
|
|
// Copyright (C) 1999-2000 Id Software, Inc.
|
|
|
|
//
|
|
|
|
// cg_view.c -- setup all the parameters (position, angle, etc)
|
|
|
|
// for a 3D rendering
|
|
|
|
#include "cg_local.h"
|
2001-09-16 04:04:31 +00:00
|
|
|
//Blaze: Should come in handy for cheat detection
|
2002-06-16 20:06:15 +00:00
|
|
|
static float CG_Cvar_Get(const char *cvar)
|
|
|
|
{
|
2001-09-16 04:04:31 +00:00
|
|
|
char buff[128];
|
2002-06-16 20:06:15 +00:00
|
|
|
|
2001-09-16 04:04:31 +00:00
|
|
|
memset(buff, 0, sizeof(buff));
|
|
|
|
trap_Cvar_VariableStringBuffer(cvar, buff, sizeof(buff));
|
|
|
|
return atof(buff);
|
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
=============================================================================
|
|
|
|
|
|
|
|
MODEL TESTING
|
|
|
|
|
|
|
|
The viewthing and gun positioning tools from Q2 have been integrated and
|
|
|
|
enhanced into a single model testing facility.
|
|
|
|
|
|
|
|
Model viewing can begin with either "testmodel <modelname>" or "testgun <modelname>".
|
|
|
|
|
2001-11-25 23:04:08 +00:00
|
|
|
The names must be the full pathname after the basedir, like
|
2001-05-06 20:50:27 +00:00
|
|
|
"models/weapons/v_launch/tris.md3" or "players/male/tris.md3"
|
|
|
|
|
|
|
|
Testmodel will create a fake entity 100 units in front of the current view
|
|
|
|
position, directly facing the viewer. It will remain immobile, so you can
|
|
|
|
move around it to view it from different angles.
|
|
|
|
|
|
|
|
Testgun will cause the model to follow the player around and supress the real
|
|
|
|
view weapon model. The default frame 0 of most guns is completely off screen,
|
|
|
|
so you will probably have to cycle a couple frames to see it.
|
|
|
|
|
|
|
|
"nextframe", "prevframe", "nextskin", and "prevskin" commands will change the
|
|
|
|
frame or skin of the testmodel. These are bound to F5, F6, F7, and F8 in
|
|
|
|
q3default.cfg.
|
|
|
|
|
|
|
|
If a gun is being tested, the "gun_x", "gun_y", and "gun_z" variables will let
|
|
|
|
you adjust the positioning.
|
|
|
|
|
|
|
|
Note that none of the model testing features update while the game is paused, so
|
|
|
|
it may be convenient to test with deathmatch set to 1 so that bringing down the
|
|
|
|
console doesn't pause the game.
|
|
|
|
|
|
|
|
=============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CG_TestModel_f
|
|
|
|
|
|
|
|
Creates an entity in front of the current position, which
|
|
|
|
can then be moved around
|
|
|
|
=================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void CG_TestModel_f(void)
|
|
|
|
{
|
|
|
|
vec3_t angles;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
memset(&cg.testModelEntity, 0, sizeof(cg.testModelEntity));
|
|
|
|
if (trap_Argc() < 2) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
Q_strncpyz(cg.testModelName, CG_Argv(1), MAX_QPATH);
|
|
|
|
cg.testModelEntity.hModel = trap_R_RegisterModel(cg.testModelName);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (trap_Argc() == 3) {
|
|
|
|
cg.testModelEntity.backlerp = atof(CG_Argv(2));
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.testModelEntity.frame = 1;
|
|
|
|
cg.testModelEntity.oldframe = 0;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!cg.testModelEntity.hModel) {
|
|
|
|
CG_Printf("Can't register model\n");
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorMA(cg.refdef.vieworg, 100, cg.refdef.viewaxis[0], cg.testModelEntity.origin);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
angles[PITCH] = 0;
|
|
|
|
angles[YAW] = 180 + cg.refdefViewAngles[1];
|
|
|
|
angles[ROLL] = 0;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
AnglesToAxis(angles, cg.testModelEntity.axis);
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.testGun = qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CG_TestGun_f
|
|
|
|
|
|
|
|
Replaces the current view weapon with the given model
|
|
|
|
=================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void CG_TestGun_f(void)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
CG_TestModel_f();
|
|
|
|
cg.testGun = qtrue;
|
|
|
|
cg.testModelEntity.renderfx = RF_MINLIGHT | RF_DEPTHHACK | RF_FIRST_PERSON;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void CG_TestModelNextFrame_f(void)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.testModelEntity.frame++;
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_Printf("frame %i\n", cg.testModelEntity.frame);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void CG_TestModelPrevFrame_f(void)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.testModelEntity.frame--;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.testModelEntity.frame < 0) {
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.testModelEntity.frame = 0;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_Printf("frame %i\n", cg.testModelEntity.frame);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void CG_TestModelNextSkin_f(void)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.testModelEntity.skinNum++;
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_Printf("skin %i\n", cg.testModelEntity.skinNum);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
void CG_TestModelPrevSkin_f(void)
|
|
|
|
{
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.testModelEntity.skinNum--;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.testModelEntity.skinNum < 0) {
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.testModelEntity.skinNum = 0;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_Printf("skin %i\n", cg.testModelEntity.skinNum);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
static void CG_AddTestModel(void)
|
|
|
|
{
|
|
|
|
int i;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// re-register the model, because the level may have changed
|
2002-06-16 20:06:15 +00:00
|
|
|
cg.testModelEntity.hModel = trap_R_RegisterModel(cg.testModelName);
|
|
|
|
if (!cg.testModelEntity.hModel) {
|
|
|
|
CG_Printf("Can't register model\n");
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// if testing a gun, set the origin reletive to the view origin
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.testGun) {
|
|
|
|
VectorCopy(cg.refdef.vieworg, cg.testModelEntity.origin);
|
|
|
|
VectorCopy(cg.refdef.viewaxis[0], cg.testModelEntity.axis[0]);
|
|
|
|
VectorCopy(cg.refdef.viewaxis[1], cg.testModelEntity.axis[1]);
|
|
|
|
VectorCopy(cg.refdef.viewaxis[2], cg.testModelEntity.axis[2]);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// allow the position to be adjusted
|
2002-06-16 20:06:15 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.testModelEntity.origin[i] += cg.refdef.viewaxis[0][i] * cg_gun_x.value;
|
|
|
|
cg.testModelEntity.origin[i] += cg.refdef.viewaxis[1][i] * cg_gun_y.value;
|
|
|
|
cg.testModelEntity.origin[i] += cg.refdef.viewaxis[2][i] * cg_gun_z.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_R_AddRefEntityToScene(&cg.testModelEntity);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CG_CalcVrect
|
|
|
|
|
|
|
|
Sets the coordinates of the rendered window
|
|
|
|
=================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
static void CG_CalcVrect(void)
|
|
|
|
{
|
|
|
|
int size;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// the intermission should allways be full screen
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.snap->ps.pm_type == PM_INTERMISSION) {
|
2001-05-06 20:50:27 +00:00
|
|
|
size = 100;
|
|
|
|
} else {
|
|
|
|
// bound normal viewsize
|
|
|
|
if (cg_viewsize.integer < 30) {
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_Cvar_Set("cg_viewsize", "30");
|
2001-05-06 20:50:27 +00:00
|
|
|
size = 30;
|
|
|
|
} else if (cg_viewsize.integer > 100) {
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_Cvar_Set("cg_viewsize", "100");
|
2001-05-06 20:50:27 +00:00
|
|
|
size = 100;
|
|
|
|
} else {
|
|
|
|
size = cg_viewsize.integer;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
cg.refdef.width = cgs.glconfig.vidWidth * size / 100;
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.refdef.width &= ~1;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
cg.refdef.height = cgs.glconfig.vidHeight * size / 100;
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.refdef.height &= ~1;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
cg.refdef.x = (cgs.glconfig.vidWidth - cg.refdef.width) / 2;
|
|
|
|
cg.refdef.y = (cgs.glconfig.vidHeight - cg.refdef.height) / 2;
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
CG_OffsetThirdPersonView
|
|
|
|
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
#define FOCUS_DISTANCE 512
|
2002-06-16 20:06:15 +00:00
|
|
|
static void CG_OffsetThirdPersonView(void)
|
|
|
|
{
|
|
|
|
vec3_t forward, right, up;
|
|
|
|
vec3_t view;
|
|
|
|
vec3_t focusAngles;
|
|
|
|
trace_t trace;
|
|
|
|
static vec3_t mins = { -4, -4, -4 };
|
|
|
|
static vec3_t maxs = { 4, 4, 4 };
|
|
|
|
vec3_t focusPoint;
|
|
|
|
float focusDist;
|
|
|
|
float forwardScale, sideScale;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
cg.refdef.vieworg[2] += cg.predictedPlayerState.viewheight;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorCopy(cg.refdefViewAngles, focusAngles);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// if dead, look at killer
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.predictedPlayerState.stats[STAT_HEALTH] <= 0) {
|
2001-05-06 20:50:27 +00:00
|
|
|
focusAngles[YAW] = cg.predictedPlayerState.stats[STAT_DEAD_YAW];
|
|
|
|
cg.refdefViewAngles[YAW] = cg.predictedPlayerState.stats[STAT_DEAD_YAW];
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (focusAngles[PITCH] > 45) {
|
|
|
|
focusAngles[PITCH] = 45; // don't go too far overhead
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
AngleVectors(focusAngles, forward, NULL, NULL);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorMA(cg.refdef.vieworg, FOCUS_DISTANCE, forward, focusPoint);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorCopy(cg.refdef.vieworg, view);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
view[2] += 8;
|
|
|
|
|
|
|
|
cg.refdefViewAngles[PITCH] *= 0.5;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
AngleVectors(cg.refdefViewAngles, forward, right, up);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
forwardScale = cos(cg_thirdPersonAngle.value / 180 * M_PI);
|
|
|
|
sideScale = sin(cg_thirdPersonAngle.value / 180 * M_PI);
|
|
|
|
VectorMA(view, -cg_thirdPersonRange.value * forwardScale, forward, view);
|
|
|
|
VectorMA(view, -cg_thirdPersonRange.value * sideScale, right, view);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// trace a ray from the origin to the viewpoint to make sure the view isn't
|
|
|
|
// in a solid block. Use an 8 by 8 block to prevent the view from near clipping anything
|
|
|
|
|
|
|
|
if (!cg_cameraMode.integer) {
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_Trace(&trace, cg.refdef.vieworg, mins, maxs, view, cg.predictedPlayerState.clientNum, MASK_SOLID);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (trace.fraction != 1.0) {
|
|
|
|
VectorCopy(trace.endpos, view);
|
2001-05-06 20:50:27 +00:00
|
|
|
view[2] += (1.0 - trace.fraction) * 32;
|
|
|
|
// try another trace to this position, because a tunnel may have the ceiling
|
|
|
|
// close enogh that this is poking out
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_Trace(&trace, cg.refdef.vieworg, mins, maxs, view, cg.predictedPlayerState.clientNum,
|
|
|
|
MASK_SOLID);
|
|
|
|
VectorCopy(trace.endpos, view);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorCopy(view, cg.refdef.vieworg);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// select pitch to look at focus point from vieword
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorSubtract(focusPoint, cg.refdef.vieworg, focusPoint);
|
|
|
|
focusDist = sqrt(focusPoint[0] * focusPoint[0] + focusPoint[1] * focusPoint[1]);
|
|
|
|
if (focusDist < 1) {
|
2001-05-06 20:50:27 +00:00
|
|
|
focusDist = 1; // should never happen
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
cg.refdefViewAngles[PITCH] = -180 / M_PI * atan2(focusPoint[2], focusDist);
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.refdefViewAngles[YAW] -= cg_thirdPersonAngle.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this causes a compiler bug on mac MrC compiler
|
2002-06-16 20:06:15 +00:00
|
|
|
static void CG_StepOffset(void)
|
|
|
|
{
|
|
|
|
int timeDelta;
|
2001-11-25 23:04:08 +00:00
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
// smooth out stair climbing
|
|
|
|
timeDelta = cg.time - cg.stepTime;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (timeDelta < STEP_TIME) {
|
|
|
|
cg.refdef.vieworg[2] -= cg.stepChange * (STEP_TIME - timeDelta) / STEP_TIME;
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-07 20:29:05 +00:00
|
|
|
/*
|
|
|
|
void CG_PositionRotatedEntityOnTag(refEntity_t * entity, const refEntity_t * parent,
|
|
|
|
qhandle_t parentModel, char *tagName)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
orientation_t lerped;
|
|
|
|
vec3_t tempAxis[3];
|
|
|
|
|
|
|
|
//AxisClear( entity->axis );
|
|
|
|
// lerp the tag
|
|
|
|
trap_R_LerpTag(&lerped, parentModel, parent->oldframe, parent->frame, 1.0 - parent->backlerp, tagName);
|
|
|
|
|
|
|
|
// FIXME: allow origin offsets along tag?
|
|
|
|
VectorCopy(parent->origin, entity->origin);
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
VectorMA(entity->origin, lerped.origin[i], parent->axis[i], entity->origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
// had to cast away the const to avoid compiler problems...
|
|
|
|
MatrixMultiply(entity->axis, lerped.axis, tempAxis);
|
|
|
|
MatrixMultiply(tempAxis, ((refEntity_t *) parent)->axis, entity->axis);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
static void CG_DeadPlayerView()
|
|
|
|
{
|
2009-06-30 23:35:31 +00:00
|
|
|
if (cg.renderingThirdPerson || 0 != (cg.snap->ps.eFlags & EF_HEADLESS))
|
2005-09-07 20:29:05 +00:00
|
|
|
{
|
|
|
|
cg.refdefViewAngles[ROLL] = 40;
|
|
|
|
cg.refdefViewAngles[PITCH] = -15;
|
|
|
|
cg.refdefViewAngles[YAW] = cg.snap->ps.stats[STAT_DEAD_YAW];
|
|
|
|
cg.refdef.vieworg[2] += cg.predictedPlayerState.viewheight;
|
|
|
|
} else {
|
2005-09-07 22:19:16 +00:00
|
|
|
trace_t tr;
|
2009-06-30 23:35:31 +00:00
|
|
|
|
2005-09-07 20:29:05 +00:00
|
|
|
memcpy(cg.refdef.vieworg, cg.headPos, sizeof(cg.headPos));
|
|
|
|
memcpy(cg.refdef.viewaxis, cg.headAxis, sizeof(cg.headAxis));
|
2005-09-07 22:19:16 +00:00
|
|
|
|
|
|
|
CG_Trace(&tr, cg.oldHeadPos, NULL, NULL, cg.refdef.vieworg, cg.clientNum, CONTENTS_SOLID);
|
|
|
|
VectorCopy(tr.endpos, cg.refdef.vieworg);
|
2009-06-30 23:43:25 +00:00
|
|
|
VectorCopy(tr.endpos, cg.oldHeadPos);
|
2005-09-07 20:29:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
/*
|
|
|
|
===============
|
|
|
|
CG_OffsetFirstPersonView
|
|
|
|
|
|
|
|
===============
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
static void CG_OffsetFirstPersonView(void)
|
|
|
|
{
|
|
|
|
float *origin;
|
|
|
|
float *angles;
|
|
|
|
float bob;
|
|
|
|
float ratio;
|
|
|
|
float delta;
|
|
|
|
float speed;
|
|
|
|
float f;
|
|
|
|
vec3_t predictedVelocity;
|
|
|
|
int timeDelta;
|
|
|
|
|
|
|
|
if (cg.snap->ps.pm_type == PM_INTERMISSION) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
origin = cg.refdef.vieworg;
|
|
|
|
angles = cg.refdefViewAngles;
|
|
|
|
|
|
|
|
// if dead, fix the angle and don't add any kick
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.snap->ps.stats[STAT_HEALTH] <= 0) {
|
2005-09-07 20:29:05 +00:00
|
|
|
CG_DeadPlayerView();
|
|
|
|
/*
|
2001-05-06 20:50:27 +00:00
|
|
|
angles[ROLL] = 40;
|
|
|
|
angles[PITCH] = -15;
|
|
|
|
angles[YAW] = cg.snap->ps.stats[STAT_DEAD_YAW];
|
|
|
|
origin[2] += cg.predictedPlayerState.viewheight;
|
2005-09-07 20:29:05 +00:00
|
|
|
*/
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// add angles based on weapon kick
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorAdd(angles, cg.kick_angles, angles);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// add angles based on damage kick
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.damageTime) {
|
2001-05-06 20:50:27 +00:00
|
|
|
ratio = cg.time - cg.damageTime;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (ratio < DAMAGE_DEFLECT_TIME) {
|
2001-05-06 20:50:27 +00:00
|
|
|
ratio /= DAMAGE_DEFLECT_TIME;
|
|
|
|
angles[PITCH] += ratio * cg.v_dmg_pitch;
|
|
|
|
angles[ROLL] += ratio * cg.v_dmg_roll;
|
|
|
|
} else {
|
2002-06-16 20:06:15 +00:00
|
|
|
ratio = 1.0 - (ratio - DAMAGE_DEFLECT_TIME) / DAMAGE_RETURN_TIME;
|
|
|
|
if (ratio > 0) {
|
2001-05-06 20:50:27 +00:00
|
|
|
angles[PITCH] += ratio * cg.v_dmg_pitch;
|
|
|
|
angles[ROLL] += ratio * cg.v_dmg_roll;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// add pitch based on fall kick
|
|
|
|
#if 0
|
2002-06-16 20:06:15 +00:00
|
|
|
ratio = (cg.time - cg.landTime) / FALL_TIME;
|
2001-05-06 20:50:27 +00:00
|
|
|
if (ratio < 0)
|
|
|
|
ratio = 0;
|
|
|
|
angles[PITCH] += ratio * cg.fall_value;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// add angles based on velocity
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorCopy(cg.predictedPlayerState.velocity, predictedVelocity);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
delta = DotProduct(predictedVelocity, cg.refdef.viewaxis[0]);
|
2001-05-06 20:50:27 +00:00
|
|
|
angles[PITCH] += delta * cg_runpitch.value;
|
2001-11-25 23:04:08 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
delta = DotProduct(predictedVelocity, cg.refdef.viewaxis[1]);
|
2001-05-06 20:50:27 +00:00
|
|
|
angles[ROLL] -= delta * cg_runroll.value;
|
|
|
|
|
|
|
|
// add angles based on bob
|
|
|
|
|
|
|
|
// make sure the bob is visible even at low speeds
|
|
|
|
speed = cg.xyspeed > 200 ? cg.xyspeed : 200;
|
|
|
|
|
|
|
|
delta = cg.bobfracsin * cg_bobpitch.value * speed;
|
|
|
|
if (cg.predictedPlayerState.pm_flags & PMF_DUCKED)
|
2002-06-16 20:06:15 +00:00
|
|
|
delta *= 3; // crouching
|
2001-05-06 20:50:27 +00:00
|
|
|
angles[PITCH] += delta;
|
|
|
|
delta = cg.bobfracsin * cg_bobroll.value * speed;
|
|
|
|
if (cg.predictedPlayerState.pm_flags & PMF_DUCKED)
|
2002-06-16 20:06:15 +00:00
|
|
|
delta *= 3; // crouching accentuates roll
|
2001-05-06 20:50:27 +00:00
|
|
|
if (cg.bobcycle & 1)
|
|
|
|
delta = -delta;
|
|
|
|
angles[ROLL] += delta;
|
|
|
|
|
|
|
|
//===================================
|
|
|
|
|
|
|
|
// add view height
|
|
|
|
origin[2] += cg.predictedPlayerState.viewheight;
|
|
|
|
|
|
|
|
// smooth out duck height changes
|
|
|
|
timeDelta = cg.time - cg.duckTime;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (timeDelta < DUCK_TIME) {
|
|
|
|
cg.refdef.vieworg[2] -= cg.duckChange * (DUCK_TIME - timeDelta) / DUCK_TIME;
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
// add bob height
|
|
|
|
bob = cg.bobfracsin * cg.xyspeed * cg_bobup.value;
|
|
|
|
if (bob > 6) {
|
|
|
|
bob = 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
origin[2] += bob;
|
|
|
|
|
|
|
|
// add fall height
|
|
|
|
delta = cg.time - cg.landTime;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (delta < LAND_DEFLECT_TIME) {
|
2001-05-06 20:50:27 +00:00
|
|
|
f = delta / LAND_DEFLECT_TIME;
|
|
|
|
cg.refdef.vieworg[2] += cg.landChange * f;
|
2002-06-16 20:06:15 +00:00
|
|
|
} else if (delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME) {
|
2001-05-06 20:50:27 +00:00
|
|
|
delta -= LAND_DEFLECT_TIME;
|
2002-06-16 20:06:15 +00:00
|
|
|
f = 1.0 - (delta / LAND_RETURN_TIME);
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.refdef.vieworg[2] += cg.landChange * f;
|
|
|
|
}
|
|
|
|
// add step offset
|
|
|
|
CG_StepOffset();
|
|
|
|
|
|
|
|
// add kick offset
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorAdd(origin, cg.kick_origin, origin);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// pivot the eye based on a neck length
|
|
|
|
#if 0
|
|
|
|
{
|
|
|
|
#define NECK_LENGTH 8
|
2002-06-16 20:06:15 +00:00
|
|
|
vec3_t forward, up;
|
2001-11-25 23:04:08 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
cg.refdef.vieworg[2] -= NECK_LENGTH;
|
|
|
|
AngleVectors(cg.refdefViewAngles, forward, NULL, up);
|
|
|
|
VectorMA(cg.refdef.vieworg, 3, forward, cg.refdef.vieworg);
|
|
|
|
VectorMA(cg.refdef.vieworg, NECK_LENGTH, up, cg.refdef.vieworg);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
#endif
|
2001-09-11 00:11:00 +00:00
|
|
|
|
|
|
|
// Weapon kick management
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.kick_time) {
|
2001-09-11 00:11:00 +00:00
|
|
|
int duration;
|
2001-11-25 23:04:08 +00:00
|
|
|
|
2001-09-11 00:11:00 +00:00
|
|
|
if (cg.kick_duration)
|
|
|
|
duration = cg.kick_duration;
|
|
|
|
else
|
|
|
|
duration = KICK_TIME;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.time - cg.kick_time >= duration) {
|
2001-09-11 00:11:00 +00:00
|
|
|
// Elder: clear kick origin and angles
|
|
|
|
VectorClear(cg.kick_angles);
|
|
|
|
VectorClear(cg.kick_origin);
|
|
|
|
cg.kick_time = 0;
|
|
|
|
cg.kick_duration = 0;
|
2002-06-16 20:06:15 +00:00
|
|
|
} else {
|
2001-09-11 00:11:00 +00:00
|
|
|
// Decay them
|
2002-06-16 20:06:15 +00:00
|
|
|
cg.kick_angles[0] = cg.kick_angles[0] * (1 - (float) (cg.time - cg.kick_time) / duration);
|
|
|
|
cg.kick_angles[1] = cg.kick_angles[1] * (1 - (float) (cg.time - cg.kick_time) / duration);
|
|
|
|
cg.kick_angles[2] = cg.kick_angles[2] * (1 - (float) (cg.time - cg.kick_time) / duration);
|
|
|
|
cg.kick_origin[0] = cg.kick_origin[0] * (1 - (float) (cg.time - cg.kick_time) / duration);
|
|
|
|
cg.kick_origin[1] = cg.kick_origin[1] * (1 - (float) (cg.time - cg.kick_time) / duration);
|
|
|
|
cg.kick_origin[2] = cg.kick_origin[2] * (1 - (float) (cg.time - cg.kick_time) / duration);
|
2001-09-11 00:11:00 +00:00
|
|
|
}
|
|
|
|
/*
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_Printf("Kick Angles: (%f %f %f) Origin: (%f %f %f)\n",
|
|
|
|
cg.kick_angles[0], cg.kick_angles[1], cg.kick_angles[2],
|
|
|
|
cg.kick_origin[0], cg.kick_origin[1], cg.kick_origin[2]);
|
|
|
|
*/
|
2001-09-11 00:11:00 +00:00
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
|
|
|
/* hawkins: not needed in rxn as is. however, useful for SSG. */
|
|
|
|
/*
|
2001-11-25 23:04:08 +00:00
|
|
|
void CG_ZoomDown_f( void ) {
|
2001-05-06 20:50:27 +00:00
|
|
|
if ( cg.zoomed ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cg.zoomed = qtrue;
|
|
|
|
cg.zoomTime = cg.time;
|
|
|
|
}
|
|
|
|
|
2001-11-25 23:04:08 +00:00
|
|
|
void CG_ZoomUp_f( void ) {
|
2001-05-06 20:50:27 +00:00
|
|
|
if ( !cg.zoomed ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cg.zoomed = qfalse;
|
|
|
|
cg.zoomTime = cg.time;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2001-07-16 01:41:36 +00:00
|
|
|
/*
|
|
|
|
====================
|
|
|
|
CG_RQ3_GetFov
|
|
|
|
|
|
|
|
Returns a FOV based on the current zoom state
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int CG_RQ3_GetFov()
|
|
|
|
{
|
2002-06-16 20:06:15 +00:00
|
|
|
if ((cg.zoomLevel & RQ3_ZOOM_LOW) == RQ3_ZOOM_LOW && (cg.zoomLevel & RQ3_ZOOM_MED) == RQ3_ZOOM_MED)
|
2001-07-16 01:41:36 +00:00
|
|
|
return 10;
|
2002-06-16 20:06:15 +00:00
|
|
|
else if ((cg.zoomLevel & RQ3_ZOOM_MED) == RQ3_ZOOM_MED)
|
2001-07-16 01:41:36 +00:00
|
|
|
return 20;
|
2002-06-16 20:06:15 +00:00
|
|
|
else if ((cg.zoomLevel & RQ3_ZOOM_LOW) == RQ3_ZOOM_LOW)
|
2001-07-16 01:41:36 +00:00
|
|
|
return 45;
|
|
|
|
|
|
|
|
return 90;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
CG_RQ3_GetFov
|
|
|
|
|
|
|
|
Returns a FOV based on the last zoom state
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int CG_RQ3_GetLastFov()
|
|
|
|
{
|
2002-06-16 20:06:15 +00:00
|
|
|
if ((cg.lastZoomLevel & RQ3_ZOOM_LOW) == RQ3_ZOOM_LOW && (cg.lastZoomLevel & RQ3_ZOOM_MED) == RQ3_ZOOM_MED)
|
2001-07-16 01:41:36 +00:00
|
|
|
return 10;
|
2002-06-16 20:06:15 +00:00
|
|
|
else if ((cg.lastZoomLevel & RQ3_ZOOM_MED) == RQ3_ZOOM_MED)
|
2001-07-16 01:41:36 +00:00
|
|
|
return 20;
|
2002-06-16 20:06:15 +00:00
|
|
|
else if ((cg.lastZoomLevel & RQ3_ZOOM_LOW) == RQ3_ZOOM_LOW)
|
2001-07-16 01:41:36 +00:00
|
|
|
return 45;
|
|
|
|
|
|
|
|
return 90;
|
|
|
|
}
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
/*
|
|
|
|
====================
|
|
|
|
CG_CalcFov
|
|
|
|
|
|
|
|
Fixed fov at intermissions, otherwise account for fov variable and zooms.
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
#define WAVE_AMPLITUDE 1
|
|
|
|
#define WAVE_FREQUENCY 0.4
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
static int CG_CalcFov(void)
|
|
|
|
{
|
|
|
|
float phase;
|
|
|
|
float v;
|
|
|
|
int contents;
|
|
|
|
float fov_x, fov_y; //Current zoom
|
|
|
|
float zoomFov; //Desired zoom
|
|
|
|
float f;
|
|
|
|
int inwater;
|
|
|
|
|
|
|
|
if (cg.predictedPlayerState.pm_type == PM_INTERMISSION) {
|
2001-07-16 01:41:36 +00:00
|
|
|
fov_x = 90;
|
|
|
|
}
|
2003-04-13 21:58:00 +00:00
|
|
|
// Slicer: Updates the cg.zoomLevel with the info sent by server
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_RQ3_SyncZoom();
|
2001-11-25 23:04:08 +00:00
|
|
|
|
2003-04-13 21:58:00 +00:00
|
|
|
//Slicer
|
|
|
|
cg.zoomSensLock = qfalse;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.snap->ps.weapon == WP_SSG3000) {
|
2001-10-11 22:50:58 +00:00
|
|
|
//switching zoom
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.zoomLevel != cg.lastZoomLevel) {
|
2003-04-13 21:58:00 +00:00
|
|
|
|
2002-06-12 23:05:14 +00:00
|
|
|
//Slicer
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!cg.zooming) { // If this is the first zooming attempt
|
|
|
|
cg.zoomTime = cg.time; // Lets set the time
|
|
|
|
cg.zooming = qtrue; // and disable the IF condition
|
2002-06-12 23:05:14 +00:00
|
|
|
}
|
|
|
|
|
2001-10-11 22:50:58 +00:00
|
|
|
fov_x = CG_RQ3_GetLastFov();
|
|
|
|
//Get desired zoom FOV based on current FOV
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.zoomLevel == 0) {
|
2001-10-11 22:50:58 +00:00
|
|
|
zoomFov = 90;
|
|
|
|
cg.zoomed = qfalse;
|
2002-06-16 20:06:15 +00:00
|
|
|
} else {
|
2009-06-23 19:11:11 +00:00
|
|
|
switch (CG_RQ3_GetLastFov()) {
|
2002-06-16 20:06:15 +00:00
|
|
|
case 20:
|
|
|
|
zoomFov = 10;
|
|
|
|
cg.zoomed = qtrue;
|
|
|
|
break;
|
|
|
|
case 45:
|
|
|
|
zoomFov = 20;
|
|
|
|
cg.zoomed = qtrue;
|
|
|
|
break;
|
|
|
|
case 90:
|
|
|
|
zoomFov = 45;
|
|
|
|
cg.zoomed = qtrue;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
default:
|
|
|
|
zoomFov = 90;
|
|
|
|
cg.zoomed = qfalse;
|
|
|
|
break;
|
2001-10-11 22:50:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
f = (cg.time - cg.zoomTime) / (float) ZOOM_TIME;
|
|
|
|
if (f > 1.0 || cg.zoomFirstReturn == ZOOM_OUT) {
|
2001-10-11 22:50:58 +00:00
|
|
|
//finished zoom switch
|
|
|
|
cg.lastZoomLevel = cg.zoomLevel;
|
|
|
|
fov_x = zoomFov;
|
2002-06-12 23:05:14 +00:00
|
|
|
//Slicer : zoom has finished, so the next one needs to have a new zoomTime
|
|
|
|
cg.zooming = qfalse;
|
2002-06-16 20:06:15 +00:00
|
|
|
} else
|
|
|
|
fov_x = fov_x + f * (zoomFov - fov_x);
|
2001-10-11 22:50:58 +00:00
|
|
|
}
|
|
|
|
//Idle state
|
2002-06-16 20:06:15 +00:00
|
|
|
else if (cg.snap->ps.weaponTime == 0 && cg.snap->ps.weaponstate == WEAPON_READY) {
|
2001-10-11 22:50:58 +00:00
|
|
|
fov_x = CG_RQ3_GetFov();
|
2003-04-13 21:58:00 +00:00
|
|
|
if (fov_x == 90) {
|
2001-10-11 22:50:58 +00:00
|
|
|
cg.zoomed = qfalse;
|
2003-04-13 21:58:00 +00:00
|
|
|
}
|
2001-10-11 22:50:58 +00:00
|
|
|
else
|
|
|
|
cg.zoomed = qtrue;
|
|
|
|
|
|
|
|
if (cg.lowAmmoWarning)
|
|
|
|
cg.zoomFirstReturn = ZOOM_OUTOFAMMO;
|
|
|
|
else
|
|
|
|
cg.zoomFirstReturn = ZOOM_IDLE;
|
|
|
|
}
|
|
|
|
//Zoom back in after a reload or fire
|
|
|
|
else if (cg.snap->ps.weaponTime < ZOOM_TIME &&
|
2002-06-16 20:06:15 +00:00
|
|
|
!(cg.snap->ps.weaponstate == WEAPON_DROPPING ||
|
|
|
|
cg.snap->ps.weaponstate == WEAPON_RAISING) &&
|
|
|
|
cg.snap->ps.stats[STAT_RELOADTIME] < ZOOM_TIME &&
|
|
|
|
!(cg.snap->ps.stats[STAT_RQ3] & RQ3_FASTRELOADS)) {
|
|
|
|
if (cg.zoomFirstReturn == ZOOM_OUT) {
|
2001-10-11 22:50:58 +00:00
|
|
|
cg.zoomTime = cg.time;
|
|
|
|
if (cg.lowAmmoWarning)
|
|
|
|
cg.zoomFirstReturn = ZOOM_OUTOFAMMO;
|
|
|
|
else
|
|
|
|
cg.zoomFirstReturn = ZOOM_IDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fov_x = 90;
|
|
|
|
zoomFov = CG_RQ3_GetFov();
|
|
|
|
|
2003-04-13 21:58:00 +00:00
|
|
|
|
2001-10-11 22:50:58 +00:00
|
|
|
if (zoomFov == 90)
|
|
|
|
cg.zoomed = qfalse;
|
|
|
|
else
|
|
|
|
cg.zoomed = qtrue;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
f = (cg.time - cg.zoomTime) / (float) ZOOM_TIME;
|
|
|
|
if (f > 1.0) //|| cg.zoomFirstReturn == ZOOM_OUTOFAMMO)
|
2001-10-11 22:50:58 +00:00
|
|
|
fov_x = zoomFov;
|
|
|
|
else
|
2002-06-16 20:06:15 +00:00
|
|
|
fov_x = fov_x + f * (zoomFov - fov_x);
|
|
|
|
//fov_x = zoomFov + f * ( fov_x - zoomFov );
|
2001-10-11 22:50:58 +00:00
|
|
|
}
|
|
|
|
//first time after a shot, reload, or weapon switch - zoom out
|
2002-06-16 20:06:15 +00:00
|
|
|
else {
|
2001-10-11 22:50:58 +00:00
|
|
|
fov_x = CG_RQ3_GetFov();
|
2003-04-13 21:58:00 +00:00
|
|
|
//Slicer: if the weapon is about to go to firing sequence, lock the zoomSensitivity
|
2003-04-23 17:50:32 +00:00
|
|
|
if(cg.snap->ps.weaponstate == WEAPON_FIRING && cg_RQ3_ssgZoomSensLock.value)
|
2003-04-13 21:58:00 +00:00
|
|
|
cg.zoomSensLock = qtrue;
|
2001-10-11 22:50:58 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.snap->ps.weaponstate == WEAPON_RELOADING && cg.zoomFirstReturn != ZOOM_OUT) {
|
2001-10-11 22:50:58 +00:00
|
|
|
cg.zoomTime = cg.time;
|
|
|
|
cg.zoomFirstReturn = ZOOM_OUT;
|
2002-06-16 20:06:15 +00:00
|
|
|
} else if (cg.zoomFirstReturn == ZOOM_IDLE &&
|
|
|
|
!(cg.snap->ps.weaponstate == WEAPON_DROPPING
|
|
|
|
|| cg.snap->ps.weaponstate == WEAPON_RAISING)) {
|
2001-10-11 22:50:58 +00:00
|
|
|
cg.zoomTime = cg.time;
|
|
|
|
cg.zoomFirstReturn = ZOOM_OUT;
|
|
|
|
}
|
2001-11-25 23:04:08 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.zoomFirstReturn == ZOOM_OUTOFAMMO) {
|
2001-10-11 22:50:58 +00:00
|
|
|
zoomFov = fov_x;
|
2002-06-16 20:06:15 +00:00
|
|
|
f = 1.0f; // don't bother zooming out
|
|
|
|
} else {
|
2001-10-11 22:50:58 +00:00
|
|
|
zoomFov = 90;
|
2002-06-16 20:06:15 +00:00
|
|
|
f = (cg.time - cg.zoomTime) / (float) ZOOM_TIME;
|
2001-10-11 22:50:58 +00:00
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (f > 1.0) {
|
2001-10-11 22:50:58 +00:00
|
|
|
fov_x = zoomFov;
|
|
|
|
if (fov_x == 90)
|
|
|
|
cg.zoomed = qfalse;
|
|
|
|
else
|
|
|
|
cg.zoomed = qtrue;
|
2002-06-16 20:06:15 +00:00
|
|
|
} else
|
|
|
|
fov_x = fov_x + f * (zoomFov - fov_x);
|
2001-10-11 22:50:58 +00:00
|
|
|
}
|
2002-06-12 23:05:14 +00:00
|
|
|
|
2001-10-11 22:50:58 +00:00
|
|
|
}
|
2001-07-16 01:41:36 +00:00
|
|
|
//Using anything but the SSG3000
|
2002-06-16 20:06:15 +00:00
|
|
|
else {
|
2001-07-16 01:41:36 +00:00
|
|
|
//Always at 90 degrees
|
|
|
|
fov_x = 90;
|
2001-06-18 00:40:38 +00:00
|
|
|
cg.zoomed = qfalse;
|
2003-04-13 21:58:00 +00:00
|
|
|
cg.zoomSensLock = qfalse;
|
2001-06-08 04:35:50 +00:00
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2009-06-23 21:28:57 +00:00
|
|
|
// Makro - adjust for cg_fov
|
|
|
|
fov_x *= cg_fov.value / 90.f;
|
|
|
|
|
2009-06-23 19:11:11 +00:00
|
|
|
// Makro - adjust for wide screen
|
|
|
|
// We first determine fov_y corresponding to the previously computed fov_x,
|
|
|
|
// if the screen had been 4:3. Then, given that fov_y, we determine fov_x
|
|
|
|
// taking into account the actual aspect ratio.
|
|
|
|
|
|
|
|
fov_y = atan2(tan(fov_x / 360 * M_PI), 4.f / 3.f) * 360 / M_PI;
|
|
|
|
fov_x = 360.f / M_PI * atan2(tan(fov_y * M_PI / 360.f) * cg.refdef.width, cg.refdef.height);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// warp if underwater
|
2002-06-16 20:06:15 +00:00
|
|
|
contents = CG_PointContents(cg.refdef.vieworg, -1);
|
|
|
|
if (contents & (CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA)) {
|
2001-05-06 20:50:27 +00:00
|
|
|
phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2;
|
2002-06-16 20:06:15 +00:00
|
|
|
v = WAVE_AMPLITUDE * sin(phase);
|
2001-05-06 20:50:27 +00:00
|
|
|
fov_x += v;
|
|
|
|
fov_y -= v;
|
|
|
|
inwater = qtrue;
|
2002-06-16 20:06:15 +00:00
|
|
|
} else {
|
2001-05-06 20:50:27 +00:00
|
|
|
inwater = qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set it
|
|
|
|
cg.refdef.fov_x = fov_x;
|
|
|
|
cg.refdef.fov_y = fov_y;
|
2009-06-23 21:28:57 +00:00
|
|
|
|
2003-04-13 21:58:00 +00:00
|
|
|
//Slicer: Don't calculate new values for the zoomSensitivity when doing the firing sequence
|
|
|
|
if(!cg.zoomSensLock) {
|
|
|
|
if (!cg.zoomed ) {
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.zoomSensitivity = 1;
|
2003-04-13 21:58:00 +00:00
|
|
|
} else {
|
|
|
|
if (cg_RQ3_ssgSensitivityAuto.integer)
|
|
|
|
cg.zoomSensitivity = cg.refdef.fov_y / 75.0;
|
|
|
|
else {
|
|
|
|
// Use user-defined sensitivites
|
2009-06-23 19:11:11 +00:00
|
|
|
switch (CG_RQ3_GetLastFov()) {
|
2003-04-13 21:58:00 +00:00
|
|
|
case 45:
|
|
|
|
cg.zoomSensitivity = cg_RQ3_ssgSensitivity2x.value;
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
cg.zoomSensitivity = cg_RQ3_ssgSensitivity4x.value;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
cg.zoomSensitivity = cg_RQ3_ssgSensitivity6x.value;
|
|
|
|
break;
|
|
|
|
}
|
2001-10-11 22:50:58 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return inwater;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
CG_DamageBlendBlob
|
|
|
|
|
|
|
|
===============
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
static void CG_DamageBlendBlob(void)
|
|
|
|
{
|
|
|
|
int t;
|
|
|
|
int maxTime;
|
|
|
|
refEntity_t ent;
|
2001-11-25 23:04:08 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!cg.damageValue) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-08-01 21:07:48 +00:00
|
|
|
//if (cg.cameraMode) {
|
2002-06-16 20:06:15 +00:00
|
|
|
// return;
|
2001-08-01 21:07:48 +00:00
|
|
|
//}
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
// ragePro systems can't fade blends, so don't obscure the screen
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cgs.glconfig.hardwareType == GLHW_RAGEPRO) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
maxTime = DAMAGE_TIME;
|
|
|
|
t = cg.time - cg.damageTime;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (t <= 0 || t >= maxTime) {
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
memset(&ent, 0, sizeof(ent));
|
2001-05-06 20:50:27 +00:00
|
|
|
ent.reType = RT_SPRITE;
|
|
|
|
ent.renderfx = RF_FIRST_PERSON;
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorMA(cg.refdef.vieworg, 8, cg.refdef.viewaxis[0], ent.origin);
|
|
|
|
VectorMA(ent.origin, cg.damageX * -8, cg.refdef.viewaxis[1], ent.origin);
|
|
|
|
VectorMA(ent.origin, cg.damageY * 8, cg.refdef.viewaxis[2], ent.origin);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
ent.radius = cg.damageValue * 3;
|
|
|
|
ent.customShader = cgs.media.viewBloodShader;
|
|
|
|
ent.shaderRGBA[0] = 255;
|
|
|
|
ent.shaderRGBA[1] = 255;
|
|
|
|
ent.shaderRGBA[2] = 255;
|
2002-06-16 20:06:15 +00:00
|
|
|
ent.shaderRGBA[3] = 200 * (1.0 - ((float) t / maxTime));
|
|
|
|
trap_R_AddRefEntityToScene(&ent);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
CG_CalcViewValues
|
|
|
|
|
|
|
|
Sets cg.refdef view values
|
|
|
|
===============
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
static int CG_CalcViewValues(void)
|
|
|
|
{
|
|
|
|
playerState_t *ps;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
memset(&cg.refdef, 0, sizeof(cg.refdef));
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// strings for in game rendering
|
|
|
|
// Q_strncpyz( cg.refdef.text[0], "Park Ranger", sizeof(cg.refdef.text[0]) );
|
|
|
|
// Q_strncpyz( cg.refdef.text[1], "19", sizeof(cg.refdef.text[1]) );
|
|
|
|
|
|
|
|
// calculate size of 3D view
|
|
|
|
CG_CalcVrect();
|
|
|
|
|
|
|
|
ps = &cg.predictedPlayerState;
|
2001-08-01 21:07:48 +00:00
|
|
|
/*
|
|
|
|
if (cg.cameraMode) {
|
|
|
|
vec3_t origin, angles;
|
|
|
|
if (trap_getCameraInfo(cg.time, &origin, &angles)) {
|
|
|
|
VectorCopy(origin, cg.refdef.vieworg);
|
|
|
|
angles[ROLL] = 0;
|
|
|
|
VectorCopy(angles, cg.refdefViewAngles);
|
|
|
|
AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
|
|
|
|
return CG_CalcFov();
|
|
|
|
} else {
|
|
|
|
cg.cameraMode = qfalse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2001-05-06 20:50:27 +00:00
|
|
|
// intermission view
|
2002-06-16 20:06:15 +00:00
|
|
|
if (ps->pm_type == PM_INTERMISSION) {
|
|
|
|
VectorCopy(ps->origin, cg.refdef.vieworg);
|
|
|
|
VectorCopy(ps->viewangles, cg.refdefViewAngles);
|
|
|
|
AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
|
2001-05-06 20:50:27 +00:00
|
|
|
return CG_CalcFov();
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
cg.bobcycle = (ps->bobCycle & 128) >> 7;
|
|
|
|
cg.bobfracsin = fabs(sin((ps->bobCycle & 127) / 127.0 * M_PI));
|
|
|
|
cg.xyspeed = sqrt(ps->velocity[0] * ps->velocity[0] + ps->velocity[1] * ps->velocity[1]);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
VectorCopy(ps->origin, cg.refdef.vieworg);
|
|
|
|
VectorCopy(ps->viewangles, cg.refdefViewAngles);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
if (cg_cameraOrbit.integer) {
|
|
|
|
if (cg.time > cg.nextOrbitTime) {
|
|
|
|
cg.nextOrbitTime = cg.time + cg_cameraOrbitDelay.integer;
|
|
|
|
cg_thirdPersonAngle.value += cg_cameraOrbit.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// add error decay
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg_errorDecay.value > 0) {
|
|
|
|
int t;
|
|
|
|
float f;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
t = cg.time - cg.predictedErrorTime;
|
2002-06-16 20:06:15 +00:00
|
|
|
f = (cg_errorDecay.value - t) / cg_errorDecay.value;
|
|
|
|
if (f > 0 && f < 1) {
|
|
|
|
VectorMA(cg.refdef.vieworg, f, cg.predictedError, cg.refdef.vieworg);
|
2001-05-06 20:50:27 +00:00
|
|
|
} else {
|
|
|
|
cg.predictedErrorTime = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.renderingThirdPerson) {
|
2001-05-06 20:50:27 +00:00
|
|
|
// back away from character
|
|
|
|
CG_OffsetThirdPersonView();
|
|
|
|
} else {
|
|
|
|
// offset for local bobbing and kicks
|
|
|
|
CG_OffsetFirstPersonView();
|
|
|
|
}
|
|
|
|
|
|
|
|
// position eye reletive to origin
|
2005-09-07 20:29:05 +00:00
|
|
|
if (cg.snap->ps.stats[STAT_HEALTH] > 0)
|
|
|
|
AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.hyperspace) {
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.refdef.rdflags |= RDF_NOWORLDMODEL | RDF_HYPERSPACE;
|
|
|
|
}
|
|
|
|
// field of view
|
|
|
|
return CG_CalcFov();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
CG_PowerupTimerSounds
|
|
|
|
=====================
|
|
|
|
*/
|
2007-02-03 15:02:21 +00:00
|
|
|
/* JBravo: Nope
|
2002-06-16 20:06:15 +00:00
|
|
|
static void CG_PowerupTimerSounds(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int t;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// powerup timers going away
|
2002-06-16 20:06:15 +00:00
|
|
|
for (i = 0; i < MAX_POWERUPS; i++) {
|
2001-05-06 20:50:27 +00:00
|
|
|
t = cg.snap->ps.powerups[i];
|
2002-06-16 20:06:15 +00:00
|
|
|
if (t <= cg.time) {
|
2001-05-06 20:50:27 +00:00
|
|
|
continue;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
if (t - cg.time >= POWERUP_BLINKS * POWERUP_BLINK_TIME) {
|
2001-05-06 20:50:27 +00:00
|
|
|
continue;
|
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
if ((t - cg.time) / POWERUP_BLINK_TIME != (t - cg.oldTime) / POWERUP_BLINK_TIME) {
|
|
|
|
trap_S_StartSound(NULL, cg.snap->ps.clientNum, CHAN_ITEM, cgs.media.wearOffSound);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-02-03 15:02:21 +00:00
|
|
|
*/
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
CG_AddBufferedSound
|
|
|
|
=====================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void CG_AddBufferedSound(sfxHandle_t sfx)
|
|
|
|
{
|
|
|
|
if (!sfx)
|
2001-05-06 20:50:27 +00:00
|
|
|
return;
|
|
|
|
cg.soundBuffer[cg.soundBufferIn] = sfx;
|
|
|
|
cg.soundBufferIn = (cg.soundBufferIn + 1) % MAX_SOUNDBUFFER;
|
|
|
|
if (cg.soundBufferIn == cg.soundBufferOut) {
|
|
|
|
cg.soundBufferOut++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
CG_PlayBufferedSounds
|
|
|
|
=====================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
static void CG_PlayBufferedSounds(void)
|
|
|
|
{
|
|
|
|
if (cg.soundTime < cg.time) {
|
2001-05-06 20:50:27 +00:00
|
|
|
if (cg.soundBufferOut != cg.soundBufferIn && cg.soundBuffer[cg.soundBufferOut]) {
|
|
|
|
trap_S_StartLocalSound(cg.soundBuffer[cg.soundBufferOut], CHAN_ANNOUNCER);
|
|
|
|
cg.soundBuffer[cg.soundBufferOut] = 0;
|
|
|
|
cg.soundBufferOut = (cg.soundBufferOut + 1) % MAX_SOUNDBUFFER;
|
2002-08-07 03:35:57 +00:00
|
|
|
cg.soundTime = cg.time + 1100;
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
|
2003-09-17 23:49:29 +00:00
|
|
|
|
2004-01-26 21:26:09 +00:00
|
|
|
#define FLARE_FADEOUT_TIME 200
|
2004-03-09 01:05:21 +00:00
|
|
|
#define FLARE_BLIND_ALPHA 0.25f
|
2003-09-17 23:49:29 +00:00
|
|
|
|
2005-09-07 20:29:05 +00:00
|
|
|
//Makro - lens flare
|
2003-09-20 19:38:16 +00:00
|
|
|
void CG_AddLensFlare(qboolean sun)
|
2003-09-17 23:49:29 +00:00
|
|
|
{
|
|
|
|
vec3_t dir, dp;
|
|
|
|
|
2003-09-19 00:54:23 +00:00
|
|
|
if (cgs.numFlares <= 0 && (cgs.sunFlareSize <= 0 || cgs.sunAlpha == 0))
|
|
|
|
return;
|
2004-03-09 01:05:21 +00:00
|
|
|
|
2003-09-20 19:38:16 +00:00
|
|
|
if (sun)
|
|
|
|
{
|
|
|
|
float PI180 = M_PI/180, pitch, yaw, cx, cy,
|
|
|
|
hfovx = cg.refdef.fov_x/2, hfovy = cg.refdef.fov_y/2;
|
2003-09-17 23:49:29 +00:00
|
|
|
vec3_t end;
|
|
|
|
trace_t tr;
|
2004-01-26 21:26:09 +00:00
|
|
|
int timeDelta = 0, visible = 0;
|
2003-09-17 23:49:29 +00:00
|
|
|
|
2003-09-20 19:38:16 +00:00
|
|
|
cgs.flareFadeFactor = 0.0f;
|
|
|
|
|
|
|
|
VectorCopy(cgs.sunDir, dir);
|
2004-01-26 21:26:09 +00:00
|
|
|
dp[0] = DotProduct(dir, cg.refdef.viewaxis[0]);
|
|
|
|
dp[1] = DotProduct(dir, cg.refdef.viewaxis[1]);
|
|
|
|
dp[2] = DotProduct(dir, cg.refdef.viewaxis[2]);
|
|
|
|
|
|
|
|
//do a trace in the direction of the sun
|
2003-09-17 23:49:29 +00:00
|
|
|
VectorMA(cg.refdef.vieworg, 16384, dir, end);
|
|
|
|
CG_Trace(&tr, cg.refdef.vieworg, NULL, NULL, end, 0, CONTENTS_SOLID);
|
2003-09-20 19:38:16 +00:00
|
|
|
//if we hit the sky
|
|
|
|
if (tr.surfaceFlags & SURF_SKY)
|
2003-09-17 23:49:29 +00:00
|
|
|
{
|
2003-09-20 19:38:16 +00:00
|
|
|
yaw = 90.0f - acos(dp[1])/PI180;
|
|
|
|
pitch = 90.0f - acos(dp[2])/PI180;
|
|
|
|
|
2004-01-26 21:26:09 +00:00
|
|
|
cgs.flareForwardFactor = dp[0];
|
2003-09-20 19:38:16 +00:00
|
|
|
//if the sun is in fov
|
2004-01-26 21:26:09 +00:00
|
|
|
if (cgs.flareForwardFactor > 0 && abs(yaw) <= hfovx && abs(pitch) <= hfovy) {
|
2003-09-20 19:38:16 +00:00
|
|
|
//get the screen co-ordinates of the sun
|
|
|
|
#if 0
|
|
|
|
cx = 320 * (1.0f - dp[1] / (cos(yaw * PI180) * tan(hfovx * PI180)));
|
|
|
|
cy = 240 * (1.0f - dp[2] / (cos(pitch * PI180) * tan(hfovy * PI180)));
|
|
|
|
#else
|
|
|
|
//if we really needed them to be accurate, those above would be best
|
|
|
|
//but we actually don't !
|
|
|
|
cx = 320 * (1.0f - dp[1]);
|
|
|
|
cy = 240 * (1.0f - dp[2]);
|
|
|
|
#endif
|
|
|
|
cgs.lastSunX = cx;
|
|
|
|
cgs.lastSunY = cy;
|
|
|
|
cgs.lastSunTime = cg.time;
|
|
|
|
visible = qtrue;
|
|
|
|
cgs.flareFadeFactor = 1.0f;
|
|
|
|
}
|
|
|
|
//Note - we could do more traces if we hit transparent objects instead
|
|
|
|
//of the sky for example, but that would slow things down
|
2003-09-17 23:49:29 +00:00
|
|
|
}
|
2003-09-20 19:38:16 +00:00
|
|
|
if (!visible && cgs.lastSunTime) {
|
|
|
|
timeDelta = cg.time - cgs.lastSunTime;
|
|
|
|
if (timeDelta > FLARE_FADEOUT_TIME)
|
|
|
|
{
|
|
|
|
cgs.lastSunTime = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cgs.flareFadeFactor = 1.0f - (float)timeDelta / FLARE_FADEOUT_TIME;
|
2003-09-18 19:08:40 +00:00
|
|
|
}
|
2003-09-20 19:38:16 +00:00
|
|
|
//global vars
|
|
|
|
if (cg.refdef.fov_x < 90)
|
|
|
|
cgs.flareFovFactor = 5 - 0.05f * cg.refdef.fov_x;
|
|
|
|
else
|
|
|
|
cgs.flareFovFactor = 1.0f;
|
|
|
|
//finally, add the sun
|
|
|
|
if (cgs.sunFlareSize > 0 && cgs.sunAlpha > 0 && cgs.flareFadeFactor != 0.0f) {
|
|
|
|
refEntity_t ent;
|
|
|
|
|
|
|
|
memset(&ent, 0, sizeof(ent));
|
|
|
|
VectorCopy(tr.endpos, ent.origin);
|
|
|
|
ent.reType = RT_SPRITE;
|
|
|
|
ent.customShader = cgs.media.sunFlareShader;
|
|
|
|
//this function wouldn't be complete without some funny math
|
|
|
|
//this makes the sprite as big as the mapper wanted it to be
|
2005-02-15 16:33:39 +00:00
|
|
|
ent.radius = cgs.sunFlareSize * tr.fraction * 25.6f;
|
2003-09-20 19:38:16 +00:00
|
|
|
ent.renderfx = RF_DEPTHHACK;
|
|
|
|
ent.shaderRGBA[0] = cgs.flareFadeFactor * cgs.sunAlpha * 255;
|
|
|
|
ent.shaderRGBA[1] = ent.shaderRGBA[0];
|
|
|
|
ent.shaderRGBA[2] = ent.shaderRGBA[0];
|
|
|
|
ent.shaderRGBA[3] = ent.shaderRGBA[0];
|
|
|
|
trap_R_AddRefEntityToScene(&ent);
|
2003-09-18 19:08:40 +00:00
|
|
|
}
|
2004-03-07 17:39:11 +00:00
|
|
|
//speed hack
|
|
|
|
cgs.flareFadeFactor *= cg_RQ3_flareIntensity.value;
|
2003-09-20 19:38:16 +00:00
|
|
|
} else {
|
|
|
|
//add the reflection particles
|
2004-03-09 00:39:47 +00:00
|
|
|
if (cgs.flareFadeFactor != 0.0f)
|
|
|
|
{
|
2003-09-20 19:38:16 +00:00
|
|
|
float len = 0, color[4];
|
|
|
|
float size, hsize;
|
2005-02-15 16:33:39 +00:00
|
|
|
float ffov = cos(cg.refdef.fov_y/4);
|
2003-09-20 19:38:16 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
VectorSet(dir, 320-cgs.lastSunX, 240-cgs.lastSunY, 0);
|
|
|
|
len = 2 * VectorNormalize(dir);
|
|
|
|
for (i=0; i<cgs.numFlares; i++) {
|
2004-01-28 23:26:33 +00:00
|
|
|
float alpha = cg.flareColor[i][3] * cgs.flareFadeFactor;
|
2003-09-20 19:38:16 +00:00
|
|
|
size = cg.flareShaderSize[i] * cgs.flareFovFactor;
|
|
|
|
hsize = size/2.0f;
|
|
|
|
dp[2] = len / cgs.numFlares * (i+1);
|
|
|
|
dp[0] = cgs.lastSunX + dp[2] * dir[0];
|
|
|
|
dp[1] = cgs.lastSunY + dp[2] * dir[1];
|
2004-01-28 23:26:33 +00:00
|
|
|
color[0] = cg.flareColor[i][0] * alpha;
|
|
|
|
color[1] = cg.flareColor[i][1] * alpha;
|
|
|
|
color[2] = cg.flareColor[i][2] * alpha;
|
|
|
|
color[3] = 1.0f;
|
2003-09-20 19:38:16 +00:00
|
|
|
trap_R_SetColor(color);
|
|
|
|
CG_DrawPic(dp[0] - hsize, dp[1] - hsize, size, size,
|
|
|
|
cgs.media.flareShader[cg.flareShaderNum[i]]);
|
|
|
|
}
|
2005-02-15 16:33:39 +00:00
|
|
|
if (cgs.flareForwardFactor > ffov)
|
2004-03-09 00:39:47 +00:00
|
|
|
{
|
|
|
|
color[0] = color[1] = color[2] = 1.0f;
|
2005-02-15 16:33:39 +00:00
|
|
|
//color[3] = cgs.sunAlpha * cgs.flareForwardFactor * cgs.flareFadeFactor * FLARE_BLIND_ALPHA;
|
|
|
|
color[3] = (cgs.flareForwardFactor - ffov) / (1 - ffov) * cgs.flareFadeFactor * FLARE_BLIND_ALPHA;
|
2004-03-09 00:39:47 +00:00
|
|
|
//Makro - too expensive
|
|
|
|
//color[3] = cgs.sunAlpha * cgs.flareFadeFactor * FLARE_BLIND_ALPHA * (1.0f - abs(320 - cgs.lastSunX) / 320.0f) * (1.0f - abs(240 - cgs.lastSunY) / 240.0f);
|
2009-06-30 02:34:25 +00:00
|
|
|
CG_FillRect(cgs.screenXMin, 0, cgs.screenWidth, SCREEN_HEIGHT, color);
|
2004-03-09 00:39:47 +00:00
|
|
|
}
|
2003-09-17 23:49:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CG_DrawActiveFrame
|
|
|
|
|
|
|
|
Generates and draws a game scene and status information at the given time.
|
|
|
|
=================
|
|
|
|
*/
|
2002-06-16 20:06:15 +00:00
|
|
|
void CG_DrawActiveFrame(int serverTime, stereoFrame_t stereoView, qboolean demoPlayback)
|
|
|
|
{
|
|
|
|
int inwater;
|
2003-09-07 22:19:27 +00:00
|
|
|
int skyPortalMode = ADDENTS_NOSKYPORTAL;
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2001-09-16 04:04:31 +00:00
|
|
|
//Blaze: for cheat detection
|
2002-06-16 20:06:15 +00:00
|
|
|
int i;
|
|
|
|
float cvar_val;
|
|
|
|
|
2001-09-16 04:04:31 +00:00
|
|
|
//end Blaze
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.time = serverTime;
|
2003-03-09 21:30:39 +00:00
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.demoPlayback = demoPlayback;
|
|
|
|
|
|
|
|
// update cvars
|
|
|
|
CG_UpdateCvars();
|
|
|
|
|
|
|
|
// if we are only updating the screen as a loading
|
|
|
|
// pacifier, don't even try to read snapshots
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.infoScreenText[0] != 0) {
|
2001-05-06 20:50:27 +00:00
|
|
|
CG_DrawInformation();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// any looped sounds will be respecified as entities
|
|
|
|
// are added to the render list
|
|
|
|
trap_S_ClearLoopingSounds(qfalse);
|
|
|
|
|
|
|
|
// clear all the render lists
|
|
|
|
trap_R_ClearScene();
|
|
|
|
|
|
|
|
// set up cg.snap and possibly cg.nextSnap
|
|
|
|
CG_ProcessSnapshots();
|
|
|
|
|
|
|
|
// if we haven't received any snapshots yet, all
|
|
|
|
// we can draw is the information screen
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!cg.snap || (cg.snap->snapFlags & SNAPFLAG_NOT_ACTIVE)) {
|
2001-05-06 20:50:27 +00:00
|
|
|
CG_DrawInformation();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// let the client system know what our weapon and zoom settings are
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_SetUserCmdValue(cg.weaponSelect, cg.zoomSensitivity);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// this counter will be bumped for every valid scene we generate
|
|
|
|
cg.clientFrame++;
|
|
|
|
|
|
|
|
// update cg.predictedPlayerState
|
|
|
|
CG_PredictPlayerState();
|
|
|
|
|
|
|
|
// decide on third person view
|
2001-09-01 16:15:01 +00:00
|
|
|
// Elder: remove third-person death rendering
|
2002-06-16 20:06:15 +00:00
|
|
|
cg.renderingThirdPerson = cg_thirdPerson.integer; //|| (cg.snap->ps.stats[STAT_HEALTH] <= 0);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// build cg.refdef
|
|
|
|
inwater = CG_CalcViewValues();
|
|
|
|
|
|
|
|
// first person blend blobs, done after AnglesToAxis
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!cg.renderingThirdPerson) {
|
2001-05-06 20:50:27 +00:00
|
|
|
CG_DamageBlendBlob();
|
|
|
|
}
|
2002-07-13 22:43:59 +00:00
|
|
|
|
2002-09-01 21:15:08 +00:00
|
|
|
//Makro - these were a few lines below
|
|
|
|
cg.refdef.time = cg.time;
|
|
|
|
memcpy(cg.refdef.areamask, cg.snap->areamask, sizeof(cg.refdef.areamask));
|
|
|
|
|
2002-08-30 00:00:16 +00:00
|
|
|
//Makro - fog hull
|
2003-08-10 20:13:26 +00:00
|
|
|
if (cgs.clearColorSet) {
|
|
|
|
float fogcolor[4];
|
|
|
|
fogcolor[0] = cgs.clearColor[0];
|
|
|
|
fogcolor[1] = cgs.clearColor[1];
|
|
|
|
fogcolor[2] = cgs.clearColor[2];
|
|
|
|
fogcolor[3] = 1.0f;
|
2009-06-30 13:05:01 +00:00
|
|
|
CG_FillRect(cgs.screenXMin, 0, cgs.screenWidth, SCREEN_HEIGHT, fogcolor);
|
2002-08-30 00:00:16 +00:00
|
|
|
}
|
2003-03-28 22:26:24 +00:00
|
|
|
//CG_DrawBigPolygon();
|
2002-08-30 00:00:16 +00:00
|
|
|
|
2002-07-13 22:43:59 +00:00
|
|
|
//Makro - draw sky portal first
|
2003-08-10 20:13:26 +00:00
|
|
|
if (cgs.skyPortalSet) {
|
2002-09-01 21:15:08 +00:00
|
|
|
vec3_t oldOrigin;
|
2005-09-07 20:29:05 +00:00
|
|
|
|
2003-09-07 19:51:40 +00:00
|
|
|
CG_AddPacketEntities(ADDENTS_SKYPORTAL);
|
|
|
|
skyPortalMode = ADDENTS_NORMAL;
|
2002-09-01 21:15:08 +00:00
|
|
|
VectorCopy(cg.refdef.vieworg, oldOrigin);
|
2005-09-07 20:29:05 +00:00
|
|
|
//Makro - move the portal with the player
|
|
|
|
cg.refdef.vieworg[0] *= cgs.skyPortalMoveFactor[0];
|
|
|
|
cg.refdef.vieworg[1] *= cgs.skyPortalMoveFactor[1];
|
|
|
|
cg.refdef.vieworg[2] *= cgs.skyPortalMoveFactor[2];
|
|
|
|
VectorAdd(cgs.skyPortalOrigin, cg.refdef.vieworg, cg.refdef.vieworg);
|
|
|
|
|
2002-09-01 21:15:08 +00:00
|
|
|
trap_R_RenderScene(&cg.refdef);
|
|
|
|
VectorCopy(oldOrigin, cg.refdef.vieworg);
|
2002-07-13 22:43:59 +00:00
|
|
|
}
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
// build the render lists
|
2002-06-16 20:06:15 +00:00
|
|
|
if (!cg.hyperspace) {
|
2002-09-01 21:15:08 +00:00
|
|
|
CG_AddPacketEntities(skyPortalMode); // adter calcViewValues, so predicted player state is correct
|
2001-05-06 20:50:27 +00:00
|
|
|
CG_AddMarks();
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_AddParticles();
|
2001-05-06 20:50:27 +00:00
|
|
|
CG_AddLocalEntities();
|
2002-08-25 00:47:00 +00:00
|
|
|
CG_AddAtmosphericEffects(); // q3f atmospheric stuff: Add rain/snow etc.
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_AddViewWeapon(&cg.predictedPlayerState);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2001-07-28 14:12:11 +00:00
|
|
|
//Elder: check local laser status
|
|
|
|
//CG_CheckLaser();
|
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
// add buffered sounds
|
|
|
|
CG_PlayBufferedSounds();
|
|
|
|
|
|
|
|
// play buffered voice chats
|
|
|
|
CG_PlayBufferedVoiceChats();
|
|
|
|
|
|
|
|
// finish up the rest of the refdef
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.testModelEntity.hModel) {
|
2001-05-06 20:50:27 +00:00
|
|
|
CG_AddTestModel();
|
|
|
|
}
|
2002-09-01 21:15:08 +00:00
|
|
|
|
|
|
|
//Makro - moved a few lines up, before the sky portal code
|
|
|
|
//cg.refdef.time = cg.time;
|
|
|
|
//memcpy(cg.refdef.areamask, cg.snap->areamask, sizeof(cg.refdef.areamask));
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// warning sounds when powerup is wearing off
|
2007-02-03 15:02:21 +00:00
|
|
|
// CG_PowerupTimerSounds(); // JBravo: we dont use this ?
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// update audio positions
|
2002-06-16 20:06:15 +00:00
|
|
|
trap_S_Respatialize(cg.snap->ps.clientNum, cg.refdef.vieworg, cg.refdef.viewaxis, inwater);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
|
|
|
// make sure the lagometerSample and frame timing isn't done twice when in stereo
|
2002-06-16 20:06:15 +00:00
|
|
|
if (stereoView != STEREO_RIGHT) {
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.frametime = cg.time - cg.oldTime;
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.frametime < 0) {
|
2001-05-06 20:50:27 +00:00
|
|
|
cg.frametime = 0;
|
|
|
|
}
|
|
|
|
cg.oldTime = cg.time;
|
|
|
|
CG_AddLagometerFrameInfo();
|
|
|
|
}
|
|
|
|
if (cg_timescale.value != cg_timescaleFadeEnd.value) {
|
|
|
|
if (cg_timescale.value < cg_timescaleFadeEnd.value) {
|
2002-06-16 20:06:15 +00:00
|
|
|
cg_timescale.value += cg_timescaleFadeSpeed.value * ((float) cg.frametime) / 1000;
|
2001-05-06 20:50:27 +00:00
|
|
|
if (cg_timescale.value > cg_timescaleFadeEnd.value)
|
|
|
|
cg_timescale.value = cg_timescaleFadeEnd.value;
|
2002-06-16 20:06:15 +00:00
|
|
|
} else {
|
|
|
|
cg_timescale.value -= cg_timescaleFadeSpeed.value * ((float) cg.frametime) / 1000;
|
2001-05-06 20:50:27 +00:00
|
|
|
if (cg_timescale.value < cg_timescaleFadeEnd.value)
|
|
|
|
cg_timescale.value = cg_timescaleFadeEnd.value;
|
|
|
|
}
|
|
|
|
if (cg_timescaleFadeSpeed.value) {
|
|
|
|
trap_Cvar_Set("timescale", va("%f", cg_timescale.value));
|
|
|
|
}
|
|
|
|
}
|
2003-09-17 23:49:29 +00:00
|
|
|
|
2001-05-06 20:50:27 +00:00
|
|
|
// actually issue the rendering calls
|
2002-06-16 20:06:15 +00:00
|
|
|
CG_DrawActive(stereoView);
|
2001-05-06 20:50:27 +00:00
|
|
|
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg_stats.integer) {
|
|
|
|
CG_Printf("cg.clientFrame:%i\n", cg.clientFrame);
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|
2001-10-11 22:50:58 +00:00
|
|
|
//if ((cg.time - cgs.levelStartTime) / 10000 == 1)
|
|
|
|
// Elder: working timer implementation
|
2002-06-16 20:06:15 +00:00
|
|
|
if (cg.time > cg.cvarCheckTime) {
|
2001-10-11 22:50:58 +00:00
|
|
|
//cg.cvarCheckTime = cg.time + 5000 + rand() % 6000;
|
|
|
|
cg.cvarCheckTime = cg.time + 10000;
|
2002-08-29 04:42:41 +00:00
|
|
|
if (0 == CG_Cvar_Get("ogc_islame"))
|
|
|
|
{
|
|
|
|
Com_Error(ERR_DISCONNECT, "No OGC plzkthx");
|
|
|
|
}
|
2001-09-16 04:04:31 +00:00
|
|
|
//Blaze: Check for invalid video settings.
|
2002-06-16 20:06:15 +00:00
|
|
|
for (i = 0; i < 30; i++) {
|
|
|
|
if (strcmp(cheats[i].cvar, "") != 0) {
|
2001-09-16 04:04:31 +00:00
|
|
|
cvar_val = CG_Cvar_Get(cheats[i].cvar);
|
|
|
|
//CG_Printf("%s is set to %f\n",cheats[i].cvar, cvar_val);
|
2002-06-16 20:06:15 +00:00
|
|
|
if ((cvar_val < cheats[i].low || cvar_val > cheats[i].high)) {
|
|
|
|
CG_Printf("This server restricts %s to be between %1.11f and %1.11f\n",
|
|
|
|
cheats[i].cvar, cheats[i].low, cheats[i].high);
|
2002-03-07 14:51:57 +00:00
|
|
|
//Makro - a Com_Error would be nicer
|
|
|
|
//trap_Cvar_Set("RQ3_CvarKickReason", cheats[i].cvar );
|
|
|
|
//trap_SendConsoleCommand(va("disconnect\n"));
|
2002-06-16 20:06:15 +00:00
|
|
|
Com_Error(ERR_DISCONNECT,
|
|
|
|
"WARNING: You have been disconnected from the server because %s was out of range (%f - %f)",
|
|
|
|
cheats[i].cvar, cheats[i].low, cheats[i].high);
|
2001-09-16 04:04:31 +00:00
|
|
|
}
|
2001-11-25 23:04:08 +00:00
|
|
|
|
2001-09-16 04:04:31 +00:00
|
|
|
}
|
2001-11-25 23:04:08 +00:00
|
|
|
|
2001-09-16 04:04:31 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-06 20:50:27 +00:00
|
|
|
}
|