mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-22 12:11:24 +00:00
Finished implementation of disruptor scope
This commit is contained in:
parent
baafc2ec8d
commit
6695f0bc0d
9 changed files with 62 additions and 81 deletions
|
@ -1751,8 +1751,17 @@ void JKVR_submitFrame()
|
||||||
layer.Textures[eye].SwapChainIndex = frameBuffer->TextureSwapChainIndex;
|
layer.Textures[eye].SwapChainIndex = frameBuffer->TextureSwapChainIndex;
|
||||||
|
|
||||||
ovrMatrix4f projectionMatrix;
|
ovrMatrix4f projectionMatrix;
|
||||||
|
|
||||||
|
if (vr.cgzoommode)
|
||||||
|
{
|
||||||
|
projectionMatrix = ovrMatrix4f_CreateProjectionFov(vr.fov / 1.4, vr.fov / 1.4,
|
||||||
|
0.0f, 0.0f, 0.1f, 0.0f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
projectionMatrix = ovrMatrix4f_CreateProjectionFov(vr.fov, vr.fov,
|
projectionMatrix = ovrMatrix4f_CreateProjectionFov(vr.fov, vr.fov,
|
||||||
0.0f, 0.0f, 0.1f, 0.0f);
|
0.0f, 0.0f, 0.1f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection(&projectionMatrix);
|
layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection(&projectionMatrix);
|
||||||
|
|
||||||
|
|
|
@ -47,14 +47,6 @@ typedef struct {
|
||||||
|
|
||||||
int item_selector = 0; // 1 - weapons/gadgets/saber stance, 2 - Force powers
|
int item_selector = 0; // 1 - weapons/gadgets/saber stance, 2 - Force powers
|
||||||
|
|
||||||
//Lots of scope weapon stuff
|
|
||||||
bool scopeengaged; // Scope has been engaged on a scoped weapon
|
|
||||||
bool scopedweapon; // Weapon scope is available
|
|
||||||
bool scopedetached; // Scope has been detached from weapon
|
|
||||||
bool detachablescope; // Scope can be detached from weapon
|
|
||||||
|
|
||||||
bool hasbinoculars;
|
|
||||||
|
|
||||||
bool velocitytriggered;
|
bool velocitytriggered;
|
||||||
float primaryswingvelocity;
|
float primaryswingvelocity;
|
||||||
bool primaryVelocityTriggeredAttack;
|
bool primaryVelocityTriggeredAttack;
|
||||||
|
|
|
@ -4,11 +4,7 @@
|
||||||
|
|
||||||
#include "VrCommon.h"
|
#include "VrCommon.h"
|
||||||
|
|
||||||
#define STABILISATION_DISTANCE 0.25
|
#define STABILISATION_DISTANCE 0.28
|
||||||
#define SCOPE_ENGAGE_DISTANCE 0.25
|
|
||||||
#define VSTOCK_ENGAGE_DISTANCE 0.25
|
|
||||||
#define BINOCULAR_ENGAGE_DISTANCE 0.25
|
|
||||||
#define VELOCITY_TRIGGER 1.0
|
|
||||||
|
|
||||||
extern ovrInputStateTrackedRemote leftTrackedRemoteState_old;
|
extern ovrInputStateTrackedRemote leftTrackedRemoteState_old;
|
||||||
extern ovrInputStateTrackedRemote leftTrackedRemoteState_new;
|
extern ovrInputStateTrackedRemote leftTrackedRemoteState_new;
|
||||||
|
@ -42,6 +38,5 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
|
||||||
|
|
||||||
|
|
||||||
void CalculateShoulderPosition();
|
void CalculateShoulderPosition();
|
||||||
void updateScopeAngles();
|
|
||||||
|
|
||||||
#endif //vrinput_h
|
#endif //vrinput_h
|
|
@ -176,31 +176,6 @@ void acquireTrackedRemotesData(ovrMobile *Ovr, double displayTime) {//The amount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//YAW: Left increase, Right decrease
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
VectorSet(currentScopeAngles, vr.weaponangles[PITCH], vr.weaponangles[YAW], vr.hmdorientation[ROLL]);
|
|
||||||
|
|
||||||
//Set "view" Angles
|
|
||||||
VectorCopy(currentScopeAngles, vr.hmdorientation);
|
|
||||||
|
|
||||||
//Orientation
|
|
||||||
VectorSubtract(lastScopeAngles, currentScopeAngles, vr.hmdorientation_delta);
|
|
||||||
|
|
||||||
//Keep this for our records
|
|
||||||
VectorCopy(currentScopeAngles, lastScopeAngles);
|
|
||||||
} else {
|
|
||||||
VectorSet(currentScopeAngles, vr.weaponangles[PITCH], vr.weaponangles[YAW], vr.hmdorientation[ROLL]);
|
|
||||||
VectorCopy(currentScopeAngles, lastScopeAngles);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PortableMouseAbs(float x,float y);
|
void PortableMouseAbs(float x,float y);
|
||||||
float clamp(float _min, float _val, float _max)
|
float clamp(float _min, float _val, float _max)
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,12 +242,11 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
if (vr.weapon_stabilised &&
|
if (vr.weapon_stabilised &&
|
||||||
VectorLength(vr.weaponoffset) < 0.24f &&
|
VectorLength(vr.weaponoffset) < 0.24f &&
|
||||||
vr.cgzoommode == 0) {
|
vr.cgzoommode == 0) {
|
||||||
sendButtonAction("+altattack", true);
|
sendButtonAction("disruptorscope", true);
|
||||||
} else if ((VectorLength(vr.weaponoffset) >= 0.24f || !vr.weapon_stabilised) &&
|
} else if ((VectorLength(vr.weaponoffset) >= 0.24f || !vr.weapon_stabilised) &&
|
||||||
vr.cgzoommode == 2) {
|
vr.cgzoommode == 2) {
|
||||||
sendButtonActionSimple("exitzoom");
|
sendButtonActionSimple("exitzoom");
|
||||||
}
|
}
|
||||||
//We don't need to send the -altattack as the block below in the next frame will send it for us
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vr.cgzoommode > 0)
|
if (vr.cgzoommode > 0)
|
||||||
|
@ -289,28 +288,6 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Engage scope / virtual stock if conditions are right
|
|
||||||
bool scopeready = vr.weapon_stabilised && (distanceToHMD < SCOPE_ENGAGE_DISTANCE);
|
|
||||||
static bool lastScopeReady = qfalse;
|
|
||||||
if (scopeready != lastScopeReady) {
|
|
||||||
if (vr.scopedweapon && !vr.scopedetached) {
|
|
||||||
if (!vr.scopeengaged && scopeready) {
|
|
||||||
ALOGV("**WEAPON EVENT** trigger scope mode");
|
|
||||||
sendButtonActionSimple("weapalt");
|
|
||||||
} else if (vr.scopeengaged && !scopeready) {
|
|
||||||
ALOGV("**WEAPON EVENT** disable scope mode");
|
|
||||||
sendButtonActionSimple("weapalt");
|
|
||||||
}
|
|
||||||
lastScopeReady = scopeready;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Engage scope / virtual stock (iron sight lock) if conditions are right
|
|
||||||
static bool scopeEngaged = qfalse;
|
|
||||||
if (scopeEngaged != vr.scopeengaged) {
|
|
||||||
scopeEngaged = vr.scopeengaged;
|
|
||||||
}
|
|
||||||
|
|
||||||
//dominant hand stuff first
|
//dominant hand stuff first
|
||||||
{
|
{
|
||||||
//Record recent weapon position for trajectory based stuff
|
//Record recent weapon position for trajectory based stuff
|
||||||
|
@ -403,7 +380,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vr.weapon_stabilised) {
|
if (vr.weapon_stabilised) {
|
||||||
if (vr.scopeengaged || vr_virtual_stock->integer == 1) {
|
if (vr_virtual_stock->integer == 1) {
|
||||||
//offset to the appropriate eye a little bit
|
//offset to the appropriate eye a little bit
|
||||||
vec2_t xy;
|
vec2_t xy;
|
||||||
rotateAboutOrigin(Cvar_VariableValue("cg_stereoSeparation") / 2.0f, 0.0f,
|
rotateAboutOrigin(Cvar_VariableValue("cg_stereoSeparation") / 2.0f, 0.0f,
|
||||||
|
@ -418,7 +395,26 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
|
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
|
||||||
-degrees(atan2f(x, -z)), 0);
|
-degrees(atan2f(x, -z)), 0);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else if (vr.cgzoommode == 2)
|
||||||
|
{
|
||||||
|
float x =
|
||||||
|
pOff->HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||||
|
float y =
|
||||||
|
pOff->HeadPose.Pose.Position.y - (vr.hmdposition[1] - 0.1f);
|
||||||
|
float z =
|
||||||
|
pOff->HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||||
|
float zxDist = length(x, z);
|
||||||
|
|
||||||
|
if (zxDist != 0.0f && z != 0.0f) {
|
||||||
|
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)),
|
||||||
|
-degrees(atan2f(x, -z)), vr.weaponangles[ROLL] /
|
||||||
|
2.0f); //Dampen roll on stabilised weapon
|
||||||
|
vr.weaponposition[1] += 0.1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
float x =
|
float x =
|
||||||
pOff->HeadPose.Pose.Position.x - pWeapon->HeadPose.Pose.Position.x;
|
pOff->HeadPose.Pose.Position.x - pWeapon->HeadPose.Pose.Position.x;
|
||||||
float y =
|
float y =
|
||||||
|
@ -583,9 +579,9 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
|
|
||||||
//B Button
|
//B Button
|
||||||
if ((primaryButtonsNew & primaryButton2) != (primaryButtonsOld & primaryButton2)) {
|
if ((primaryButtonsNew & primaryButton2) != (primaryButtonsOld & primaryButton2)) {
|
||||||
if (vr.cgzoommode == 1 || vr.cgzoommode == 3)
|
if (vr.cgzoommode)
|
||||||
{
|
{
|
||||||
sendButtonActionSimple("invuse");
|
sendButtonActionSimple("exitzoom");
|
||||||
}
|
}
|
||||||
else if (cl.frame.ps.weapon == WP_SABER && vr.velocitytriggered)
|
else if (cl.frame.ps.weapon == WP_SABER && vr.velocitytriggered)
|
||||||
{
|
{
|
||||||
|
@ -676,9 +672,9 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
|
|
||||||
//Move a lot slower if scope is engaged
|
//Move a lot slower if scope is engaged
|
||||||
remote_movementSideways =
|
remote_movementSideways =
|
||||||
v[0] * (vr.scopeengaged ? 0.3f : 1.0f) * vr_movement_multiplier->value;
|
v[0] * vr_movement_multiplier->value;
|
||||||
remote_movementForward =
|
remote_movementForward =
|
||||||
v[1] * (vr.scopeengaged ? 0.3f : 1.0f) * vr_movement_multiplier->value;
|
v[1] * vr_movement_multiplier->value;
|
||||||
ALOGV(" remote_movementSideways: %f, remote_movementForward: %f",
|
ALOGV(" remote_movementSideways: %f, remote_movementForward: %f",
|
||||||
remote_movementSideways,
|
remote_movementSideways,
|
||||||
remote_movementForward);
|
remote_movementForward);
|
||||||
|
@ -714,7 +710,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
(!vr.third_person && vr_turn_mode->integer == 1);
|
(!vr.third_person && vr_turn_mode->integer == 1);
|
||||||
|
|
||||||
static int increaseSnap = true;
|
static int increaseSnap = true;
|
||||||
if (!vr.item_selector && !vr.scopeengaged) {
|
if (!vr.item_selector) {
|
||||||
if (usingSnapTurn) {
|
if (usingSnapTurn) {
|
||||||
if (primaryJoystickX > 0.7f) {
|
if (primaryJoystickX > 0.7f) {
|
||||||
if (increaseSnap) {
|
if (increaseSnap) {
|
||||||
|
@ -793,8 +789,6 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateScopeAngles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,10 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
||||||
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer && !vr->scopeengaged)
|
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer)
|
||||||
{
|
{
|
||||||
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
|
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.0f);
|
||||||
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
|
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.0f);
|
||||||
|
|
||||||
float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
|
float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
|
||||||
if (cg.refdef.stereoView == STEREO_LEFT) {
|
if (cg.refdef.stereoView == STEREO_LEFT) {
|
||||||
|
|
|
@ -208,6 +208,7 @@ void CG_ItemSelectorNext_f( void );
|
||||||
void CG_ItemSelectorPrev_f( void );
|
void CG_ItemSelectorPrev_f( void );
|
||||||
void CG_ToggleSaber_f( void );
|
void CG_ToggleSaber_f( void );
|
||||||
void CG_ExitZoom_f( void );
|
void CG_ExitZoom_f( void );
|
||||||
|
void CG_DisruptorScope_f( void );
|
||||||
|
|
||||||
/* This array MUST be sorted correctly by alphabetical name field */
|
/* This array MUST be sorted correctly by alphabetical name field */
|
||||||
static consoleCommand_t commands[] = {
|
static consoleCommand_t commands[] = {
|
||||||
|
@ -251,6 +252,7 @@ static consoleCommand_t commands[] = {
|
||||||
{ "itemselectorprev", CG_ItemSelectorPrev_f },
|
{ "itemselectorprev", CG_ItemSelectorPrev_f },
|
||||||
{ "togglesaber", CG_ToggleSaber_f },
|
{ "togglesaber", CG_ToggleSaber_f },
|
||||||
{ "exitzoom", CG_ExitZoom_f },
|
{ "exitzoom", CG_ExitZoom_f },
|
||||||
|
{ "disruptorscope", CG_DisruptorScope_f },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const size_t numCommands = ARRAY_LEN( commands );
|
static const size_t numCommands = ARRAY_LEN( commands );
|
||||||
|
|
|
@ -27,10 +27,10 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
||||||
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer && !vr->scopeengaged)
|
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer)
|
||||||
{
|
{
|
||||||
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
|
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.0f);
|
||||||
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
|
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.0f);
|
||||||
|
|
||||||
float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
|
float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
|
||||||
if (cg.refdef.stereoView == STEREO_LEFT) {
|
if (cg.refdef.stereoView == STEREO_LEFT) {
|
||||||
|
|
|
@ -2651,9 +2651,11 @@ void CG_Weapon_f( void )
|
||||||
|
|
||||||
void Cmd_UseInventory_f(gentity_t *ent);
|
void Cmd_UseInventory_f(gentity_t *ent);
|
||||||
|
|
||||||
|
extern float cg_zoomFov; //from cg_view.cpp
|
||||||
|
|
||||||
void CG_ExitZoom_f( )
|
void CG_ExitZoom_f( )
|
||||||
{
|
{
|
||||||
if ( cg.zoomMode == 2 )
|
if ( cg.zoomMode )
|
||||||
{
|
{
|
||||||
G_SoundOnEnt( pm->gent, CHAN_AUTO, "sound/weapons/disruptor/zoomend.wav" );
|
G_SoundOnEnt( pm->gent, CHAN_AUTO, "sound/weapons/disruptor/zoomend.wav" );
|
||||||
// already zooming, so must be wanting to turn it off
|
// already zooming, so must be wanting to turn it off
|
||||||
|
@ -2663,6 +2665,18 @@ void CG_ExitZoom_f( )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CG_DisruptorScope_f( )
|
||||||
|
{
|
||||||
|
if ( cg.zoomMode == 0 || cg.zoomMode == 3 )
|
||||||
|
{
|
||||||
|
G_SoundOnEnt( pm->gent, CHAN_AUTO, "sound/weapons/disruptor/zoomstart.wav" );
|
||||||
|
// not already zooming, so do it now
|
||||||
|
cg.zoomMode = 2;
|
||||||
|
cg.zoomLocked = qfalse;
|
||||||
|
cg_zoomFov = 80.0f;//(cg.overrides.active&CG_OVERRIDE_FOV) ? cg.overrides.fov : cg_fov.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CG_ToggleSaber_f( )
|
void CG_ToggleSaber_f( )
|
||||||
{
|
{
|
||||||
player->client->ps.saberActive = (qboolean)!player->client->ps.saberActive;
|
player->client->ps.saberActive = (qboolean)!player->client->ps.saberActive;
|
||||||
|
|
Loading…
Reference in a new issue