mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-24 21:11:05 +00:00
Implement virtual gun stock
This commit is contained in:
parent
a235a57205
commit
61faf0a731
4 changed files with 47 additions and 16 deletions
|
@ -65,7 +65,7 @@ typedef struct {
|
|||
|
||||
menuradiobutton_s autoswitch;
|
||||
menuradiobutton_s scope;
|
||||
menuradiobutton_s twohanded;
|
||||
menulist_s twohanded;
|
||||
menulist_s directionmode;
|
||||
menulist_s snapturn;
|
||||
menuradiobutton_s uturn;
|
||||
|
@ -84,7 +84,7 @@ static controls3_t s_controls3;
|
|||
static void Controls3_SetMenuItems( void ) {
|
||||
s_controls3.autoswitch.curvalue = trap_Cvar_VariableValue( "cg_autoswitch" ) != 0;
|
||||
s_controls3.scope.curvalue = trap_Cvar_VariableValue( "vr_weaponScope" ) != 0;
|
||||
s_controls3.twohanded.curvalue = trap_Cvar_VariableValue( "vr_twoHandedWeapons" ) != 0;
|
||||
s_controls3.twohanded.curvalue = trap_Cvar_VariableValue( "vr_twoHandedWeapons" );
|
||||
s_controls3.directionmode.curvalue = (int)trap_Cvar_VariableValue( "vr_directionMode" ) % NUM_DIRECTIONMODE;
|
||||
s_controls3.snapturn.curvalue = (int)trap_Cvar_VariableValue( "vr_snapturn" ) / 45;
|
||||
s_controls3.uturn.curvalue = trap_Cvar_VariableValue( "vr_uturn" ) != 0;
|
||||
|
@ -268,6 +268,14 @@ static void Controls3_MenuInit( void ) {
|
|||
NULL
|
||||
};
|
||||
|
||||
static const char *s_twohandedmode[] =
|
||||
{
|
||||
"Disabled",
|
||||
"Enabled (Basic)",
|
||||
"Enabled (VR Gun Stock)",
|
||||
NULL
|
||||
};
|
||||
|
||||
memset( &s_controls3, 0 ,sizeof(controls3_t) );
|
||||
|
||||
Controls3_Cache();
|
||||
|
@ -317,13 +325,15 @@ static void Controls3_MenuInit( void ) {
|
|||
s_controls3.scope.generic.y = y;
|
||||
|
||||
y += BIGCHAR_HEIGHT+2;
|
||||
s_controls3.twohanded.generic.type = MTYPE_RADIOBUTTON;
|
||||
s_controls3.twohanded.generic.type = MTYPE_SPINCONTROL;
|
||||
s_controls3.twohanded.generic.name = "Two-Handed Weapons:";
|
||||
s_controls3.twohanded.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
|
||||
s_controls3.twohanded.generic.callback = Controls3_MenuEvent;
|
||||
s_controls3.twohanded.generic.id = ID_TWOHANDED;
|
||||
s_controls3.twohanded.generic.x = VR_X_POS;
|
||||
s_controls3.twohanded.generic.y = y;
|
||||
s_controls3.twohanded.itemnames = s_twohandedmode;
|
||||
s_controls3.twohanded.numitems = 3;
|
||||
|
||||
y += BIGCHAR_HEIGHT+2;
|
||||
s_controls3.directionmode.generic.type = MTYPE_SPINCONTROL;
|
||||
|
|
|
@ -888,6 +888,24 @@ static void IN_VRController( qboolean isRightController, XrPosef pose )
|
|||
cl.snap.ps.stats[STAT_HEALTH] > 0;
|
||||
|
||||
if (vr_twoHandedWeapons->integer && vr.weapon_stabilised)
|
||||
{
|
||||
if (vr_twoHandedWeapons->integer == 2) // Virtual gun stock
|
||||
{
|
||||
// Offset to the appropriate eye a little bit
|
||||
vec2_t xy;
|
||||
rotateAboutOrigin(Cvar_VariableValue("cg_stereoSeparation") / 2.0f, 0.0f, -vr.hmdorientation[YAW], xy);
|
||||
float x = vr.offhandposition[0] - (vr.hmdposition[0] + xy[0]);
|
||||
float y = vr.offhandposition[1] - (vr.hmdposition[1] - 0.1f) + vr_heightAdjust->value; // Use a point lower
|
||||
float z = vr.offhandposition[2] - (vr.hmdposition[2] + xy[1]);
|
||||
|
||||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
|
||||
-degrees(atan2f(x, -z)), 0);
|
||||
}
|
||||
}
|
||||
else // Basic two-handed
|
||||
{
|
||||
// Apply smoothing to the weapon hand
|
||||
vec3_t smooth_weaponoffset;
|
||||
|
@ -907,6 +925,7 @@ static void IN_VRController( qboolean isRightController, XrPosef pose )
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static qboolean IN_VRJoystickUse8WayMapping( void ) {
|
||||
char action[256];
|
||||
|
|
|
@ -69,9 +69,10 @@ itemDef {
|
|||
itemDef {
|
||||
name controls3
|
||||
group grpControls3
|
||||
type ITEM_TYPE_YESNO
|
||||
type ITEM_TYPE_MULTI
|
||||
text "Two-Handed Weapons:"
|
||||
cvar "vr_twoHandedWeapons"
|
||||
cvarFloatList { "Disabled" 0 "Enabled (Basic)" 1 "Enabled (VR Gun Stock)" 2}
|
||||
rect 99 125 256 20
|
||||
textalign ITEM_ALIGN_RIGHT
|
||||
textalignx 128
|
||||
|
|
|
@ -191,9 +191,10 @@ itemDef {
|
|||
itemDef {
|
||||
name controls
|
||||
group grpControls
|
||||
type ITEM_TYPE_YESNO
|
||||
type ITEM_TYPE_MULTI
|
||||
text "Two-Handed Weapons:"
|
||||
cvar "vr_twoHandedWeapons"
|
||||
cvarFloatList { "Disabled" 0 "Enabled (Basic)" 1 "Enabled (VR Gun Stock)" 2}
|
||||
rect 30 56 200 20
|
||||
textalign ITEM_ALIGN_RIGHT
|
||||
textalignx 143
|
||||
|
|
Loading…
Reference in a new issue