mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-25 13:31:10 +00:00
Merge pull request #91 from petr666/master
Implement virtual gun stock (OpenXR)
This commit is contained in:
commit
6d9951dd95
4 changed files with 47 additions and 16 deletions
|
@ -65,7 +65,7 @@ typedef struct {
|
||||||
|
|
||||||
menuradiobutton_s autoswitch;
|
menuradiobutton_s autoswitch;
|
||||||
menuradiobutton_s scope;
|
menuradiobutton_s scope;
|
||||||
menuradiobutton_s twohanded;
|
menulist_s twohanded;
|
||||||
menulist_s directionmode;
|
menulist_s directionmode;
|
||||||
menulist_s snapturn;
|
menulist_s snapturn;
|
||||||
menuradiobutton_s uturn;
|
menuradiobutton_s uturn;
|
||||||
|
@ -84,7 +84,7 @@ static controls3_t s_controls3;
|
||||||
static void Controls3_SetMenuItems( void ) {
|
static void Controls3_SetMenuItems( void ) {
|
||||||
s_controls3.autoswitch.curvalue = trap_Cvar_VariableValue( "cg_autoswitch" ) != 0;
|
s_controls3.autoswitch.curvalue = trap_Cvar_VariableValue( "cg_autoswitch" ) != 0;
|
||||||
s_controls3.scope.curvalue = trap_Cvar_VariableValue( "vr_weaponScope" ) != 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.directionmode.curvalue = (int)trap_Cvar_VariableValue( "vr_directionMode" ) % NUM_DIRECTIONMODE;
|
||||||
s_controls3.snapturn.curvalue = (int)trap_Cvar_VariableValue( "vr_snapturn" ) / 45;
|
s_controls3.snapturn.curvalue = (int)trap_Cvar_VariableValue( "vr_snapturn" ) / 45;
|
||||||
s_controls3.uturn.curvalue = trap_Cvar_VariableValue( "vr_uturn" ) != 0;
|
s_controls3.uturn.curvalue = trap_Cvar_VariableValue( "vr_uturn" ) != 0;
|
||||||
|
@ -268,6 +268,14 @@ static void Controls3_MenuInit( void ) {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *s_twohandedmode[] =
|
||||||
|
{
|
||||||
|
"Disabled",
|
||||||
|
"Enabled (Basic)",
|
||||||
|
"Enabled (VR Gun Stock)",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
memset( &s_controls3, 0 ,sizeof(controls3_t) );
|
memset( &s_controls3, 0 ,sizeof(controls3_t) );
|
||||||
|
|
||||||
Controls3_Cache();
|
Controls3_Cache();
|
||||||
|
@ -317,13 +325,15 @@ static void Controls3_MenuInit( void ) {
|
||||||
s_controls3.scope.generic.y = y;
|
s_controls3.scope.generic.y = y;
|
||||||
|
|
||||||
y += BIGCHAR_HEIGHT+2;
|
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.name = "Two-Handed Weapons:";
|
||||||
s_controls3.twohanded.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
|
s_controls3.twohanded.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
|
||||||
s_controls3.twohanded.generic.callback = Controls3_MenuEvent;
|
s_controls3.twohanded.generic.callback = Controls3_MenuEvent;
|
||||||
s_controls3.twohanded.generic.id = ID_TWOHANDED;
|
s_controls3.twohanded.generic.id = ID_TWOHANDED;
|
||||||
s_controls3.twohanded.generic.x = VR_X_POS;
|
s_controls3.twohanded.generic.x = VR_X_POS;
|
||||||
s_controls3.twohanded.generic.y = y;
|
s_controls3.twohanded.generic.y = y;
|
||||||
|
s_controls3.twohanded.itemnames = s_twohandedmode;
|
||||||
|
s_controls3.twohanded.numitems = 3;
|
||||||
|
|
||||||
y += BIGCHAR_HEIGHT+2;
|
y += BIGCHAR_HEIGHT+2;
|
||||||
s_controls3.directionmode.generic.type = MTYPE_SPINCONTROL;
|
s_controls3.directionmode.generic.type = MTYPE_SPINCONTROL;
|
||||||
|
|
|
@ -889,20 +889,39 @@ static void IN_VRController( qboolean isRightController, XrPosef pose )
|
||||||
|
|
||||||
if (vr_twoHandedWeapons->integer && vr.weapon_stabilised)
|
if (vr_twoHandedWeapons->integer && vr.weapon_stabilised)
|
||||||
{
|
{
|
||||||
//Apply smoothing to the weapon hand
|
if (vr_twoHandedWeapons->integer == 2) // Virtual gun stock
|
||||||
vec3_t smooth_weaponoffset;
|
{
|
||||||
VectorAdd(vr.weaponoffset, vr.weaponoffset_last[0], smooth_weaponoffset);
|
// Offset to the appropriate eye a little bit
|
||||||
VectorAdd(smooth_weaponoffset, vr.weaponoffset_last[1],smooth_weaponoffset);
|
vec2_t xy;
|
||||||
VectorScale(smooth_weaponoffset, 1.0f/3.0f, smooth_weaponoffset);
|
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); // Use a point lower
|
||||||
|
float z = vr.offhandposition[2] - (vr.hmdposition[2] + xy[1]);
|
||||||
|
|
||||||
vec3_t vec;
|
float zxDist = length(x, z);
|
||||||
VectorSubtract(vr.offhandoffset, smooth_weaponoffset, vec);
|
|
||||||
|
|
||||||
float zxDist = length(vec[0], vec[2]);
|
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;
|
||||||
|
VectorAdd(vr.weaponoffset, vr.weaponoffset_last[0], smooth_weaponoffset);
|
||||||
|
VectorAdd(smooth_weaponoffset, vr.weaponoffset_last[1],smooth_weaponoffset);
|
||||||
|
VectorScale(smooth_weaponoffset, 1.0f/3.0f, smooth_weaponoffset);
|
||||||
|
|
||||||
if (zxDist != 0.0f && vec[2] != 0.0f) {
|
vec3_t vec;
|
||||||
VectorSet(vr.weaponangles, -degrees(atanf(vec[1] / zxDist)),
|
VectorSubtract(vr.offhandoffset, smooth_weaponoffset, vec);
|
||||||
-degrees(atan2f(vec[0], -vec[2])), vr.weaponangles[ROLL] / 2.0f); //Dampen roll on stabilised weapon
|
|
||||||
|
float zxDist = length(vec[0], vec[2]);
|
||||||
|
|
||||||
|
if (zxDist != 0.0f && vec[2] != 0.0f) {
|
||||||
|
VectorSet(vr.weaponangles, -degrees(atanf(vec[1] / zxDist)),
|
||||||
|
-degrees(atan2f(vec[0], -vec[2])), vr.weaponangles[ROLL] / 2.0f); // Dampen roll on stabilised weapon
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,9 +69,10 @@ itemDef {
|
||||||
itemDef {
|
itemDef {
|
||||||
name controls3
|
name controls3
|
||||||
group grpControls3
|
group grpControls3
|
||||||
type ITEM_TYPE_YESNO
|
type ITEM_TYPE_MULTI
|
||||||
text "Two-Handed Weapons:"
|
text "Two-Handed Weapons:"
|
||||||
cvar "vr_twoHandedWeapons"
|
cvar "vr_twoHandedWeapons"
|
||||||
|
cvarFloatList { "Disabled" 0 "Enabled (Basic)" 1 "Enabled (VR Gun Stock)" 2}
|
||||||
rect 99 125 256 20
|
rect 99 125 256 20
|
||||||
textalign ITEM_ALIGN_RIGHT
|
textalign ITEM_ALIGN_RIGHT
|
||||||
textalignx 128
|
textalignx 128
|
||||||
|
|
|
@ -191,9 +191,10 @@ itemDef {
|
||||||
itemDef {
|
itemDef {
|
||||||
name controls
|
name controls
|
||||||
group grpControls
|
group grpControls
|
||||||
type ITEM_TYPE_YESNO
|
type ITEM_TYPE_MULTI
|
||||||
text "Two-Handed Weapons:"
|
text "Two-Handed Weapons:"
|
||||||
cvar "vr_twoHandedWeapons"
|
cvar "vr_twoHandedWeapons"
|
||||||
|
cvarFloatList { "Disabled" 0 "Enabled (Basic)" 1 "Enabled (VR Gun Stock)" 2}
|
||||||
rect 30 56 200 20
|
rect 30 56 200 20
|
||||||
textalign ITEM_ALIGN_RIGHT
|
textalign ITEM_ALIGN_RIGHT
|
||||||
textalignx 143
|
textalignx 143
|
||||||
|
|
Loading…
Reference in a new issue