Lots of good stuff..

- Flashlight from "backpack"
- HUD now visible (with some stereo depth)
- PDA now has a functional mouse pointer
- Interaction with screens is by pointing the weapon controller rather than gaze based
- Default SS is now 1.0
- Default refresh rate is 60hz
This commit is contained in:
Simon 2020-09-16 00:02:29 +01:00
parent e096223048
commit ec594e1357
19 changed files with 93 additions and 3224 deletions

View file

@ -49,7 +49,6 @@ Copyright : Copyright 2015 Oculus VR, LLC. All Rights reserved.
bool Doom3Quest_initialised;
float playerYaw;
float vrFOV;
float vr_weapon_pitchadjust = -30.0f;
bool vr_moveuseoffhand;
float vr_snapturn_angle;
bool vr_switchsticks;
@ -88,11 +87,11 @@ int CPU_LEVEL = 4;
int GPU_LEVEL = 4;
int NUM_MULTI_SAMPLES = 1;
int FFR = 0;
float SS_MULTIPLIER = 1.25f;
int DISPLAY_REFRESH = 72;
float SS_MULTIPLIER = 1.0f;
int DISPLAY_REFRESH = 60;
vr_client_info_t vr;
vr_client_info_t *pVRClientInfo;
vrClientInfo vr;
vrClientInfo *pVRClientInfo;
jclass clazz;
@ -1263,9 +1262,6 @@ void VR_Init()
//init randomiser
srand(time(NULL));
//Initialise our cvar holders
vr_weapon_pitchadjust = -30.0f;
shutdown = false;
}

View file

@ -31,7 +31,7 @@ typedef struct {
vec3_t hmdorientation_last; // Don't use this, it is just for calculating delta!
vec3_t hmdorientation_delta;
vec3_t weaponangles_flashlight;
vec3_t weaponangles_unadjusted;
vec3_t weaponangles;
vec3_t weaponangles_last; // Don't use this, it is just for calculating delta!
vec3_t weaponangles_delta;
@ -75,9 +75,9 @@ typedef struct {
vec3_t test_angles;
vec3_t test_offset;
} vr_client_info_t;
} vrClientInfo;
extern vr_client_info_t *pVRClientInfo;
extern vrClientInfo *pVRClientInfo;
#ifdef __cplusplus
}

View file

@ -21,10 +21,10 @@ Authors : Simon Brown
float vr_turn_mode = 0.0f;
float vr_turn_angle = 45.0f;
float vr_reloadtimeoutms;
float vr_walkdirection;
float vr_reloadtimeoutms = 200.0f;
float vr_walkdirection = 0;
float vr_movement_multiplier;
float vr_weapon_pitchadjust;
float vr_weapon_pitchadjust = -30.0f;
float vr_lasersight;
float vr_control_scheme;
float vr_teleport;
@ -128,7 +128,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
vec3_t rotation = {0};
rotation[PITCH] = 30;
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, pVRClientInfo->weaponangles_flashlight);
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, pVRClientInfo->weaponangles_unadjusted);
rotation[PITCH] = vr_weapon_pitchadjust;
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, pVRClientInfo->weaponangles);
@ -174,15 +174,16 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
(pOffTrackedRemoteNew->Buttons & offButton2)) {
Android_SetCommand("loadgame quick");
}
} else {
} else
{
//PDA
if (((pOffTrackedRemoteNew->Buttons & offButton1) !=
(pOffTrackedRemoteOld->Buttons & offButton1))) {
handleTrackedControllerButton_AsButton(pDominantTrackedRemoteNew, pDominantTrackedRemoteOld, false, offButton1, UB_IMPULSE19);
(pOffTrackedRemoteOld->Buttons & offButton1)) &&
(pOffTrackedRemoteNew->Buttons & offButton1)) {
Android_SetImpuse(UB_IMPULSE19);
}
}
float distance = sqrtf(powf(pOff->HeadPose.Pose.Position.x - pWeapon->HeadPose.Pose.Position.x, 2) +
powf(pOff->HeadPose.Pose.Position.y - pWeapon->HeadPose.Pose.Position.y, 2) +
powf(pOff->HeadPose.Pose.Position.z - pWeapon->HeadPose.Pose.Position.z, 2));
@ -359,13 +360,13 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
if (pVRClientInfo->backpackitemactive == 0) {
if (dominantGripPushed) {
pVRClientInfo->lastweaponid = pVRClientInfo->weaponid;
//Initiate grenade from backpack mode
sendButtonActionSimple("weaponbank 6");
//Initiate flashlight from backpack mode
Android_SetImpuse(UB_IMPULSE11);
int channel = (vr_control_scheme >= 10) ? 0 : 1;
Doom3Quest_Vibrate(80, channel, 0.8); // vibrate to let user know they switched
pVRClientInfo->backpackitemactive = 1;
}
else if (dominantButton1Pushed)
/*else if (dominantButton1Pushed)
{
pVRClientInfo->lastweaponid = pVRClientInfo->weaponid;
@ -375,7 +376,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
Doom3Quest_Vibrate(80, channel, 0.8); // vibrate to let user know they switched
pVRClientInfo->backpackitemactive = 2;
}
/*else if (dominantButton2Pushed && pVRClientInfo->hasbinoculars)
else if (dominantButton2Pushed && pVRClientInfo->hasbinoculars)
{
int channel = (vr_control_scheme >= 10) ? 0 : 1;
Doom3Quest_Vibrate(80, channel, 0.8); // vibrate to let user know they switched

View file

@ -90,7 +90,7 @@ public:
// Set the local client number. Distinguishes listen ( == 0 ) / dedicated ( == -1 )
virtual void SetLocalClient( int clientNum ) = 0;
virtual void SetVRClientInfo(vr_client_info_t *pVRClientInfo) = 0;
virtual void SetVRClientInfo(vrClientInfo *pVRClientInfo) = 0;
virtual bool InCinematic() = 0;

View file

@ -1134,7 +1134,7 @@ usercmd_t idUsercmdGenLocal::GetDirectUsercmd( void ) {
InitCurrent();
// process the system mouse events
//Mouse();
Mouse();
// process the system keyboard events
Keyboard();

View file

@ -764,7 +764,7 @@ void idGameLocal::SetLocalClient( int clientNum ) {
localClientNum = clientNum;
}
void idGameLocal::SetVRClientInfo(vr_client_info_t *pVR)
void idGameLocal::SetVRClientInfo(vrClientInfo *pVR)
{
pVRClientInfo = pVR;
}

View file

@ -303,7 +303,7 @@ public:
virtual void Init( void );
virtual void Shutdown( void );
virtual void SetLocalClient( int clientNum );
virtual void SetVRClientInfo(vr_client_info_t *pVRClientInfo);
virtual void SetVRClientInfo(vrClientInfo *pVRClientInfo);
virtual void ThrottleUserInfo( void );
virtual const idDict * SetUserInfo( int clientNum, const idDict &userInfo, bool isClient, bool canModify );
virtual const idDict * GetUserInfo( int clientNum );
@ -456,7 +456,7 @@ public:
private:
const static int INITIAL_SPAWN_COUNT = 1;
vr_client_info_t *pVRClientInfo;
vrClientInfo *pVRClientInfo;
idStr mapFileName; // name of the map, empty string if no map loaded
idMapFile * mapFile; // will be NULL during the game unless in-game editing is used

View file

@ -139,10 +139,10 @@ idItem::UpdateRenderEntity
*/
bool idItem::UpdateRenderEntity( renderEntity_s *renderEntity, const renderView_t *renderView ) const {
if ( lastRenderViewTime == renderView->time ) {
/* if ( lastRenderViewTime == renderView->time ) {
return false;
}
*/
lastRenderViewTime = renderView->time;
// check for glow highlighting if near the center of the view

View file

@ -4396,12 +4396,20 @@ void idPlayer::UpdateFocus( void ) {
return;
}
/*
start = GetEyePosition();
end = start + viewAngles.ToForward() * 80.0f;
*/
//Use unadjusted weapon angles to control GUIs
idMat3 weaponViewAxis;
idAngles weaponViewAngles;
CalculateViewWeaponPos(false, start, weaponViewAxis, weaponViewAngles);
end = start + (weaponViewAngles.ToForward() * 80.0f);
// player identification -> names to the hud
if ( gameLocal.isMultiplayer && entityNumber == gameLocal.localClientNum ) {
idVec3 end = start + viewAngles.ToForward() * 768.0f;
idVec3 end = start + weaponViewAngles.ToForward() * 768.0f;
gameLocal.clip.TracePoint( trace, start, end, MASK_SHOT_BOUNDINGBOX, this );
int iclient = -1;
if ( ( trace.fraction < 1.0f ) && ( trace.c.entityNum < MAX_CLIENTS ) ) {
@ -4906,7 +4914,7 @@ void idPlayer::UpdateViewAngles( void ) {
}
// circularly clamp the angles with deltas
for ( i = 0; i < 3; i++ ) {
for ( i = 1; i < 3; i++ ) {
cmdAngles[i] = SHORT2ANGLE( usercmd.angles[i] );
if ( influenceActive == INFLUENCE_LEVEL3 ) {
viewAngles[i] += idMath::ClampFloat( -1.0f, 1.0f, idMath::AngleDelta( idMath::AngleNormalize180( SHORT2ANGLE( usercmd.angles[i]) + deltaViewAngles[i] ) , viewAngles[i] ) );
@ -4914,6 +4922,11 @@ void idPlayer::UpdateViewAngles( void ) {
viewAngles[i] = idMath::AngleNormalize180( SHORT2ANGLE( usercmd.angles[i]) + deltaViewAngles[i] );
}
}
if (pVRClientInfo != nullptr) {
viewAngles.pitch = pVRClientInfo->hmdorientation[PITCH];
}
if ( !centerView.IsDone( gameLocal.time ) ) {
viewAngles.pitch = centerView.GetCurrentValue(gameLocal.time);
}
@ -7109,10 +7122,9 @@ void rotateAboutOrigin(float x, float y, float rotation, float out[2])
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
}
void idPlayer::CalculateViewWeaponPos( idVec3 &origin, idMat3 &axis ) {
void idPlayer::CalculateViewWeaponPos( bool adjusted, idVec3 &origin, idMat3 &axis, idAngles &angles ) {
float scale;
float fracsin;
idAngles angles;
int delta;
// CalculateRenderView must have been called first
@ -7121,9 +7133,17 @@ void idPlayer::CalculateViewWeaponPos( idVec3 &origin, idMat3 &axis ) {
if (pVRClientInfo)
{
angles.pitch = pVRClientInfo->weaponangles[PITCH];
angles.yaw = viewAngles.yaw + (pVRClientInfo->weaponangles[YAW] - pVRClientInfo->hmdorientation[YAW]);
angles.roll = pVRClientInfo->weaponangles[ROLL];
if (adjusted) {
angles.pitch = pVRClientInfo->weaponangles[PITCH];
angles.yaw = viewAngles.yaw +
(pVRClientInfo->weaponangles[YAW] - pVRClientInfo->hmdorientation[YAW]);
angles.roll = pVRClientInfo->weaponangles[ROLL];
} else {
angles.pitch = pVRClientInfo->weaponangles_unadjusted[PITCH];
angles.yaw = viewAngles.yaw +
(pVRClientInfo->weaponangles_unadjusted[YAW] - pVRClientInfo->hmdorientation[YAW]);
angles.roll = pVRClientInfo->weaponangles_unadjusted[ROLL];
}
axis = angles.ToMat3();
@ -7298,7 +7318,7 @@ idVec3 idPlayer::GetEyePosition( void ) const {
}
}
void idPlayer::SetVRClientInfo(vr_client_info_t *pVR)
void idPlayer::SetVRClientInfo(vrClientInfo *pVR)
{
pVRClientInfo = pVR;
}

View file

@ -265,7 +265,7 @@ public:
idUserInterface * objectiveSystem;
bool objectiveSystemOpen;
vr_client_info_t *pVRClientInfo;
vrClientInfo *pVRClientInfo;
int weapon_soulcube;
int weapon_pda;
@ -363,7 +363,7 @@ public:
idDict * GetUserInfo( void );
bool BalanceTDM( void );
void SetVRClientInfo(vr_client_info_t *pVRClientInfo);
void SetVRClientInfo(vrClientInfo *pVRClientInfo);
void CacheWeapons( void );
@ -405,7 +405,7 @@ public:
float DefaultFov( void ) const;
float CalcFov( bool honorZoom );
void CalculateViewWeaponPos( idVec3 &origin, idMat3 &axis );
void CalculateViewWeaponPos( bool adjusted, idVec3 &origin, idMat3 &axis, idAngles &angles );
idVec3 GetEyePosition( void ) const;
void GetViewPos( idVec3 &origin, idMat3 &axis ) const;
void OffsetThirdPersonView( float angle, float range, float height, bool clip );

View file

@ -478,7 +478,12 @@ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view )
renderSystem->DrawStretchPic( blob->x, blob->y, blob->w, blob->h,blob->s1, blob->t1, blob->s2, blob->t2, blob->material );
}
}
player->DrawHUD( hud );
cvarSystem->SetCVarBool("vr_hud", true);
player->DrawHUD( hud );
cvarSystem->SetCVarBool("vr_hud", false);
// armor impulse feedback
float armorPulse = ( gameLocal.time - player->lastArmorPulse ) / 250.0f;
@ -523,7 +528,6 @@ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view )
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, bfgMaterial );
}
}
// test a single material drawn over everything

View file

@ -1,135 +0,0 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
Doom 3 Source Code 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 3 of the License, or
(at your option) any later version.
Doom 3 Source Code 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 Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __GAME_PLAYERVIEW_H__
#define __GAME_PLAYERVIEW_H__
#include "idlib/math/Vector.h"
#include "idlib/Dict.h"
#include "renderer/Material.h"
#include "renderer/RenderWorld.h"
class idSaveGame;
class idRestoreGame;
/*
===============================================================================
Player view.
===============================================================================
*/
// screenBlob_t are for the on-screen damage claw marks, etc
typedef struct {
const idMaterial * material;
float x, y, w, h;
float s1, t1, s2, t2;
int finishTime;
int startFadeTime;
float driftAmount;
} screenBlob_t;
#define MAX_SCREEN_BLOBS 8
class idPlayerView {
public:
idPlayerView();
void Save( idSaveGame *savefile ) const;
void Restore( idRestoreGame *savefile );
void SetPlayerEntity( class idPlayer *playerEnt );
void ClearEffects( void );
void DamageImpulse( idVec3 localKickDir, const idDict *damageDef );
void WeaponFireFeedback( const idDict *weaponDef );
idAngles AngleOffset( void ) const; // returns the current kick angle
idMat3 ShakeAxis( void ) const; // returns the current shake angle
void CalculateShake( void );
// this may involve rendering to a texture and displaying
// that with a warp model or in double vision mode
void RenderPlayerView( idUserInterface *hud );
void EmitStereoEyeView( const int eye, idUserInterface *hud );
void Fade( idVec4 color, int time );
void Flash( idVec4 color, int time );
void AddBloodSpray( float duration );
// temp for view testing
void EnableBFGVision( bool b ) { bfgVision = b; };
private:
void SingleView( idUserInterface *hud, const renderView_t *view );
void DoubleVision( idUserInterface *hud, const renderView_t *view, int offset );
void BerserkVision( idUserInterface *hud, const renderView_t *view );
void InfluenceVision( idUserInterface *hud, const renderView_t *view );
void ScreenFade();
screenBlob_t * GetScreenBlob();
screenBlob_t screenBlobs[MAX_SCREEN_BLOBS];
int dvFinishTime; // double vision will be stopped at this time
const idMaterial * dvMaterial; // material to take the double vision screen shot
int kickFinishTime; // view kick will be stopped at this time
idAngles kickAngles;
bool bfgVision; //
const idMaterial * tunnelMaterial; // health tunnel vision
const idMaterial * armorMaterial; // armor damage view effect
const idMaterial * berserkMaterial; // berserk effect
const idMaterial * irGogglesMaterial; // ir effect
const idMaterial * bloodSprayMaterial; // blood spray
const idMaterial * bfgMaterial; // when targeted with BFG
const idMaterial * lagoMaterial; // lagometer drawing
float lastDamageTime; // accentuate the tunnel effect for a while
idVec4 fadeColor; // fade color
idVec4 fadeToColor; // color to fade to
idVec4 fadeFromColor; // color to fade from
float fadeRate; // fade rate
int fadeTime; // fade time
idAngles shakeAng; // from the sound sources
idPlayer * player;
renderView_t view;
};
#endif /* !__GAME_PLAYERVIEW_H__ */

View file

@ -1879,7 +1879,7 @@ void idWeapon::PresentWeapon( bool showViewModel ) {
playerViewAxis = owner->firstPersonViewAxis;
// calculate weapon position based on player movement bobbing
owner->CalculateViewWeaponPos( viewWeaponOrigin, viewWeaponAxis );
owner->CalculateViewWeaponPos( true, viewWeaponOrigin, viewWeaponAxis, viewWeaponAngles );
// hide offset is for dropping the gun when approaching a GUI or NPC
// This is simpler to manage than doing the weapon put-away animation

View file

@ -200,6 +200,7 @@ private:
// the view weapon render entity parms
idVec3 viewWeaponOrigin;
idAngles viewWeaponAngles;
idMat3 viewWeaponAxis;
// the muzzle bone's position, used for launching projectiles and trailing smoke

View file

@ -291,6 +291,21 @@ void idDeviceContext::SetMenuScaleFix(bool enable) {
}
}
// DG: this is used for the "make sure menus are rendered as 4:3" hack
void idDeviceContext::SetMenuScaleForVR( bool enable ) {
int eye = cvarSystem->GetCVarInteger("vr_eye");
if(enable) {
float scale = 0.45;
float offsetX = (1.0f - scale) * (VIRTUAL_WIDTH * 0.5f);
float offsetY = (1.0f - scale) * (VIRTUAL_HEIGHT * 0.5f);
fixScaleForMenu.Set(scale, scale);
fixOffsetForMenu.Set(offsetX + (eye==0 ? 14 : -14), offsetY);
} else {
fixScaleForMenu.Set(1, 1);
fixOffsetForMenu.Set(0, 0);
}
}
void idDeviceContext::AdjustCoords(float *x, float *y, float *w, float *h) {
if (x) {

View file

@ -101,6 +101,7 @@ public:
// DG: this is used for the "make sure menus are rendered as 4:3" hack
void SetMenuScaleFix(bool enable);
void SetMenuScaleForVR( bool enable );
bool IsMenuScaleFixActive() const {
return fixOffsetForMenu.x != 0.0f || fixOffsetForMenu.y != 0.0f;
}

View file

@ -1222,10 +1222,17 @@ void idWindow::Redraw(float x, float y) {
((flags & WIN_MENUGUI) && r_scaleMenusTo43.GetBool()) )
{
fixupFor43 = true;
dc->SetMenuScaleFix(true);
//dc->SetMenuScaleFix(true);
}
}
bool scaledHUDForVR = cvarSystem->GetCVarBool("vr_hud");
if ( scaledHUDForVR ) {
dc->SetMenuScaleForVR(true);
} else {
dc->SetMenuScaleForVR(false);
}
if ( flags & WIN_SHOWTIME ) {
dc->DrawText(va(" %0.1f seconds\n%s", (float)(time - timeLine) / 1000, gui->State().GetString("name")), 0.35f, 0, dc->colorWhite, idRectangle(100, 0, 80, 80), false);
}
@ -1241,7 +1248,7 @@ void idWindow::Redraw(float x, float y) {
if (fixupFor43) { // DG: gotta reset that before returning this function
dc->SetMenuScaleFix(false);
}
return;
return;
}
CalcClientRect(0, 0);
@ -1310,7 +1317,7 @@ void idWindow::Redraw(float x, float y) {
}
if (fixupFor43) { // DG: gotta reset that before returning this function
dc->SetMenuScaleFix(false);
//dc->SetMenuScaleFix(false);
}
drawRect.Offset(-x, -y);