mirror of
https://github.com/DrBeef/QuestZDoom.git
synced 2024-11-14 00:20:51 +00:00
weapon WIP
This commit is contained in:
parent
9cdb6d7028
commit
ed700f7a70
5 changed files with 38 additions and 52 deletions
|
@ -59,7 +59,6 @@ bool vr_walkdirection;
|
||||||
float vr_snapturn_angle;
|
float vr_snapturn_angle;
|
||||||
vec3_t offhandangles;
|
vec3_t offhandangles;
|
||||||
vec3_t offhandoffset;
|
vec3_t offhandoffset;
|
||||||
int ducked;
|
|
||||||
bool player_moving;
|
bool player_moving;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1280,32 +1279,13 @@ void VR_Init()
|
||||||
remote_movementUp = 0.0f;
|
remote_movementUp = 0.0f;
|
||||||
positional_movementSideways = 0.0f;
|
positional_movementSideways = 0.0f;
|
||||||
positional_movementForward = 0.0f;
|
positional_movementForward = 0.0f;
|
||||||
snapTurn = 0.0f;
|
snapTurn = 90.0f; // start partly turned
|
||||||
ducked = DUCK_NOTDUCKED;
|
|
||||||
|
|
||||||
//init randomiser
|
//init randomiser
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
//Initialise our cvar holders
|
//Initialise our cvar holders
|
||||||
vr_weapon_pitchadjust = -20.0;
|
vr_weapon_pitchadjust = -30.0;
|
||||||
|
|
||||||
/* vr_snapturn_angle = Cvar_Get( "vr_snapturn_angle", "45", CVAR_ARCHIVE);
|
|
||||||
vr_positional_factor = Cvar_Get( "vr_positional_factor", "2000", CVAR_ARCHIVE);
|
|
||||||
vr_walkdirection = Cvar_Get( "vr_walkdirection", "0", CVAR_ARCHIVE);
|
|
||||||
vr_weapon_pitchadjust = Cvar_Get( "vr_weapon_pitchadjust", "-20.0", CVAR_ARCHIVE);
|
|
||||||
vr_control_scheme = Cvar_Get( "vr_control_scheme", "0", CVAR_ARCHIVE);
|
|
||||||
vr_height_adjust = Cvar_Get( "vr_height_adjust", "0.0", CVAR_ARCHIVE);
|
|
||||||
vr_weaponscale = Cvar_Get( "vr_weaponscale", "0.56", CVAR_ARCHIVE);
|
|
||||||
vr_weapon_stabilised = Cvar_Get( "vr_weapon_stabilised", "0.0", CVAR_LATCH);
|
|
||||||
vr_lasersight = Cvar_Get( "vr_lasersight", "0", CVAR_LATCH);
|
|
||||||
|
|
||||||
//The Engine (which is a derivative of Quake) uses a very specific unit size:
|
|
||||||
//Wolfenstein 3D, DOOM and QUAKE use the same coordinate/unit system:
|
|
||||||
//8 foot (96 inch) height wall == 64 units, 1.5 inches per pixel unit
|
|
||||||
//1.0 pixel unit / 1.5 inch == 0.666666 pixel units per inch
|
|
||||||
//This make a world scale of: 26.2467
|
|
||||||
vr_worldscale = Cvar_Get( "vr_worldscale", "26.2467", CVAR_ARCHIVE);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ovrAppThread * gAppThread = NULL;
|
static ovrAppThread * gAppThread = NULL;
|
||||||
|
|
|
@ -54,11 +54,6 @@ extern float vr_snapturn_angle;
|
||||||
extern vec3_t offhandangles;
|
extern vec3_t offhandangles;
|
||||||
extern vec3_t offhandoffset;
|
extern vec3_t offhandoffset;
|
||||||
|
|
||||||
#define DUCK_NOTDUCKED 0
|
|
||||||
#define DUCK_BUTTON 1
|
|
||||||
#define DUCK_CROUCHED 2
|
|
||||||
extern int ducked;
|
|
||||||
|
|
||||||
extern bool player_moving;
|
extern bool player_moving;
|
||||||
|
|
||||||
void shutdownVR();
|
void shutdownVR();
|
||||||
|
|
|
@ -96,7 +96,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
||||||
const ovrQuatf quatRemote = pDominantTracking->HeadPose.Pose.Orientation;
|
const ovrQuatf quatRemote = pDominantTracking->HeadPose.Pose.Orientation;
|
||||||
QuatToYawPitchRoll(quatRemote, vr_weapon_pitchadjust, weaponangles);
|
QuatToYawPitchRoll(quatRemote, vr_weapon_pitchadjust, weaponangles);
|
||||||
weaponangles[YAW] -= VR_GetRawYaw();
|
weaponangles[YAW] -= VR_GetRawYaw();
|
||||||
//weaponangles[ROLL] *= -1.0f;
|
weaponangles[ROLL] = 0.0f; // remove roll for weapons
|
||||||
|
|
||||||
|
|
||||||
if (weaponStabilised)
|
if (weaponStabilised)
|
||||||
|
@ -107,7 +107,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
||||||
float zxDist = length(x, z);
|
float zxDist = length(x, z);
|
||||||
|
|
||||||
if (zxDist != 0.0f && z != 0.0f) {
|
if (zxDist != 0.0f && z != 0.0f) {
|
||||||
VectorSet(weaponangles, -degrees(atanf(y / zxDist)), VR_GetRawYaw() - degrees(atan2f(x, -z)), weaponangles[ROLL]);
|
VectorSet(weaponangles, -degrees(atanf(y / zxDist)), VR_GetRawYaw() - degrees(atan2f(x, -z)), 0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,31 +126,27 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
||||||
offhandoffset[2] = v[1];
|
offhandoffset[2] = v[1];
|
||||||
|
|
||||||
QuatToYawPitchRoll(pOffTracking->HeadPose.Pose.Orientation, 0.0f, offhandangles);
|
QuatToYawPitchRoll(pOffTracking->HeadPose.Pose.Orientation, 0.0f, offhandangles);
|
||||||
offhandangles[YAW] -= VR_GetRawYaw();
|
|
||||||
|
|
||||||
if (vr_walkdirection == 0) {
|
if (vr_walkdirection == 0) {
|
||||||
controllerYawHeading = offhandangles[YAW];
|
controllerYawHeading = offhandangles[YAW] - hmdorientation[YAW];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
controllerYawHeading = 0.0f;
|
controllerYawHeading = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offhandangles[YAW] -= VR_GetRawYaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dominant-hand specific stuff
|
//Positional movement
|
||||||
{
|
{
|
||||||
ALOGV(" Right-Controller-Position: %f, %f, %f",
|
ALOGV(" Right-Controller-Position: %f, %f, %f",
|
||||||
pDominantTracking->HeadPose.Pose.Position.x,
|
pDominantTracking->HeadPose.Pose.Position.x,
|
||||||
pDominantTracking->HeadPose.Pose.Position.y,
|
pDominantTracking->HeadPose.Pose.Position.y,
|
||||||
pDominantTracking->HeadPose.Pose.Position.z);
|
pDominantTracking->HeadPose.Pose.Position.z);
|
||||||
|
|
||||||
//This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the
|
|
||||||
//player is facing for positional tracking
|
|
||||||
float vr_positional_factor = 1.0f;//4.0f;
|
|
||||||
|
|
||||||
vec2_t v;
|
vec2_t v;
|
||||||
rotateAboutOrigin(-positionDeltaThisFrame[0] * vr_positional_factor,
|
rotateAboutOrigin(-positionDeltaThisFrame[0], positionDeltaThisFrame[2], -(VR_GetRawYaw() + hmdorientation[YAW]), v);
|
||||||
positionDeltaThisFrame[2] * vr_positional_factor, -(VR_GetRawYaw() + hmdorientation[YAW]), v);
|
|
||||||
positional_movementSideways = v[0];
|
positional_movementSideways = v[0];
|
||||||
positional_movementForward = v[1];
|
positional_movementForward = v[1];
|
||||||
|
|
||||||
|
@ -174,12 +170,16 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
||||||
}
|
}
|
||||||
|
|
||||||
//Apply a filter and quadratic scaler so small movements are easier to make
|
//Apply a filter and quadratic scaler so small movements are easier to make
|
||||||
|
//and we don't get movement jitter when the joystick doesn't quite center properly
|
||||||
float dist = length(pOffTrackedRemoteNew->Joystick.x, pOffTrackedRemoteNew->Joystick.y);
|
float dist = length(pOffTrackedRemoteNew->Joystick.x, pOffTrackedRemoteNew->Joystick.y);
|
||||||
float nlf = nonLinearFilter(dist);
|
float nlf = nonLinearFilter(dist);
|
||||||
float x = nlf * pOffTrackedRemoteNew->Joystick.x;
|
float x = nlf * pOffTrackedRemoteNew->Joystick.x;
|
||||||
float y = nlf * pOffTrackedRemoteNew->Joystick.y;
|
float y = nlf * pOffTrackedRemoteNew->Joystick.y;
|
||||||
|
|
||||||
|
//Apply a simple deadzone
|
||||||
player_moving = (fabs(x) + fabs(y)) > 0.05f;
|
player_moving = (fabs(x) + fabs(y)) > 0.05f;
|
||||||
|
x = player_moving ? x : 0;
|
||||||
|
y = player_moving ? y : 0;
|
||||||
|
|
||||||
//Adjust to be off-hand controller oriented
|
//Adjust to be off-hand controller oriented
|
||||||
vec2_t v;
|
vec2_t v;
|
||||||
|
|
|
@ -807,8 +807,8 @@ void FGLRenderer::Flush()
|
||||||
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
||||||
glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
||||||
|
|
||||||
//Only adjust HUD if we are 3D (otherwise we are rendering to a cylinder compositor layer)
|
//Only adjust HUD if we are 3D and not showing menu (otherwise we are rendering to a cylinder compositor layer)
|
||||||
//if (!is2D) stereo3dMode.getEyePose(eye_ix)->AdjustHud();
|
if (!is2D && !isMenuActive()) stereo3dMode.getEyePose(eye_ix)->AdjustHud();
|
||||||
|
|
||||||
m2DDrawer->Draw();
|
m2DDrawer->Draw();
|
||||||
FGLDebug::PopGroup();
|
FGLDebug::PopGroup();
|
||||||
|
|
|
@ -66,6 +66,7 @@ EXTERN_CVAR(Bool, vr_moveFollowsOffHand)
|
||||||
EXTERN_CVAR(Float, vr_weaponRotate);
|
EXTERN_CVAR(Float, vr_weaponRotate);
|
||||||
EXTERN_CVAR(Float, vr_snapTurn);
|
EXTERN_CVAR(Float, vr_snapTurn);
|
||||||
EXTERN_CVAR(Float, vr_ipd);
|
EXTERN_CVAR(Float, vr_ipd);
|
||||||
|
EXTERN_CVAR(Float, vr_weaponScale);
|
||||||
|
|
||||||
double P_XYMovement(AActor *mo, DVector2 scroll);
|
double P_XYMovement(AActor *mo, DVector2 scroll);
|
||||||
extern "C" void VR_GetMove( float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up, float *yaw, float *pitch, float *roll );
|
extern "C" void VR_GetMove( float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up, float *yaw, float *pitch, float *roll );
|
||||||
|
@ -312,7 +313,7 @@ namespace s3d
|
||||||
{
|
{
|
||||||
GetWeaponTransform(&gl_RenderState.mModelMatrix);
|
GetWeaponTransform(&gl_RenderState.mModelMatrix);
|
||||||
|
|
||||||
float scale = 0.00125f * 1.0;//oculusquest_weaponScale;
|
float scale = 0.00125f * vr_weaponScale;
|
||||||
gl_RenderState.mModelMatrix.scale(scale, -scale, scale);
|
gl_RenderState.mModelMatrix.scale(scale, -scale, scale);
|
||||||
gl_RenderState.mModelMatrix.translate(-viewwidth / 2, -viewheight * 3 / 4, 0.0f);
|
gl_RenderState.mModelMatrix.translate(-viewwidth / 2, -viewheight * 3 / 4, 0.0f);
|
||||||
|
|
||||||
|
@ -326,7 +327,7 @@ namespace s3d
|
||||||
|
|
||||||
bool OculusQuestMode::GetHandTransform(int hand, VSMatrix* mat) const
|
bool OculusQuestMode::GetHandTransform(int hand, VSMatrix* mat) const
|
||||||
{
|
{
|
||||||
/* {
|
{
|
||||||
mat->loadIdentity();
|
mat->loadIdentity();
|
||||||
|
|
||||||
AActor* playermo = r_viewpoint.camera->player->mo;
|
AActor* playermo = r_viewpoint.camera->player->mo;
|
||||||
|
@ -338,15 +339,26 @@ namespace s3d
|
||||||
|
|
||||||
mat->rotate(-deltaYawDegrees - 180, 0, 1, 0);
|
mat->rotate(-deltaYawDegrees - 180, 0, 1, 0);
|
||||||
|
|
||||||
mat->translate(-oculusquest_origin.x, -vr_floor_offset, -oculusquest_origin.z);
|
if ((vr_control_scheme < 10 && hand == 1)
|
||||||
|
|| (vr_control_scheme > 10 && hand == 0)) {
|
||||||
|
DVector3 weap(weaponoffset[0], weaponoffset[1], weaponoffset[2]);
|
||||||
|
weap *= vr_vunits_per_meter;
|
||||||
|
mat->translate(weap.X - hmdPosition[0], weap.Y - vr_floor_offset,
|
||||||
|
weap.Z - hmdPosition[2]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DVector3 weap(offhandoffset[0], offhandoffset[1], offhandoffset[2]);
|
||||||
|
weap *= vr_vunits_per_meter;
|
||||||
|
mat->translate(weap.X - hmdPosition[0], weap.Y - vr_floor_offset,
|
||||||
|
weap.Z - hmdPosition[2]);
|
||||||
|
}
|
||||||
|
|
||||||
LSMatrix44 handToAbs;
|
//Perform roration here?
|
||||||
vSMatrixFromHmdMatrix34(handToAbs, controllers[hand].pose.mDeviceToAbsoluteTracking);
|
|
||||||
|
|
||||||
mat->multMatrix(handToAbs.transpose());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -386,12 +398,9 @@ namespace s3d
|
||||||
super::SetUp();
|
super::SetUp();
|
||||||
|
|
||||||
// Set VR-appropriate settings
|
// Set VR-appropriate settings
|
||||||
const bool doAdjustVrSettings = true;
|
{
|
||||||
if (doAdjustVrSettings) {
|
|
||||||
movebob = 0;
|
movebob = 0;
|
||||||
gl_billboard_faces_camera = true;
|
gl_billboard_faces_camera = true;
|
||||||
// if (gl_multisample < 2)
|
|
||||||
// gl_multisample = 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamestate == GS_LEVEL && !isMenuActive()) {
|
if (gamestate == GS_LEVEL && !isMenuActive()) {
|
||||||
|
@ -419,6 +428,7 @@ namespace s3d
|
||||||
{
|
{
|
||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
|
//Weapon firing tracking - Thanks Fishbiter!
|
||||||
{
|
{
|
||||||
player->mo->OverrideAttackPosDir = true;
|
player->mo->OverrideAttackPosDir = true;
|
||||||
|
|
||||||
|
@ -435,8 +445,9 @@ namespace s3d
|
||||||
float dummy=0;
|
float dummy=0;
|
||||||
VR_GetMove(&dummy, &dummy, &hmd_forward, &hmd_side, &dummy, &dummy, &dummy, &dummy);
|
VR_GetMove(&dummy, &dummy, &hmd_forward, &hmd_side, &dummy, &dummy, &dummy, &dummy);
|
||||||
|
|
||||||
|
//Positional movement - Thanks fishbiter!!
|
||||||
auto vel = player->mo->Vel;
|
auto vel = player->mo->Vel;
|
||||||
player->mo->Vel = DVector3((DVector2(hmd_forward, -hmd_side) * vr_vunits_per_meter), 0);
|
player->mo->Vel = DVector3((DVector2(hmd_side, hmd_forward) * vr_vunits_per_meter), 0);
|
||||||
bool wasOnGround = player->mo->Z() <= player->mo->floorz;
|
bool wasOnGround = player->mo->Z() <= player->mo->floorz;
|
||||||
double oldZ = player->mo->Z();
|
double oldZ = player->mo->Z();
|
||||||
P_XYMovement(player->mo, DVector2(0, 0));
|
P_XYMovement(player->mo, DVector2(0, 0));
|
||||||
|
|
Loading…
Reference in a new issue