mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-02-17 01:21:47 +00:00
Made spectator / follow mode use similar view to death cam
This commit is contained in:
parent
55c06408ed
commit
76f2b49ee0
8 changed files with 72 additions and 35 deletions
|
@ -2725,10 +2725,17 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
|
||||||
vec3_t baseOrg;
|
vec3_t baseOrg;
|
||||||
VectorCopy( cg.refdef.vieworg, baseOrg );
|
VectorCopy( cg.refdef.vieworg, baseOrg );
|
||||||
|
|
||||||
float worldscale = trap_Cvar_VariableValue("vr_worldscale") *
|
float worldscale = trap_Cvar_VariableValue("vr_worldscale");
|
||||||
(( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) &&
|
if (cg.snap->ps.pm_type == PM_SPECTATOR ||
|
||||||
( cg.snap->ps.pm_type != PM_INTERMISSION ) ? DEATH_WORLDSCALE_MULTIPLIER : 1.0f);
|
(cg.snap->ps.pm_flags & PMF_FOLLOW))
|
||||||
|
{
|
||||||
|
worldscale *= SPECTATOR_WORLDSCALE_MULTIPLIER;
|
||||||
|
}
|
||||||
|
else if (( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) &&
|
||||||
|
( cg.snap->ps.pm_type != PM_INTERMISSION ))
|
||||||
|
{
|
||||||
|
worldscale *= DEATH_WORLDSCALE_MULTIPLIER;
|
||||||
|
}
|
||||||
|
|
||||||
float ipd = trap_Cvar_VariableValue("r_stereoSeparation") / 1000.0f;
|
float ipd = trap_Cvar_VariableValue("r_stereoSeparation") / 1000.0f;
|
||||||
float separation = worldscale * (ipd / 2) * (stereoView == STEREO_LEFT ? -1.0f : 1.0f);
|
float separation = worldscale * (ipd / 2) * (stereoView == STEREO_LEFT ? -1.0f : 1.0f);
|
||||||
|
|
|
@ -77,7 +77,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#define NUM_CROSSHAIRS 10
|
#define NUM_CROSSHAIRS 10
|
||||||
|
|
||||||
//multiplying size you go to when dead looking down on the match
|
//multiplying size you go to when dead looking down on the match
|
||||||
#define DEATH_WORLDSCALE_MULTIPLIER 40
|
#define DEATH_WORLDSCALE_MULTIPLIER 40
|
||||||
|
#define SPECTATOR_WORLDSCALE_MULTIPLIER 10
|
||||||
|
|
||||||
#define PLAYER_HEIGHT 48
|
#define PLAYER_HEIGHT 48
|
||||||
|
|
||||||
|
@ -631,7 +632,6 @@ typedef struct {
|
||||||
float v_dmg_time;
|
float v_dmg_time;
|
||||||
float v_dmg_pitch;
|
float v_dmg_pitch;
|
||||||
float v_dmg_roll;
|
float v_dmg_roll;
|
||||||
vec3_t v_death_origin;
|
|
||||||
|
|
||||||
// temp working variables for player view
|
// temp working variables for player view
|
||||||
float bobfracsin;
|
float bobfracsin;
|
||||||
|
|
|
@ -220,21 +220,32 @@ static void CG_CalcVrect (void) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
CG_OffsetDeathView
|
CG_OffsetVRThirdPersonView
|
||||||
|
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
static void CG_OffsetDeathView( void ) {
|
static void CG_OffsetVRThirdPersonView( void ) {
|
||||||
|
float scale = 1.0f;
|
||||||
|
|
||||||
vec3_t position_delta;
|
if (cg.predictedPlayerState.pm_type == PM_SPECTATOR ||
|
||||||
VectorNegate(vr->hmdposition_delta, position_delta);
|
(cg.predictedPlayerState.pm_flags & PMF_FOLLOW))
|
||||||
CG_ConvertFromVR(position_delta, NULL, position_delta);
|
{
|
||||||
position_delta[2] = 0;
|
scale *= SPECTATOR_WORLDSCALE_MULTIPLIER;
|
||||||
VectorScale(position_delta, (DEATH_WORLDSCALE_MULTIPLIER / 2), position_delta);
|
}
|
||||||
|
else if (( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) &&
|
||||||
|
( cg.predictedPlayerState.pm_type != PM_INTERMISSION ))
|
||||||
|
{
|
||||||
|
scale *= DEATH_WORLDSCALE_MULTIPLIER;
|
||||||
|
}
|
||||||
|
|
||||||
VectorAdd(cg.v_death_origin, position_delta, cg.v_death_origin);
|
{
|
||||||
VectorCopy(cg.v_death_origin, cg.refdef.vieworg);
|
vec3_t position;
|
||||||
cg.refdef.vieworg[2] += DEATH_WORLDSCALE_MULTIPLIER * cg.predictedPlayerState.viewheight;
|
VectorCopy(vr->hmdposition, position);
|
||||||
|
CG_ConvertFromVR(position, NULL, position);
|
||||||
|
position[2] = 0;
|
||||||
|
VectorScale(position, scale, position);
|
||||||
|
VectorAdd(cg.refdef.vieworg, position, cg.refdef.vieworg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -255,8 +266,6 @@ static void CG_OffsetThirdPersonView( void ) {
|
||||||
float focusDist;
|
float focusDist;
|
||||||
float forwardScale, sideScale;
|
float forwardScale, sideScale;
|
||||||
|
|
||||||
VectorCopy(cg.refdef.vieworg, cg.v_death_origin);
|
|
||||||
|
|
||||||
cg.refdef.vieworg[2] += cg.predictedPlayerState.viewheight;
|
cg.refdef.vieworg[2] += cg.predictedPlayerState.viewheight;
|
||||||
|
|
||||||
VectorCopy( cg.refdefViewAngles, focusAngles );
|
VectorCopy( cg.refdefViewAngles, focusAngles );
|
||||||
|
@ -348,8 +357,6 @@ static void CG_OffsetFirstPersonView( void ) {
|
||||||
origin = cg.refdef.vieworg;
|
origin = cg.refdef.vieworg;
|
||||||
angles = cg.refdefViewAngles;
|
angles = cg.refdefViewAngles;
|
||||||
|
|
||||||
VectorCopy(cg.refdef.vieworg, cg.v_death_origin);
|
|
||||||
|
|
||||||
float hitRollCoeff = trap_Cvar_VariableValue("vr_rollWhenHit");
|
float hitRollCoeff = trap_Cvar_VariableValue("vr_rollWhenHit");
|
||||||
|
|
||||||
// add angles based on damage kick
|
// add angles based on damage kick
|
||||||
|
@ -638,8 +645,9 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
||||||
|
|
||||||
//HACK!! - should change this to a renderer function call
|
//HACK!! - should change this to a renderer function call
|
||||||
//Indicate to renderer whether we are in deathcam mode, We don't want sky in death cam mode
|
//Indicate to renderer whether we are in deathcam mode, We don't want sky in death cam mode
|
||||||
trap_Cvar_Set( "vr_deathCam", ((ps->stats[STAT_HEALTH] <= 0) &&
|
trap_Cvar_Set( "vr_noSkybox", (((ps->stats[STAT_HEALTH] <= 0) &&
|
||||||
( ps->pm_type != PM_INTERMISSION )) ? "1" : "0" );
|
( ps->pm_type != PM_INTERMISSION )) || ps->pm_type == PM_SPECTATOR ||
|
||||||
|
(ps->pm_flags & PMF_FOLLOW)) ? "1" : "0" );
|
||||||
|
|
||||||
// intermission view
|
// intermission view
|
||||||
static float hmdYaw = 0;
|
static float hmdYaw = 0;
|
||||||
|
@ -694,9 +702,11 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cg.snap->ps.stats[STAT_HEALTH] <= 0) {
|
if (cg.snap->ps.stats[STAT_HEALTH] <= 0 ||
|
||||||
//If dead, view the map from above
|
ps->pm_type == PM_SPECTATOR ||
|
||||||
CG_OffsetDeathView();
|
ps->pm_flags & PMF_FOLLOW) {
|
||||||
|
//If dead, or spectating, view the map from above
|
||||||
|
CG_OffsetVRThirdPersonView();
|
||||||
} else if ( cg.renderingThirdPerson ) {
|
} else if ( cg.renderingThirdPerson ) {
|
||||||
// back away from character
|
// back away from character
|
||||||
CG_OffsetThirdPersonView();
|
CG_OffsetThirdPersonView();
|
||||||
|
@ -705,7 +715,7 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
||||||
CG_OffsetFirstPersonView();
|
CG_OffsetFirstPersonView();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stereoView == STEREO_LEFT)
|
if (!cgs.localServer && stereoView == STEREO_LEFT)
|
||||||
{
|
{
|
||||||
VectorCopy(vr->calculated_weaponangles, vr->last_calculated_weaponangles);
|
VectorCopy(vr->calculated_weaponangles, vr->last_calculated_weaponangles);
|
||||||
|
|
||||||
|
@ -769,7 +779,17 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
||||||
VectorCopy(cg.refdefViewAngles, angles);
|
VectorCopy(cg.refdefViewAngles, angles);
|
||||||
angles[ROLL] = vr->hmdorientation[ROLL];
|
angles[ROLL] = vr->hmdorientation[ROLL];
|
||||||
AnglesToAxis( angles, cg.refdef.viewaxis );
|
AnglesToAxis( angles, cg.refdef.viewaxis );
|
||||||
} else {
|
}
|
||||||
|
else if (ps->pm_flags & PMF_FOLLOW)
|
||||||
|
{
|
||||||
|
//If we're following someone,
|
||||||
|
vec3_t angles;
|
||||||
|
VectorCopy(vr->hmdorientation, angles);
|
||||||
|
angles[YAW] = vr->clientviewangles[YAW];
|
||||||
|
AnglesToAxis(angles, cg.refdef.viewaxis);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//We are connected to a multiplayer server, so make the appropriate adjustment to the view
|
//We are connected to a multiplayer server, so make the appropriate adjustment to the view
|
||||||
//angles as we send orientation to the server that includes the weapon angles
|
//angles as we send orientation to the server that includes the weapon angles
|
||||||
vec3_t angles;
|
vec3_t angles;
|
||||||
|
@ -783,7 +803,7 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
||||||
vec3_t angles;
|
vec3_t angles;
|
||||||
angles[ROLL] = vr->hmdorientation[ROLL];
|
angles[ROLL] = vr->hmdorientation[ROLL];
|
||||||
angles[PITCH] = vr->weaponangles[PITCH];
|
angles[PITCH] = vr->weaponangles[PITCH];
|
||||||
angles[YAW] = (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]) + vr->last_calculated_weaponangles[YAW];
|
angles[YAW] = (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]) + vr->weaponangles[YAW];
|
||||||
AnglesToAxis(angles, cg.refdef.viewaxis);
|
AnglesToAxis(angles, cg.refdef.viewaxis);
|
||||||
} else {
|
} else {
|
||||||
AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
|
AnglesToAxis(cg.refdefViewAngles, cg.refdef.viewaxis);
|
||||||
|
@ -906,8 +926,9 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
|
||||||
CG_PredictPlayerState();
|
CG_PredictPlayerState();
|
||||||
|
|
||||||
// decide on third person view
|
// decide on third person view
|
||||||
cg.renderingThirdPerson = cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR
|
cg.renderingThirdPerson = cg.predictedPlayerState.pm_type == PM_SPECTATOR ||
|
||||||
&& cg_thirdPerson.integer;
|
cg.predictedPlayerState.pm_flags & PMF_FOLLOW ||
|
||||||
|
cg_thirdPerson.integer;
|
||||||
|
|
||||||
// build cg.refdef
|
// build cg.refdef
|
||||||
inwater = CG_CalcViewValues( stereoView );
|
inwater = CG_CalcViewValues( stereoView );
|
||||||
|
|
|
@ -255,8 +255,17 @@ void CG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles );
|
||||||
|
|
||||||
void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles )
|
void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles )
|
||||||
{
|
{
|
||||||
|
if (cg.predictedPlayerState.pm_type == PM_SPECTATOR ||
|
||||||
|
cg.predictedPlayerState.pm_flags & PMF_FOLLOW)
|
||||||
|
{
|
||||||
|
CG_CalculateWeaponPosition(origin, angles);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float worldscale = trap_Cvar_VariableValue("vr_worldscale");
|
float worldscale = trap_Cvar_VariableValue("vr_worldscale");
|
||||||
|
|
||||||
if (!cgs.localServer)
|
if (!cgs.localServer)
|
||||||
|
|
|
@ -74,7 +74,7 @@ cvar_t *r_measureOverdraw;
|
||||||
|
|
||||||
cvar_t *r_inGameVideo;
|
cvar_t *r_inGameVideo;
|
||||||
cvar_t *r_fastsky;
|
cvar_t *r_fastsky;
|
||||||
cvar_t *vr_deathCam;
|
cvar_t *vr_noSkybox;
|
||||||
cvar_t *r_drawSun;
|
cvar_t *r_drawSun;
|
||||||
cvar_t *r_dynamiclight;
|
cvar_t *r_dynamiclight;
|
||||||
cvar_t *r_dlightBacks;
|
cvar_t *r_dlightBacks;
|
||||||
|
@ -1312,7 +1312,7 @@ void R_Register( void )
|
||||||
r_useFlush = ri.Cvar_Get( "r_useFlush", "1", CVAR_ARCHIVE );
|
r_useFlush = ri.Cvar_Get( "r_useFlush", "1", CVAR_ARCHIVE );
|
||||||
r_ignoreGLErrors = ri.Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE );
|
r_ignoreGLErrors = ri.Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE );
|
||||||
r_fastsky = ri.Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE );
|
r_fastsky = ri.Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE );
|
||||||
vr_deathCam = ri.Cvar_Get( "vr_deathCam", "0", CVAR_TEMP );
|
vr_noSkybox = ri.Cvar_Get( "vr_noSkybox", "0", CVAR_TEMP );
|
||||||
r_inGameVideo = ri.Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE );
|
r_inGameVideo = ri.Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE );
|
||||||
r_drawSun = ri.Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE );
|
r_drawSun = ri.Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE );
|
||||||
r_dynamiclight = ri.Cvar_Get( "r_dynamiclight", "0", CVAR_ARCHIVE );
|
r_dynamiclight = ri.Cvar_Get( "r_dynamiclight", "0", CVAR_ARCHIVE );
|
||||||
|
|
|
@ -1701,7 +1701,7 @@ extern cvar_t *r_lodscale;
|
||||||
|
|
||||||
extern cvar_t *r_inGameVideo; // controls whether in game video should be draw
|
extern cvar_t *r_inGameVideo; // controls whether in game video should be draw
|
||||||
extern cvar_t *r_fastsky; // controls whether sky should be cleared or drawn
|
extern cvar_t *r_fastsky; // controls whether sky should be cleared or drawn
|
||||||
extern cvar_t *vr_deathCam; //
|
extern cvar_t *vr_noSkybox; //
|
||||||
extern cvar_t *r_drawSun; // controls drawing of sun quad
|
extern cvar_t *r_drawSun; // controls drawing of sun quad
|
||||||
extern cvar_t *r_dynamiclight; // dynamic lights enabled/disabled
|
extern cvar_t *r_dynamiclight; // dynamic lights enabled/disabled
|
||||||
extern cvar_t *r_dlightBacks; // dlight non-facing surfaces for continuity
|
extern cvar_t *r_dlightBacks; // dlight non-facing surfaces for continuity
|
||||||
|
|
|
@ -843,7 +843,7 @@ Other things could be stuck in here, like birds in the sky, etc
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void RB_StageIteratorSky( void ) {
|
void RB_StageIteratorSky( void ) {
|
||||||
if ( r_fastsky->integer || vr_deathCam->integer ) {
|
if ( r_fastsky->integer || vr_noSkybox->integer ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ void VR_ClearFrameBuffer( GLuint frameBuffer, int width, int height)
|
||||||
glEnable( GL_SCISSOR_TEST );
|
glEnable( GL_SCISSOR_TEST );
|
||||||
glViewport( 0, 0, width, height );
|
glViewport( 0, 0, width, height );
|
||||||
|
|
||||||
if (Cvar_VariableIntegerValue("vr_deathCam"))
|
if (Cvar_VariableIntegerValue("vr_noSkybox"))
|
||||||
{
|
{
|
||||||
//Blood red.. ish
|
//Blood red.. ish
|
||||||
glClearColor( 0.12f, 0.0f, 0.05f, 1.0f );
|
glClearColor( 0.12f, 0.0f, 0.05f, 1.0f );
|
||||||
|
|
Loading…
Reference in a new issue