mirror of
https://github.com/DrBeef/RTCWQuest.git
synced 2025-04-23 15:33:23 +00:00
Virtual Stock Implementation
For FG42, Mauser, Thompson and Sten Optional (default is off), dominant eye can be selected for alignment The FG42 needs a bit of work on aligning..
This commit is contained in:
parent
49ebbd1d93
commit
e60b606b57
12 changed files with 168 additions and 34 deletions
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.drbeef.rtcwquest"
|
||||
android:versionCode="37"
|
||||
android:versionName="1.0.1" android:installLocation="auto" >
|
||||
android:versionCode="38"
|
||||
android:versionName="1.1.0" android:installLocation="auto" >
|
||||
|
||||
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
||||
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
|
||||
|
|
|
@ -1327,18 +1327,21 @@ void RTCWVR_Init()
|
|||
vr_weapon_pitchadjust = Cvar_Get( "vr_weapon_pitchadjust", "-20.0", CVAR_ARCHIVE);
|
||||
vr_lasersight = Cvar_Get( "vr_lasersight", "0", CVAR_ARCHIVE);
|
||||
vr_teleport = Cvar_Get( "vr_teleport", "0", CVAR_ARCHIVE);
|
||||
vr_virtual_stock = Cvar_Get( "vr_virtual_stock", "0", CVAR_ARCHIVE);
|
||||
|
||||
//Defaults
|
||||
vr_control_scheme = Cvar_Get( "vr_control_scheme", "0", CVAR_ARCHIVE);
|
||||
vr_switch_sticks = Cvar_Get( "vr_switch_sticks", "0", CVAR_ARCHIVE);
|
||||
|
||||
vr_cinematic_stereo = Cvar_Get( "vr_cinematic_stereo", "1", CVAR_ARCHIVE);
|
||||
vr_cinematic_stereo = Cvar_Get( "vr_cinematic_stereo", "0", CVAR_ARCHIVE); // Default to 2D
|
||||
vr_screen_dist = Cvar_Get( "vr_screen_dist", "3.5", CVAR_ARCHIVE);
|
||||
|
||||
//Set up vr client info
|
||||
vr.backpackitemactive = 0;
|
||||
vr.visible_hud = qtrue;
|
||||
vr.dualwield = qfalse;
|
||||
vr.vstock_weapon = qfalse;
|
||||
vr.vstock_engaged = qfalse;
|
||||
|
||||
//Clear teleport stuff
|
||||
vr.teleportexecute = qfalse;
|
||||
|
|
|
@ -39,6 +39,12 @@ typedef struct {
|
|||
qboolean scopedweapon; // Weapon scope is available
|
||||
qboolean scopedetached; // Scope has been detached from weapon
|
||||
qboolean detachablescope; // Scope can be detached from weapon
|
||||
|
||||
//Virtual Stock stuff
|
||||
qboolean vstock_weapon; // Weapon has a stock that can be used "vitually"
|
||||
qboolean vstock_engaged; // Virtual Stock is engaged
|
||||
vec3_t vstock_weapon_offset; // The offset of the fixed primary hand when Virtual Stock is engaged (set by cgame Weapon code)
|
||||
|
||||
qboolean hasbinoculars;
|
||||
|
||||
qboolean velocitytriggered; // Weapon attack triggered by velocity (knife)
|
||||
|
|
|
@ -8,6 +8,7 @@ cvar_t *vr_weapon_pitchadjust;
|
|||
cvar_t *vr_lasersight;
|
||||
cvar_t *vr_control_scheme;
|
||||
cvar_t *vr_teleport;
|
||||
cvar_t *vr_virtual_stock;
|
||||
cvar_t *vr_switch_sticks;
|
||||
cvar_t *vr_cinematic_stereo;
|
||||
cvar_t *vr_screen_dist;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
enum control_scheme;
|
||||
|
||||
#define SCOPE_ENGAGE_DISTANCE 0.25
|
||||
#define VSTOCK_ENGAGE_DISTANCE 0.25
|
||||
#define BINOCULAR_ENGAGE_DISTANCE 0.25
|
||||
#define VELOCITY_TRIGGER 1.6
|
||||
|
||||
|
|
|
@ -129,10 +129,20 @@ void updateScopeAngles()
|
|||
//Bit of a hack, but use weapon orientation / position for view when scope is engaged
|
||||
static vec3_t currentScopeAngles;
|
||||
static vec3_t lastScopeAngles;
|
||||
if (vr.scopeengaged)
|
||||
if (vr.scopeengaged || vr.vstock_engaged)
|
||||
{
|
||||
//Clear weapon offset
|
||||
VectorSet(vr.weaponoffset, 0, 0, 0);
|
||||
if (vr.vstock_engaged)
|
||||
{
|
||||
//Copy weapon offset X
|
||||
vr.weaponoffset[0] = vr.vstock_weapon_offset[1];
|
||||
vr.weaponoffset[1] = vr.vstock_weapon_offset[2];
|
||||
vr.weaponoffset[2] = vr.vstock_weapon_offset[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
//Clear weapon offset
|
||||
VectorSet(vr.weaponoffset, 0, 0, 0);
|
||||
}
|
||||
|
||||
VectorSet(currentScopeAngles, vr.weaponangles[PITCH], vr.weaponangles[YAW], vr.hmdorientation[ROLL]);
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@ Authors : Simon Brown
|
|||
|
||||
*************************************************************************************/
|
||||
|
||||
#include <VrApi.h>
|
||||
#include <VrApi_Helpers.h>
|
||||
#include <VrApi_SystemUtils.h>
|
||||
#include <VrApi_Input.h>
|
||||
#include <VrApi_Types.h>
|
||||
#include "../../../../../../VrApi/Include/VrApi.h"
|
||||
#include "../../../../../../VrApi/Include/VrApi_Helpers.h"
|
||||
#include "../../../../../../VrApi/Include/VrApi_SystemUtils.h"
|
||||
#include "../../../../../../VrApi/Include/VrApi_Input.h"
|
||||
#include "../../../../../../VrApi/Include/VrApi_Types.h"
|
||||
#include <android/keycodes.h>
|
||||
|
||||
#include "VrInput.h"
|
||||
|
@ -20,7 +20,7 @@ Authors : Simon Brown
|
|||
#include <src/qcommon/qcommon.h>
|
||||
#include <src/client/client.h>
|
||||
|
||||
#include "../../../../../../VrApi/Include/VrApi_Input.h"
|
||||
|
||||
|
||||
#define WP_AKIMBO 20
|
||||
|
||||
|
@ -182,10 +182,10 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
}
|
||||
}
|
||||
|
||||
//Engage scope if conditions are right
|
||||
//Engage scope / virtual stock if conditions are right
|
||||
qboolean scopeready = vr.weapon_stabilised && (distanceToHMD < SCOPE_ENGAGE_DISTANCE);
|
||||
static qboolean lastScopeready = qfalse;
|
||||
if (scopeready != lastScopeready) {
|
||||
static qboolean lastScopeReady = qfalse;
|
||||
if (scopeready != lastScopeReady) {
|
||||
if (vr.scopedweapon && !vr.scopedetached) {
|
||||
if (!vr.scopeengaged && scopeready) {
|
||||
ALOGV("**WEAPON EVENT** trigger scope mode");
|
||||
|
@ -195,10 +195,21 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
ALOGV("**WEAPON EVENT** disable scope mode");
|
||||
sendButtonActionSimple("weapalt");
|
||||
}
|
||||
lastScopeready = scopeready;
|
||||
lastScopeReady = scopeready;
|
||||
}
|
||||
}
|
||||
|
||||
//Engage scope / virtual stock if conditions are right
|
||||
qboolean vstockReady = vr.weapon_stabilised && (distanceToHMD < VSTOCK_ENGAGE_DISTANCE) &&
|
||||
(vr.vstock_weapon && vr_virtual_stock->integer > 0);
|
||||
if (vstockReady != vr.vstock_engaged) {
|
||||
vr.vstock_engaged = vstockReady;
|
||||
|
||||
//Resync on either transition
|
||||
RTCWVR_ResyncClientYawWithGameYaw();
|
||||
}
|
||||
|
||||
|
||||
static qboolean scopeEngaged = qfalse;
|
||||
if (scopeEngaged != vr.scopeengaged)
|
||||
{
|
||||
|
@ -264,21 +275,34 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
|
||||
if (vr.weapon_stabilised || vr.dualwield)
|
||||
{
|
||||
float z = pOff->HeadPose.Pose.Position.z - pWeapon->HeadPose.Pose.Position.z;
|
||||
float x = pOff->HeadPose.Pose.Position.x - pWeapon->HeadPose.Pose.Position.x;
|
||||
float y = pOff->HeadPose.Pose.Position.y - pWeapon->HeadPose.Pose.Position.y;
|
||||
float zxDist = length(x, z);
|
||||
if (vr.scopeengaged || vr.vstock_engaged)
|
||||
{
|
||||
float x = pOff->HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
float y = pOff->HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
float z = pOff->HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
if (vr.dualwield) {
|
||||
//SUPER FUDGE
|
||||
VectorSet(vr.weaponangles, vr.weaponangles[PITCH],
|
||||
-90.0f-degrees(atan2f(x, -z)), degrees(atanf(y / zxDist)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
|
||||
-degrees(atan2f(x, -z)), vr.weaponangles[ROLL]);
|
||||
-degrees(atan2f(x, -z)), 0);
|
||||
}
|
||||
} else {
|
||||
float x = pOff->HeadPose.Pose.Position.x - pWeapon->HeadPose.Pose.Position.x;
|
||||
float y = pOff->HeadPose.Pose.Position.y - pWeapon->HeadPose.Pose.Position.y;
|
||||
float z = pOff->HeadPose.Pose.Position.z - pWeapon->HeadPose.Pose.Position.z;
|
||||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
if (vr.dualwield) {
|
||||
//SUPER FUDGE
|
||||
VectorSet(vr.weaponangles, vr.weaponangles[PITCH],
|
||||
-90.0f-degrees(atan2f(x, -z)), degrees(atanf(y / zxDist)));
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
|
||||
-degrees(atan2f(x, -z)), vr.weaponangles[ROLL]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,6 +274,29 @@ int weapBanksMultiPlayer[MAX_WEAP_BANKS_MP][MAX_WEAPS_IN_BANK_MP] = {
|
|||
|
||||
//----(SA) end
|
||||
|
||||
//These are in real world units (metres)
|
||||
float virtualStockOffsets[WP_SILENCER][3] = {
|
||||
//Right Up Forward
|
||||
{0, 0, 0} ,//WP_NONE,
|
||||
{0, 0, 0} ,//WP_KNIFE,
|
||||
{0, 0, 0} ,//WP_LUGER,
|
||||
{0, 0, 0} ,//WP_MP40,
|
||||
{0.03f, -0.08f, -0.35f} ,//WP_MAUSER,
|
||||
{0.03f, -0.12f, -0.25f} ,//WP_FG42,
|
||||
{0, 0, 0} ,//WP_GRENADE_LAUNCHER,
|
||||
{0, 0, 0} ,//WP_PANZERFAUST,
|
||||
{0, 0, 0} ,//WP_VENOM,
|
||||
{0, 0, 0} ,//WP_FLAMETHROWER,
|
||||
{0, 0, 0} ,//WP_TESLA,
|
||||
{0, 0, 0} ,//WP_COLT,
|
||||
{0.03f, -0.108f, -0.3f} ,//WP_THOMPSON,
|
||||
{0, 0, 0} ,//WP_GARAND,
|
||||
{0, 0, 0} ,//WP_GRENADE_PINEAPPLE,
|
||||
{0, 0, 0} ,//WP_SNIPERRIFLE,
|
||||
{0, 0, 0} ,//WP_SNOOPERSCOPE,
|
||||
{0, 0, 0} ,//WP_FG42SCOPE,
|
||||
{0.0325f, -0.06f, -0.24f}//WP_STEN,
|
||||
};
|
||||
|
||||
/*
|
||||
==============
|
||||
|
@ -3638,12 +3661,20 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
|||
case WP_KNIFE:
|
||||
cgVR->velocitytriggered = qtrue;
|
||||
cgVR->scopedweapon = qfalse;
|
||||
cgVR->vstock_weapon = qfalse;
|
||||
break;
|
||||
case WP_FG42:
|
||||
case WP_MAUSER:
|
||||
cgVR->velocitytriggered = qfalse;
|
||||
cgVR->scopedweapon = qtrue;
|
||||
cgVR->detachablescope = qtrue;
|
||||
cgVR->vstock_weapon = cgVR->scopedetached; // only available when not scoped
|
||||
break;
|
||||
case WP_THOMPSON:
|
||||
case WP_STEN:
|
||||
cgVR->velocitytriggered = qfalse;
|
||||
cgVR->scopedweapon = qfalse;
|
||||
cgVR->vstock_weapon = qtrue; // only available when not scoped
|
||||
break;
|
||||
case WP_GARAND:
|
||||
case WP_SNOOPERSCOPE:
|
||||
|
@ -3653,13 +3684,35 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
|||
cgVR->scopedweapon = qtrue;
|
||||
cgVR->scopedetached = qfalse;
|
||||
cgVR->detachablescope = qfalse;
|
||||
cgVR->vstock_weapon = qfalse;
|
||||
break;
|
||||
default:
|
||||
cgVR->velocitytriggered = qfalse;
|
||||
cgVR->scopedweapon = qfalse;
|
||||
cgVR->vstock_weapon = qfalse;
|
||||
break;
|
||||
}
|
||||
|
||||
int vStock = trap_Cvar_VariableIntegerValue("vr_virtual_stock");
|
||||
if (vStock) {
|
||||
float multiplier = (vStock == 1 ? -1.0f : 1.0f);
|
||||
|
||||
vec3_t offset;
|
||||
VectorClear(offset);
|
||||
|
||||
vec3_t orientation;
|
||||
VectorCopy(cgVR->hmdorientation, orientation);
|
||||
orientation[PITCH] *= -1.0f;
|
||||
orientation[ROLL] = 0;
|
||||
|
||||
vec3_t forward, right, up;
|
||||
AngleVectors(orientation, forward, right, up);
|
||||
VectorMA(offset, virtualStockOffsets[ps->weapon][0] * multiplier, right, offset);
|
||||
VectorMA(offset, virtualStockOffsets[ps->weapon][1], up, offset);
|
||||
VectorMA(offset, virtualStockOffsets[ps->weapon][2], forward, offset);
|
||||
|
||||
VectorCopy(offset, cgVR->vstock_weapon_offset);
|
||||
}
|
||||
|
||||
// add everything onto the hand
|
||||
CG_AddPlayerWeapon(&hand, ps, &cg.predictedPlayerEntity);
|
||||
|
|
|
@ -42,7 +42,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
// q_shared.h -- included first by ALL program modules.
|
||||
// A user mod should never modify this file
|
||||
|
||||
#define Q3_VERSION "RTCWQuest 1.0.1 (Wolf 1.41)"
|
||||
#define Q3_VERSION "RTCWQuest 1.1.0 (Wolf 1.41)"
|
||||
// ver 1.0.0 - release
|
||||
// ver 1.0.1 - post-release work
|
||||
// ver 1.1.0 - patch 1 (12/12/01)
|
||||
|
|
|
@ -274,13 +274,31 @@ itemDef
|
|||
visible 1
|
||||
}
|
||||
|
||||
itemDef {
|
||||
name vr
|
||||
group grpControls
|
||||
text "Virtual Stock:"
|
||||
type ITEM_TYPE_MULTI
|
||||
cvar "vr_virtual_stock"
|
||||
cvarFloatList {"Off" 0 "Enabled (Right Eye)" 1 "Enabled (Left Eye)" 2 }
|
||||
rect 82 165 290 12
|
||||
textalign ITEM_ALIGN_RIGHT
|
||||
textalignx 142
|
||||
textaligny 10
|
||||
textscale .23
|
||||
style WINDOW_STYLE_FILLED
|
||||
backcolor 1 1 1 .07
|
||||
forecolor 1 1 1 1
|
||||
visible 1
|
||||
}
|
||||
|
||||
itemDef {
|
||||
name vr
|
||||
group grpControls
|
||||
type ITEM_TYPE_SLIDER
|
||||
text "Screen Distance:"
|
||||
cvarfloat "vr_screen_dist" 2.0 0.5 8.0
|
||||
rect 82 165 290 12
|
||||
rect 82 180 290 12
|
||||
textalign ITEM_ALIGN_RIGHT
|
||||
textalignx 142
|
||||
textaligny 10
|
||||
|
@ -299,7 +317,7 @@ itemDef
|
|||
type ITEM_TYPE_MULTI
|
||||
cvar "vr_cinematic_stereo"
|
||||
cvarFloatList {"2D" 0 "3D" 1 }
|
||||
rect 82 180 290 12
|
||||
rect 82 195 290 12
|
||||
textalign ITEM_ALIGN_RIGHT
|
||||
textalignx 142
|
||||
textaligny 10
|
||||
|
|
|
@ -247,13 +247,31 @@ itemDef
|
|||
visible 1
|
||||
}
|
||||
|
||||
itemDef {
|
||||
name ingame_vr
|
||||
group grpControls
|
||||
text "Virtual Stock:"
|
||||
type ITEM_TYPE_MULTI
|
||||
cvar "vr_virtual_stock"
|
||||
cvarFloatList {"Off" 0 "Enabled (Right Eye)" 1 "Enabled (Left Eye)" 2 }
|
||||
rect 82 165 290 12
|
||||
textalign ITEM_ALIGN_RIGHT
|
||||
textalignx 142
|
||||
textaligny 10
|
||||
textscale .23
|
||||
style WINDOW_STYLE_FILLED
|
||||
backcolor 1 1 1 .07
|
||||
forecolor 1 1 1 1
|
||||
visible 1
|
||||
}
|
||||
|
||||
itemDef {
|
||||
name ingame_vr
|
||||
group grpControls
|
||||
type ITEM_TYPE_SLIDER
|
||||
text "Screen Distance:"
|
||||
cvarfloat "vr_screen_dist" 2.0 0.5 8.0
|
||||
rect 82 165 290 12
|
||||
rect 82 180 290 12
|
||||
textalign ITEM_ALIGN_RIGHT
|
||||
textalignx 142
|
||||
textaligny 10
|
||||
|
@ -272,7 +290,7 @@ itemDef
|
|||
type ITEM_TYPE_MULTI
|
||||
cvar "vr_cinematic_stereo"
|
||||
cvarFloatList {"2D" 0 "3D" 1 }
|
||||
rect 82 180 290 12
|
||||
rect 82 195 290 12
|
||||
textalign ITEM_ALIGN_RIGHT
|
||||
textalignx 142
|
||||
textaligny 10
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue