mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 06:41:58 +00:00
Second Spectator Mode
- Looks same as deathcam - Player can also now fly about the map in deathcam/spectator mode 2 using the off hand thumbstick
This commit is contained in:
parent
e3ec4191f7
commit
3fb6a4945a
8 changed files with 67 additions and 40 deletions
|
@ -2784,10 +2784,11 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
|
|||
//Just move camera down about 20cm
|
||||
heightOffset = -0.2f;
|
||||
}
|
||||
else if (( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) &&
|
||||
( cg.snap->ps.pm_type != PM_INTERMISSION ))
|
||||
else if ((( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) &&
|
||||
( cg.snap->ps.pm_type != PM_INTERMISSION )) ||
|
||||
(cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON_2))
|
||||
{
|
||||
worldscale *= DEATH_WORLDSCALE_MULTIPLIER;
|
||||
worldscale *= SPECTATOR2_WORLDSCALE_MULTIPLIER;
|
||||
//Just move camera down about 50cm
|
||||
heightOffset = -0.5f;
|
||||
}
|
||||
|
@ -2812,7 +2813,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
|
|||
if (cg.snap->ps.stats[STAT_HEALTH] > 0 &&
|
||||
//Don't use fake positional if following another player - this is handled in the
|
||||
//VR third person code
|
||||
!( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON)))
|
||||
!( cg.demoPlayback || CG_IsThirdPersonFollowMode()))
|
||||
{
|
||||
vec3_t pos, hmdposition, vieworg;
|
||||
VectorClear(pos);
|
||||
|
|
|
@ -77,7 +77,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#define NUM_CROSSHAIRS 10
|
||||
|
||||
//multiplying size you go to when dead looking down on the match
|
||||
#define DEATH_WORLDSCALE_MULTIPLIER 30
|
||||
#define SPECTATOR2_WORLDSCALE_MULTIPLIER 30
|
||||
#define SPECTATOR_WORLDSCALE_MULTIPLIER 10
|
||||
|
||||
#define PLAYER_HEIGHT 48
|
||||
|
@ -1265,6 +1265,7 @@ void CG_TestModelPrevSkin_f (void);
|
|||
void CG_ZoomDown_f( void );
|
||||
void CG_ZoomUp_f( void );
|
||||
void CG_AddBufferedSound( sfxHandle_t sfx);
|
||||
qboolean CG_IsThirdPersonFollowMode( void );
|
||||
|
||||
void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );
|
||||
|
||||
|
|
|
@ -1998,7 +1998,7 @@ static void CG_PlayerSprites( centity_t *cent ) {
|
|||
//Put a sprite over the followed player's head
|
||||
if ( cent->currentState.number == cg.snap->ps.clientNum &&
|
||||
cg.renderingThirdPerson &&
|
||||
(cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON)) {
|
||||
CG_IsThirdPersonFollowMode()) {
|
||||
CG_PlayerFloatSprite( cent, cgs.media.friendShader );
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -227,7 +227,9 @@ CG_OffsetVRThirdPersonView
|
|||
static void CG_OffsetVRThirdPersonView( void ) {
|
||||
float scale = 1.0f;
|
||||
|
||||
if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON))
|
||||
//Follow mode 1
|
||||
if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW &&
|
||||
vr->follow_mode == VRFM_THIRDPERSON))
|
||||
{
|
||||
scale *= SPECTATOR_WORLDSCALE_MULTIPLIER;
|
||||
|
||||
|
@ -248,11 +250,20 @@ static void CG_OffsetVRThirdPersonView( void ) {
|
|||
VectorMA( cg.vr_vieworigin, -60, forward, cg.vr_vieworigin );
|
||||
}
|
||||
}
|
||||
else if (( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) &&
|
||||
( cg.predictedPlayerState.pm_type != PM_INTERMISSION ))
|
||||
//Death or follow mode 2
|
||||
else if ((( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) &&
|
||||
( cg.predictedPlayerState.pm_type != PM_INTERMISSION )) ||
|
||||
(cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON_2))
|
||||
{
|
||||
scale *= DEATH_WORLDSCALE_MULTIPLIER;
|
||||
VectorCopy(cg.refdef.vieworg, cg.vr_vieworigin);
|
||||
scale *= SPECTATOR2_WORLDSCALE_MULTIPLIER;
|
||||
|
||||
//Move camera if the user is pushing thumbstick
|
||||
vec3_t angles, forward, right, up;
|
||||
VectorCopy(vr->offhandangles, angles);
|
||||
angles[YAW] += (vr->clientviewangles[YAW] - vr->hmdorientation[YAW]);
|
||||
AngleVectors(angles, forward, right, up);
|
||||
VectorMA(cg.vr_vieworigin, vr->thumbstick_location[THUMB_LEFT][1] * 5.0f, forward, cg.vr_vieworigin);
|
||||
VectorMA(cg.vr_vieworigin, vr->thumbstick_location[THUMB_LEFT][0] * 5.0f, right, cg.vr_vieworigin);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -664,7 +675,7 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
|||
trap_Cvar_Set( "vr_noSkybox", (((ps->stats[STAT_HEALTH] <= 0) &&
|
||||
( ps->pm_type != PM_INTERMISSION )) ||
|
||||
cg.demoPlayback ||
|
||||
(cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON) ? "1" : "0" ));
|
||||
CG_IsThirdPersonFollowMode() ? "1" : "0" ));
|
||||
|
||||
// intermission view
|
||||
static float hmdYaw = 0;
|
||||
|
@ -721,12 +732,14 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
|||
|
||||
if (( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) &&
|
||||
( cg.predictedPlayerState.pm_type != PM_INTERMISSION ) ||
|
||||
( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON)))
|
||||
( cg.demoPlayback || CG_IsThirdPersonFollowMode()))
|
||||
{
|
||||
//If dead, or spectating, view the map from above
|
||||
CG_OffsetVRThirdPersonView();
|
||||
}
|
||||
else if ( cg.renderingThirdPerson )
|
||||
else
|
||||
{
|
||||
if (cg.renderingThirdPerson)
|
||||
{
|
||||
// back away from character
|
||||
CG_OffsetThirdPersonView();
|
||||
|
@ -737,6 +750,10 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
|||
CG_OffsetFirstPersonView();
|
||||
}
|
||||
|
||||
//Reset this in case we die or follow
|
||||
VectorCopy(cg.refdef.vieworg, cg.vr_vieworigin);
|
||||
}
|
||||
|
||||
if (!cgs.localServer && stereoView == STEREO_LEFT)
|
||||
{
|
||||
vec3_t weaponorigin, weaponangles;
|
||||
|
@ -808,7 +825,7 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
|||
angles[ROLL] = vr->hmdorientation[ROLL];
|
||||
AnglesToAxis( angles, cg.refdef.viewaxis );
|
||||
}
|
||||
else if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON))
|
||||
else if ( cg.demoPlayback || CG_IsThirdPersonFollowMode())
|
||||
{
|
||||
//If we're following someone,
|
||||
vec3_t angles;
|
||||
|
@ -838,7 +855,7 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
|||
angles[YAW] = (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]) + vr->weaponangles[YAW];
|
||||
AnglesToAxis(angles, cg.refdef.viewaxis);
|
||||
}
|
||||
else if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON))
|
||||
else if ( cg.demoPlayback || CG_IsThirdPersonFollowMode())
|
||||
{
|
||||
//If we're following someone,
|
||||
vec3_t angles;
|
||||
|
@ -918,6 +935,12 @@ static void CG_PlayBufferedSounds( void ) {
|
|||
|
||||
//=========================================================================
|
||||
|
||||
qboolean CG_IsThirdPersonFollowMode( void )
|
||||
{
|
||||
return cg.snap->ps.pm_flags & PMF_FOLLOW &&
|
||||
(vr->follow_mode == VRFM_THIRDPERSON || vr->follow_mode == VRFM_THIRDPERSON_2);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CG_DrawActiveFrame
|
||||
|
@ -971,7 +994,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
|
|||
|
||||
// decide on third person view
|
||||
cg.renderingThirdPerson = cg.predictedPlayerState.pm_type == PM_SPECTATOR ||
|
||||
cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_THIRDPERSON) ||
|
||||
cg.demoPlayback || CG_IsThirdPersonFollowMode() ||
|
||||
cg_thirdPerson.integer;
|
||||
|
||||
// build cg.refdef
|
||||
|
|
|
@ -2110,9 +2110,9 @@ void CG_DrawWeaponSelector( void )
|
|||
}
|
||||
else //selectorMode == WS_HMD
|
||||
{
|
||||
if (length(vr->thumbstick_location[0], vr->thumbstick_location[1]) > 0.95f)
|
||||
if (length(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]) > 0.95f)
|
||||
{
|
||||
float a = atan2(vr->thumbstick_location[0], vr->thumbstick_location[1]);
|
||||
float a = atan2(vr->thumbstick_location[THUMB_RIGHT][0], vr->thumbstick_location[THUMB_RIGHT][1]);
|
||||
x = sinf(a) * 0.95f;
|
||||
y = cosf(a) * 0.95f;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
|
||||
#define NUM_WEAPON_SAMPLES 10
|
||||
|
||||
typedef enum {
|
||||
VRFM_THIRDPERSON,
|
||||
VRFM_FIRSTPERSON
|
||||
} followMode_t;
|
||||
#define THUMB_LEFT 0
|
||||
#define THUMB_RIGHT 1
|
||||
|
||||
typedef struct {
|
||||
qboolean weapon_stabilised;
|
||||
|
@ -18,7 +16,7 @@ typedef struct {
|
|||
qboolean right_handed;
|
||||
qboolean virtual_screen;
|
||||
qboolean local_server; // used in bg_pmove.c
|
||||
followMode_t follow_mode;
|
||||
vrFollowMode_t follow_mode;
|
||||
qboolean weapon_select;
|
||||
qboolean smooth_turning;
|
||||
|
||||
|
@ -50,7 +48,7 @@ typedef struct {
|
|||
vec3_t offhandoffset_last[2];
|
||||
vec3_t offhandposition;
|
||||
|
||||
vec2_t thumbstick_location;
|
||||
vec2_t thumbstick_location[2]; //left / right thumbstick locations - used in cgame
|
||||
|
||||
//////////////////////////////////////
|
||||
// Test stuff for weapon alignment
|
||||
|
|
|
@ -463,11 +463,8 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
|
|||
char action[256];
|
||||
vrController_t* controller = isRightController == qtrue ? &rightController : &leftController;
|
||||
|
||||
if (isRightController)
|
||||
{
|
||||
vr.thumbstick_location[0] = joystickX;
|
||||
vr.thumbstick_location[1] = joystickY;
|
||||
}
|
||||
vr.thumbstick_location[isRightController][0] = joystickX;
|
||||
vr.thumbstick_location[isRightController][1] = joystickY;
|
||||
|
||||
if (vr.virtual_screen ||
|
||||
cl.snap.ps.pm_type == PM_INTERMISSION)
|
||||
|
@ -995,7 +992,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
|
|||
if (cl.snap.ps.pm_flags & PMF_FOLLOW)
|
||||
{
|
||||
//Switch follow mode
|
||||
vr.follow_mode = 1 - vr.follow_mode;
|
||||
vr.follow_mode = (vr.follow_mode+1) % VRFM_NUM_FOLLOWMODES;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -38,4 +38,11 @@ typedef enum {
|
|||
WS_PREVNEXT
|
||||
} weaponSelectorType_t;
|
||||
|
||||
typedef enum {
|
||||
VRFM_THIRDPERSON, //Camera will auto move to keep up with player
|
||||
VRFM_THIRDPERSON_2, //Camera is completely free movement with the thumbstick
|
||||
VRFM_FIRSTPERSON, //Obvious isn't it?..
|
||||
VRFM_NUM_FOLLOWMODES
|
||||
} vrFollowMode_t;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue