Made Doom Playable in Cinema Mode

This commit is contained in:
Simon 2020-06-07 22:32:20 +01:00
parent f35544b9b1
commit e4d64f9b9f
8 changed files with 63 additions and 48 deletions

View file

@ -44,7 +44,6 @@ Copyright : Copyright 2015 Oculus VR, LLC. All Rights reserved.
//Define all variables here that were externs in the VrCommon.h
bool qzdoom_initialised;
long long global_time;
float playerHeight;
float playerYaw;
bool resetDoomYaw;
bool resetPreviousPitch;
@ -855,18 +854,8 @@ void setWorldPosition( float x, float y, float z )
void setHMDPosition( float x, float y, float z, float yaw )
{
static bool s_useScreen = false;
VectorSet(hmdPosition, x, y, z);
if (s_useScreen != QzDoom_useScreenLayer())
{
s_useScreen = QzDoom_useScreenLayer();
//Record player height on transition
playerHeight = y;
}
if (!QzDoom_useScreenLayer())
{
playerYaw = yaw;
@ -905,8 +894,8 @@ void VR_GetMove( float *joy_forward, float *joy_side, float *hmd_forward, float
*up = remote_movementUp;
*joy_side = remote_movementSideways;
*hmd_side = positional_movementSideways;
*yaw = cinemamode ? mouseX : hmdorientation[YAW] + snapTurn;
*pitch = cinemamode ? mouseY : hmdorientation[PITCH];
*yaw = cinemamode ? cinemamodeYaw : hmdorientation[YAW] + snapTurn;
*pitch = cinemamode ? cinemamodePitch : hmdorientation[PITCH];
*roll = cinemamode ? 0.0f : hmdorientation[ROLL];
}
@ -1296,8 +1285,8 @@ void VR_Init()
positional_movementSideways = 0.0f;
positional_movementForward = 0.0f;
snapTurn = 0.0f;
mouseX = 0.0f;
mouseY = 0.0f;
cinemamodeYaw = 0.0f;
cinemamodePitch = 0.0f;
//init randomiser
srand(time(NULL));

View file

@ -30,10 +30,9 @@ extern "C"
extern bool qzdoom_initialised;
extern bool cinemamode;
extern float mouseX;
extern float mouseY;
extern float cinemamodeYaw;
extern float cinemamodePitch;
extern float playerHeight;
extern float playerYaw;
extern bool resetDoomYaw;
extern float doomYaw;

View file

@ -21,8 +21,8 @@ float positional_movementSideways;
float positional_movementForward;
float snapTurn;
float mouseX;
float mouseY;
float cinemamodeYaw;
float cinemamodePitch;
void acquireTrackedRemotesData(const ovrMobile *Ovr, double displayTime);

View file

@ -21,6 +21,7 @@ Authors : Simon Brown
int getGameState();
int getMenuState();
void Joy_GenerateButtonEvents(int oldbuttons, int newbuttons, int numbuttons, int base);
float getViewpointYaw();
void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
@ -68,20 +69,20 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
//In cinema mode, right-stick controls mouse
const float mouseSpeed = 2.5f;
const float mouseSpeed = 2.0f;
if (cinemamode)
{
if (pPrimaryTrackedRemoteNew->Joystick.x > 0.6f) {
mouseX -= mouseSpeed;
cinemamodeYaw -= mouseSpeed;
}
if (pPrimaryTrackedRemoteNew->Joystick.x < -0.6f) {
mouseX += mouseSpeed;
cinemamodeYaw += mouseSpeed;
}
if (pPrimaryTrackedRemoteNew->Joystick.y > 0.6f) {
mouseY -= mouseSpeed;
cinemamodePitch -= mouseSpeed;
}
if (pPrimaryTrackedRemoteNew->Joystick.y < -0.6f) {
mouseY += mouseSpeed;
cinemamodePitch += mouseSpeed;
}
}
@ -118,8 +119,10 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
{
vec2_t v;
float yawRotation = cinemamode ? getViewpointYaw() - hmdorientation[YAW] :
doomYaw - hmdorientation[YAW];
rotateAboutOrigin(weaponoffset[0], weaponoffset[2],
-(doomYaw - hmdorientation[YAW]), v);
-yawRotation, v);
weaponoffset[0] = v[1];
weaponoffset[2] = v[0];
}

View file

@ -388,8 +388,8 @@ CCMD (turn180)
}
extern bool cinemamode;
extern float mouseX;
extern float mouseY;
extern float cinemamodeYaw;
extern float cinemamodePitch;
extern vec3_t hmdorientation;
extern float snapturn;
CCMD (cinemamode)
@ -397,8 +397,8 @@ CCMD (cinemamode)
cinemamode = !cinemamode;
//Store these
mouseX = hmdorientation[YAW] + snapTurn;
mouseY = hmdorientation[PITCH];
cinemamodeYaw = hmdorientation[YAW] + snapTurn;
cinemamodePitch = hmdorientation[PITCH];
//Reset angles back to normal view
if (!cinemamode)

View file

@ -105,6 +105,16 @@ float getDoomPlayerHeightWithoutCrouch(const player_t *player)
return height;
}
extern "C" float getViewpointYaw()
{
if (cinemamode)
{
return r_viewpoint.Angles.Yaw.Degrees;
}
return doomYaw;
}
namespace s3d
{
static DVector3 oculusquest_origin(0, 0, 0);
@ -128,7 +138,7 @@ namespace s3d
outViewShift[0] = outViewShift[1] = outViewShift[2] = 0;
vec3_t angles;
VectorSet(angles, -GLRenderer->mAngles.Pitch.Degrees, doomYaw, GLRenderer->mAngles.Roll.Degrees);
VectorSet(angles, -GLRenderer->mAngles.Pitch.Degrees, getViewpointYaw(), GLRenderer->mAngles.Roll.Degrees);
vec3_t v_forward, v_right, v_up;
AngleVectors(angles, v_forward, v_right, v_up);
@ -313,8 +323,14 @@ namespace s3d
mat->scale(1, 1 / pixelstretch, 1);
mat->rotate(-90 + (doomYaw - hmdorientation[YAW]) + weaponangles[YAW], 0, 1, 0);
mat->rotate(-weaponangles[PITCH], 1, 0, 0);
if (cinemamode)
{
mat->rotate(-90 + r_viewpoint.Angles.Yaw.Degrees + (weaponangles[YAW]- hmdorientation[YAW]), 0, 1, 0);
mat->rotate(-weaponangles[PITCH] - r_viewpoint.Angles.Pitch.Degrees, 1, 0, 0);
} else {
mat->rotate(-90 + doomYaw + (weaponangles[YAW]- hmdorientation[YAW]), 0, 1, 0);
mat->rotate(-weaponangles[PITCH], 1, 0, 0);
}
mat->rotate(-weaponangles[ROLL], 0, 0, 1);
}
else
@ -323,8 +339,14 @@ namespace s3d
mat->scale(1, 1 / pixelstretch, 1);
mat->rotate(-90 + (doomYaw - hmdorientation[YAW]) + offhandangles[YAW], 0, 1, 0);
mat->rotate(-offhandangles[PITCH], 1, 0, 0);
if (cinemamode)
{
mat->rotate(-90 + r_viewpoint.Angles.Yaw.Degrees + (offhandangles[YAW]- hmdorientation[YAW]), 0, 1, 0);
mat->rotate(-offhandangles[PITCH] - r_viewpoint.Angles.Pitch.Degrees, 1, 0, 0);
} else {
mat->rotate(-90 + doomYaw + (offhandangles[YAW]- hmdorientation[YAW]), 0, 1, 0);
mat->rotate(-offhandangles[PITCH], 1, 0, 0);
}
mat->rotate(-offhandangles[ROLL], 0, 0, 1);
}
@ -475,8 +497,10 @@ namespace s3d
{
player->mo->OverrideAttackPosDir = true;
player->mo->AttackPitch = -weaponangles[PITCH];
player->mo->AttackAngle = -90 + (doomYaw - hmdorientation[YAW]) + weaponangles[YAW];
player->mo->AttackPitch = cinemamode ? -weaponangles[PITCH] - r_viewpoint.Angles.Pitch.Degrees
: -weaponangles[PITCH];
player->mo->AttackAngle = -90 + getViewpointYaw() + (weaponangles[YAW]- hmdorientation[YAW]);
player->mo->AttackPos.X = player->mo->X() - (weaponoffset[0] * vr_vunits_per_meter);
player->mo->AttackPos.Y = player->mo->Y() - (weaponoffset[2] * vr_vunits_per_meter);

View file

@ -620,6 +620,7 @@ OptionMenu "OtherControlsMenu" protected
StaticTextSwitchable "$CNTRLMNU_SWITCHTEXT1", "$CNTRLMNU_SWITCHTEXT2", "ControlMessage"
StaticText ""
Control "Toggle Cinema Mode" , "cinemamode"
Control "$CNTRLMNU_AUTOMAP" , "togglemap"
StaticText ""
@ -2323,22 +2324,21 @@ OptionMenu VROptionsMenu protected
StaticText ""
StaticText "VR Controls"
Control "Toggle Cinema Mode", "cinemamode"
Option "Control Scheme", "vr_control_scheme", "ControlScheme"
Option "Switch Thumsticks", "vr_switch_sticks", "OnOff"
Option "Use Secondary Button Mappings", "vr_secondary_button_mappings", "OnOff"
Option "Allow Secondary Button Mappings", "vr_secondary_button_mappings", "OnOff"
Option "Two Handed Weapons", "vr_two_handed_weapons", "OnOff"
Option "Off-hand Move Direction", "vr_move_use_offhand", "OffOn"
StaticText ""
StaticText "Set Snap-Turn to <= 10 degrees for \"Smooth\" Turn"
Slider "Snap-turn Angle", "vr_snapTurn", 0.0, 90.0, 1.0, 2
StaticText ""
StaticText "Locomotion"
Option "Off-hand Move Direction", "vr_move_use_offhand", "OffOn"
Option "Use Teleport", "vr_teleport", "OnOff"
Option "Allow slidey movement (Momentum)", "vr_momentum", "OnOff"
Slider "Walking Speed", "vr_move_speed", 5, 50, 1, 2
Slider "Run Multiplier", "vr_run_multiplier", 0.0, 5.0, 0.1, 2
StaticText ""
StaticText "Set Snap-Turn to <= 10 degrees for \"Smooth\" Turn"
Slider "Snap-turn Angle", "vr_snapTurn", 0.0, 90.0, 1.0, 2
StaticText ""
StaticText "Haptics"
@ -2347,20 +2347,20 @@ OptionMenu VROptionsMenu protected
StaticText ""
StaticText "Weapon"
Option "Weapon Recoil", "vr_recoil", "OnOff"
Slider "Weapon Pitch Adjust", "vr_weaponRotate", -45, 45, 5, 2
Slider "Weapon Scale", "vr_weaponScale", 0.1, 1.0, 0.01, 2
Slider "Weapon Sprite Scale", "vr_weaponScale", 0.1, 1.0, 0.01, 2
Option "Weapon Sprite 3D", "r_PlayerSprites3DMode", "Sprites3DMode"
Slider "Weapon Fat Item Width", "gl_fatItemWidth", 0.1, 1.0, 0.1, 2
Option "Weapon Recoil", "vr_recoil", "OnOff"
StaticText ""
Submenu "VR HUD/Automap Options", "VRHUDOptions"
StaticText ""
StaticText "Display"
Option "Lock FrameRate (IF LOW PERF.)", "cl_capfps", "OnOff"
Option "Show VR HUD FPS", "vid_fps", "OnOff"
Option "Dynamic Lights (CAUTION)", "vr_dynlights", "OnOff"
Option "Lock FrameRate (IF LOW PERF.)", "cl_capfps", "OnOff"
Option "Show FPS on HUD", "vid_fps", "OnOff"
Option "Dynamic Lights (CAUTION)", "vr_dynlights", "OnOff"
}
/*=======================================

Binary file not shown.