weapon WIP

This commit is contained in:
Simon 2020-03-10 18:51:35 +00:00
parent 9cdb6d7028
commit ed700f7a70
5 changed files with 38 additions and 52 deletions

View file

@ -59,7 +59,6 @@ bool vr_walkdirection;
float vr_snapturn_angle;
vec3_t offhandangles;
vec3_t offhandoffset;
int ducked;
bool player_moving;
@ -1280,32 +1279,13 @@ void VR_Init()
remote_movementUp = 0.0f;
positional_movementSideways = 0.0f;
positional_movementForward = 0.0f;
snapTurn = 0.0f;
ducked = DUCK_NOTDUCKED;
snapTurn = 90.0f; // start partly turned
//init randomiser
srand(time(NULL));
//Initialise our cvar holders
vr_weapon_pitchadjust = -20.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);
*/
vr_weapon_pitchadjust = -30.0;
}
static ovrAppThread * gAppThread = NULL;

View file

@ -54,11 +54,6 @@ extern float vr_snapturn_angle;
extern vec3_t offhandangles;
extern vec3_t offhandoffset;
#define DUCK_NOTDUCKED 0
#define DUCK_BUTTON 1
#define DUCK_CROUCHED 2
extern int ducked;
extern bool player_moving;
void shutdownVR();

View file

@ -96,7 +96,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
const ovrQuatf quatRemote = pDominantTracking->HeadPose.Pose.Orientation;
QuatToYawPitchRoll(quatRemote, vr_weapon_pitchadjust, weaponangles);
weaponangles[YAW] -= VR_GetRawYaw();
//weaponangles[ROLL] *= -1.0f;
weaponangles[ROLL] = 0.0f; // remove roll for weapons
if (weaponStabilised)
@ -107,7 +107,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
float zxDist = length(x, z);
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];
QuatToYawPitchRoll(pOffTracking->HeadPose.Pose.Orientation, 0.0f, offhandangles);
offhandangles[YAW] -= VR_GetRawYaw();
if (vr_walkdirection == 0) {
controllerYawHeading = offhandangles[YAW];
controllerYawHeading = offhandangles[YAW] - hmdorientation[YAW];
}
else
{
controllerYawHeading = 0.0f;
}
offhandangles[YAW] -= VR_GetRawYaw();
}
//Dominant-hand specific stuff
//Positional movement
{
ALOGV(" Right-Controller-Position: %f, %f, %f",
pDominantTracking->HeadPose.Pose.Position.x,
pDominantTracking->HeadPose.Pose.Position.y,
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;
rotateAboutOrigin(-positionDeltaThisFrame[0] * vr_positional_factor,
positionDeltaThisFrame[2] * vr_positional_factor, -(VR_GetRawYaw() + hmdorientation[YAW]), v);
rotateAboutOrigin(-positionDeltaThisFrame[0], positionDeltaThisFrame[2], -(VR_GetRawYaw() + hmdorientation[YAW]), v);
positional_movementSideways = v[0];
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
//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 nlf = nonLinearFilter(dist);
float x = nlf * pOffTrackedRemoteNew->Joystick.x;
float y = nlf * pOffTrackedRemoteNew->Joystick.y;
//Apply a simple deadzone
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
vec2_t v;

View file

@ -807,8 +807,8 @@ void FGLRenderer::Flush()
glViewport(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)
//if (!is2D) stereo3dMode.getEyePose(eye_ix)->AdjustHud();
//Only adjust HUD if we are 3D and not showing menu (otherwise we are rendering to a cylinder compositor layer)
if (!is2D && !isMenuActive()) stereo3dMode.getEyePose(eye_ix)->AdjustHud();
m2DDrawer->Draw();
FGLDebug::PopGroup();

View file

@ -66,6 +66,7 @@ EXTERN_CVAR(Bool, vr_moveFollowsOffHand)
EXTERN_CVAR(Float, vr_weaponRotate);
EXTERN_CVAR(Float, vr_snapTurn);
EXTERN_CVAR(Float, vr_ipd);
EXTERN_CVAR(Float, vr_weaponScale);
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 );
@ -312,7 +313,7 @@ namespace s3d
{
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.translate(-viewwidth / 2, -viewheight * 3 / 4, 0.0f);
@ -326,7 +327,7 @@ namespace s3d
bool OculusQuestMode::GetHandTransform(int hand, VSMatrix* mat) const
{
/* {
{
mat->loadIdentity();
AActor* playermo = r_viewpoint.camera->player->mo;
@ -338,15 +339,26 @@ namespace s3d
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;
vSMatrixFromHmdMatrix34(handToAbs, controllers[hand].pose.mDeviceToAbsoluteTracking);
//Perform roration here?
mat->multMatrix(handToAbs.transpose());
return true;
}*/
}
return false;
}
@ -386,12 +398,9 @@ namespace s3d
super::SetUp();
// Set VR-appropriate settings
const bool doAdjustVrSettings = true;
if (doAdjustVrSettings) {
{
movebob = 0;
gl_billboard_faces_camera = true;
// if (gl_multisample < 2)
// gl_multisample = 4;
}
if (gamestate == GS_LEVEL && !isMenuActive()) {
@ -419,6 +428,7 @@ namespace s3d
{
if (player)
{
//Weapon firing tracking - Thanks Fishbiter!
{
player->mo->OverrideAttackPosDir = true;
@ -435,8 +445,9 @@ namespace s3d
float dummy=0;
VR_GetMove(&dummy, &dummy, &hmd_forward, &hmd_side, &dummy, &dummy, &dummy, &dummy);
//Positional movement - Thanks fishbiter!!
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;
double oldZ = player->mo->Z();
P_XYMovement(player->mo, DVector2(0, 0));