mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-21 19:51:33 +00:00
First implementation of 1st person saber
This commit is contained in:
parent
5b4d047b5a
commit
2c29c10b42
18 changed files with 93 additions and 23 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.jk2quest"
|
||||
android:versionCode="5"
|
||||
android:versionName="0.0.5" android:installLocation="auto" >
|
||||
android:versionCode="6"
|
||||
android:versionName="0.0.6" android:installLocation="auto" >
|
||||
|
||||
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
||||
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
|
||||
|
|
|
@ -23,7 +23,7 @@ typedef struct {
|
|||
vec3_t hmdorientation_last; // Don't use this, it is just for calculating delta!
|
||||
vec3_t hmdorientation_delta;
|
||||
|
||||
vec3_t weaponangles_knife;
|
||||
vec3_t weaponangles_saber;
|
||||
vec3_t weaponangles;
|
||||
vec3_t weaponangles_last; // Don't use this, it is just for calculating delta!
|
||||
vec3_t weaponangles_delta;
|
||||
|
@ -47,7 +47,8 @@ typedef struct {
|
|||
|
||||
bool hasbinoculars;
|
||||
|
||||
bool velocitytriggered; // Weapon attack triggered by velocity (knife)
|
||||
bool velocitytriggered;
|
||||
float swingvelocity;
|
||||
|
||||
vec3_t offhandangles;
|
||||
vec3_t offhandangles_last; // Don't use this, it is just for calculating delta!
|
||||
|
|
|
@ -108,8 +108,8 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
{
|
||||
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
|
||||
vec3_t rotation = {0};
|
||||
rotation[PITCH] = 30;
|
||||
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, vr.weaponangles_knife);
|
||||
rotation[PITCH] = 45;
|
||||
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, vr.weaponangles_saber);
|
||||
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
||||
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, vr.weaponangles);
|
||||
|
||||
|
@ -228,16 +228,17 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
vr.weaponoffset[2] = pWeapon->HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
vr.weaponoffset_timestamp = Sys_Milliseconds( );
|
||||
|
||||
vr.swingvelocity = sqrtf(powf(pWeapon->HeadPose.LinearVelocity.x, 2) +
|
||||
powf(pWeapon->HeadPose.LinearVelocity.y, 2) +
|
||||
powf(pWeapon->HeadPose.LinearVelocity.z, 2));
|
||||
|
||||
|
||||
//Does weapon velocity trigger attack (knife) and is it fast enough
|
||||
static bool velocityTriggeredAttack = false;
|
||||
if (vr.velocitytriggered)
|
||||
{
|
||||
static bool fired = qfalse;
|
||||
float velocity = sqrtf(powf(pWeapon->HeadPose.LinearVelocity.x, 2) +
|
||||
powf(pWeapon->HeadPose.LinearVelocity.y, 2) +
|
||||
powf(pWeapon->HeadPose.LinearVelocity.z, 2));
|
||||
|
||||
velocityTriggeredAttack = (velocity > VELOCITY_TRIGGER);
|
||||
velocityTriggeredAttack = (vr.swingvelocity > VELOCITY_TRIGGER);
|
||||
|
||||
if (fired != velocityTriggeredAttack) {
|
||||
ALOGV("**WEAPON EVENT** veocity triggered %s", velocityTriggeredAttack ? "+attack" : "-attack");
|
||||
|
|
|
@ -49,7 +49,7 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
|
|||
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
|
||||
vec3_t rotation = {0};
|
||||
rotation[PITCH] = 10;
|
||||
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles_knife);
|
||||
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles_saber);
|
||||
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
||||
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles);
|
||||
|
||||
|
|
|
@ -624,6 +624,7 @@ extern vmCvar_t cg_thirdPersonPitchOffset;
|
|||
extern vmCvar_t cg_thirdPersonVertOffset;
|
||||
extern vmCvar_t cg_thirdPersonCameraDamp;
|
||||
extern vmCvar_t cg_thirdPersonTargetDamp;
|
||||
extern vmCvar_t cg_saberAutoThird;
|
||||
extern vmCvar_t cg_gunAutoFirst;
|
||||
|
||||
extern vmCvar_t cg_stereoSeparation;
|
||||
|
|
|
@ -305,6 +305,7 @@ vmCvar_t cg_thirdPersonPitchOffset;
|
|||
vmCvar_t cg_thirdPersonVertOffset;
|
||||
vmCvar_t cg_thirdPersonCameraDamp;
|
||||
vmCvar_t cg_thirdPersonTargetDamp;
|
||||
vmCvar_t cg_saberAutoThird;
|
||||
vmCvar_t cg_gunAutoFirst;
|
||||
|
||||
vmCvar_t cg_thirdPersonAlpha;
|
||||
|
@ -453,6 +454,7 @@ static cvarTable_t cvarTable[] = {
|
|||
{ &cg_thirdPersonAlpha, "cg_thirdPersonAlpha", "1.0", CVAR_ARCHIVE },
|
||||
{ &cg_thirdPersonAutoAlpha, "cg_thirdPersonAutoAlpha", "0", 0 },
|
||||
// NOTE: also declare this in UI_Init
|
||||
{ &cg_saberAutoThird, "cg_saberAutoThird", "1", CVAR_ARCHIVE },
|
||||
{ &cg_gunAutoFirst, "cg_gunAutoFirst", "1", CVAR_ARCHIVE },
|
||||
|
||||
{ &cg_pano, "pano", "0", 0 },
|
||||
|
|
|
@ -5841,8 +5841,8 @@ static void CG_DoSaber( vec3_t origin, vec3_t dir, float length, float lengthMax
|
|||
cgi_R_AddRefEntityToScene( &saber );
|
||||
}
|
||||
|
||||
#define MAX_MARK_FRAGMENTS 128
|
||||
#define MAX_MARK_POINTS 384
|
||||
#define MAX_MARK_FRAGMENTS 256
|
||||
#define MAX_MARK_POINTS 768
|
||||
extern markPoly_t *CG_AllocMark();
|
||||
|
||||
static void CG_CreateSaberMarks( vec3_t start, vec3_t end, vec3_t normal )
|
||||
|
|
|
@ -2107,7 +2107,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
|
|||
|| (cg.snap->ps.eFlags&EF_HELD_BY_SAND_CREATURE)
|
||||
|| (
|
||||
(g_entities[0].client&&g_entities[0].client->NPC_class==CLASS_ATST)
|
||||
|| (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE)
|
||||
// || (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ void PM_StepSlideMove( float gravity );
|
|||
|
||||
void rotateAboutOrigin(float x, float y, float rotation, vec2_t out);
|
||||
void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles );
|
||||
void BG_CalculateVRSaberPosition( vec3_t origin, vec3_t angles );
|
||||
void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles );
|
||||
void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out);
|
||||
|
||||
|
|
|
@ -756,6 +756,11 @@ void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles )
|
|||
BG_CalculateVRPositionInWorld(vr->weaponposition, vr->weaponoffset, vr->weaponangles, origin, angles);
|
||||
}
|
||||
|
||||
void BG_CalculateVRSaberPosition( vec3_t origin, vec3_t angles )
|
||||
{
|
||||
BG_CalculateVRPositionInWorld(vr->weaponposition, vr->weaponoffset, vr->weaponangles_saber, origin, angles);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
BG_PlayerTouchesItem
|
||||
|
|
|
@ -9034,9 +9034,9 @@ static void PM_FinishWeaponChange( void ) {
|
|||
if ( pm->gent )
|
||||
{
|
||||
WP_SaberInitBladeData( pm->gent );
|
||||
if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) )
|
||||
if ( (pm->ps->clientNum < MAX_CLIENTS||PM_ControlledByPlayer()) && cg_saberAutoThird.integer )
|
||||
{
|
||||
//gi.cvar_set( "cg_thirdperson", "1" );
|
||||
gi.cvar_set( "cg_thirdperson", "1" );
|
||||
}
|
||||
}
|
||||
if ( trueSwitch )
|
||||
|
|
|
@ -1041,7 +1041,7 @@ extern void CG_ChangeWeapon( int num );
|
|||
|
||||
if ( ent->s.number < MAX_CLIENTS )
|
||||
{
|
||||
if ( ent->client->ps.weapon == WP_SABER )
|
||||
if ( ent->client->ps.weapon == WP_SABER && cg_saberAutoThird.value )
|
||||
{
|
||||
gi.cvar_set( "cg_thirdperson", "1" );
|
||||
}
|
||||
|
|
|
@ -660,7 +660,7 @@ void G_InitCvars( void ) {
|
|||
com_buildScript = gi.cvar ("com_buildscript", "0", 0);
|
||||
|
||||
g_saberAutoBlocking = gi.cvar( "g_saberAutoBlocking", "1", CVAR_CHEAT );//must press +block button to do any blocking
|
||||
g_saberRealisticCombat = gi.cvar( "g_saberMoreRealistic", "0", CVAR_ARCHIVE );//makes collision more precise, increases damage
|
||||
g_saberRealisticCombat = gi.cvar( "g_saberMoreRealistic", "1", CVAR_ARCHIVE );//makes collision more precise, increases damage
|
||||
debug_subdivision = gi.cvar( "debug_subdivision", "0", CVAR_ARCHIVE );//debug for dismemberment
|
||||
g_dismemberProbabilities = gi.cvar ( "g_dismemberProbabilities", "1", CVAR_ARCHIVE );//0 = ignore probabilities, 1 = use probabilities
|
||||
g_saberDamageCapping = gi.cvar( "g_saberDamageCapping", "1", CVAR_CHEAT );//caps damage of sabers vs players and NPC who use sabers
|
||||
|
|
|
@ -294,6 +294,7 @@ void UI_Init( int apiVersion, uiimport_t *uiimport, qboolean inGameLoad )
|
|||
ui.Cvar_Create( "ui_prisonerobj_mintotal", "0", CVAR_ROM|CVAR_SAVEGAME|CVAR_NORESTART);
|
||||
|
||||
ui.Cvar_Create( "g_dismemberment", "3", CVAR_ARCHIVE );//0 = none, 1 = arms and hands, 2 = legs, 3 = waist and head
|
||||
ui.Cvar_Create( "cg_saberAutoThird", "0", CVAR_ARCHIVE );
|
||||
ui.Cvar_Create( "cg_gunAutoFirst", "1", CVAR_ARCHIVE );
|
||||
ui.Cvar_Create( "cg_crosshairIdentifyTarget", "1", CVAR_ARCHIVE );
|
||||
ui.Cvar_Create( "g_subtitles", "0", CVAR_ARCHIVE );
|
||||
|
|
|
@ -31,6 +31,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
#include "../game/anims.h"
|
||||
#include "../game/wp_saber.h"
|
||||
#include "bg_local.h"
|
||||
#include <JKVR/VrClientInfo.h>
|
||||
|
||||
#define LOOK_SWING_SCALE 0.5
|
||||
|
||||
|
@ -49,6 +50,7 @@ qboolean CG_RegisterClientModelname( clientInfo_t *ci, const char *headModelName
|
|||
const char *legsModelName, const char *legsSkinName );
|
||||
|
||||
void CG_PlayerAnimSounds( int animFileIndex, qboolean torso, int oldFrame, int frame, int entNum );
|
||||
extern void G_SoundOnEnt( gentity_t *ent, soundChannel_t channel, const char *soundPath );
|
||||
extern void BG_G2SetBoneAngles( centity_t *cent, gentity_t *gent, int boneIndex, const vec3_t angles, const int flags,
|
||||
const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList );
|
||||
extern void FX_BorgDeathSparkParticles( vec3_t origin, vec3_t angles, vec3_t vel, vec3_t user );
|
||||
|
@ -3426,8 +3428,34 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
|
|||
!gent->client->ps.powerups[PW_UNCLOAKING] &&
|
||||
!gent->client->ps.powerups[PW_DISRUPTION] )
|
||||
{
|
||||
//SB: Never render any player model if 1st person
|
||||
if (cent->gent->NPC || cg.renderingThirdPerson ||
|
||||
cent->gent->client->ps.weapon != WP_SABER) {
|
||||
cgi_R_AddRefEntityToScene(ent);
|
||||
}
|
||||
else if (!cg.renderingThirdPerson && cent->gent->client->ps.weapon == WP_SABER)
|
||||
{
|
||||
//#ifdef JK2_MODE
|
||||
refEntity_t hiltEnt;
|
||||
memset( &hiltEnt, 0, sizeof(refEntity_t) );
|
||||
hiltEnt.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON;
|
||||
hiltEnt.hModel = cgi_R_RegisterModel( "models/weapons2/saber/saber_w.md3" );
|
||||
vec3_t angles;
|
||||
BG_CalculateVRSaberPosition(hiltEnt.origin, hiltEnt.angles);
|
||||
vec3_t axis[3];
|
||||
AnglesToAxis(hiltEnt.angles, axis);
|
||||
VectorSubtract(vec3_origin, axis[2], hiltEnt.axis[0]);
|
||||
VectorCopy(axis[1], hiltEnt.axis[1]);
|
||||
VectorCopy(axis[0], hiltEnt.axis[2]);
|
||||
cgi_R_AddRefEntityToScene(&hiltEnt);
|
||||
if (vr->swingvelocity > 1.2f)
|
||||
{
|
||||
G_SoundOnEnt( cent->gent, CHAN_WEAPON, va( "sound/weapons/saber/saberhup%d.wav", Q_irand( 1, 9 ) ) );
|
||||
}
|
||||
//#else
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Disruptor Gun Alt-fire
|
||||
if ( gent->client->ps.powerups[PW_DISRUPTION] )
|
||||
|
@ -4281,8 +4309,8 @@ void CG_DoSaber( vec3_t origin, vec3_t dir, float length, float lengthMax, saber
|
|||
cgi_R_AddRefEntityToScene( &saber );
|
||||
}
|
||||
|
||||
#define MAX_MARK_FRAGMENTS 128
|
||||
#define MAX_MARK_POINTS 384
|
||||
#define MAX_MARK_FRAGMENTS 256
|
||||
#define MAX_MARK_POINTS 768
|
||||
extern markPoly_t *CG_AllocMark();
|
||||
|
||||
void CG_CreateSaberMarks( vec3_t start, vec3_t end, vec3_t normal )
|
||||
|
@ -4438,6 +4466,13 @@ Ghoul2 Insert Start
|
|||
// work the matrix axis stuff into the original axis and origins used.
|
||||
gi.G2API_GiveMeVectorFromMatrix(boltMatrix, ORIGIN, org_);
|
||||
gi.G2API_GiveMeVectorFromMatrix(boltMatrix, NEGATIVE_X, axis_[0]);//was NEGATIVE_Y, but the md3->glm exporter screws up this tag somethin' awful
|
||||
if (!cg.renderingThirdPerson && !cent->gent->client->ps.saberInFlight)
|
||||
{
|
||||
vec3_t angles;
|
||||
BG_CalculateVRSaberPosition(org_, angles);
|
||||
AnglesToAxis(angles, axis_);
|
||||
VectorMA(org_, 4.0f, axis_[0], org_);
|
||||
}
|
||||
|
||||
//Now figure out where this info will be next frame
|
||||
/*
|
||||
|
@ -5147,6 +5182,13 @@ extern vmCvar_t cg_thirdPersonAlpha;
|
|||
{
|
||||
VectorCopy( ent.origin, cent->gent->client->renderInfo.muzzlePoint );
|
||||
VectorCopy( ent.axis[0], cent->gent->client->renderInfo.muzzleDir );
|
||||
|
||||
if ( !cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE))
|
||||
{
|
||||
vec3_t angles;
|
||||
BG_CalculateVRSaberPosition(cent->gent->client->renderInfo.muzzlePoint, angles);
|
||||
AngleVectors( angles, cent->gent->client->renderInfo.muzzleDir, NULL, NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
//now try to get the right data
|
||||
|
@ -5161,6 +5203,11 @@ extern vmCvar_t cg_thirdPersonAlpha;
|
|||
&boltMatrix, G2Angles, ent.origin, cg.time,
|
||||
cgs.model_draw, cent->currentState.modelScale );
|
||||
gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.handRPoint );
|
||||
if (!cg.renderingThirdPerson && !cent->gent->client->ps.saberInFlight)
|
||||
{
|
||||
vec3_t angles;
|
||||
BG_CalculateVRSaberPosition(cent->gent->client->renderInfo.handRPoint, angles);
|
||||
}
|
||||
}
|
||||
if ( cent->gent->handLBolt != -1 )
|
||||
{
|
||||
|
@ -5169,6 +5216,11 @@ extern vmCvar_t cg_thirdPersonAlpha;
|
|||
&boltMatrix, G2Angles, ent.origin, cg.time,
|
||||
cgs.model_draw, cent->currentState.modelScale );
|
||||
gi.G2API_GiveMeVectorFromMatrix( boltMatrix, ORIGIN, cent->gent->client->renderInfo.handLPoint );
|
||||
if (!cg.renderingThirdPerson && !cent->gent->client->ps.saberInFlight)
|
||||
{
|
||||
vec3_t angles;
|
||||
BG_CalculateVROffHandPosition(cent->gent->client->renderInfo.handLPoint, angles);
|
||||
}
|
||||
}
|
||||
if ( cent->gent->footLBolt != -1 )
|
||||
{
|
||||
|
|
|
@ -80,6 +80,7 @@ void PM_StepSlideMove( float gravity );
|
|||
|
||||
void rotateAboutOrigin(float x, float y, float rotation, vec2_t out);
|
||||
void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles );
|
||||
void BG_CalculateVRSaberPosition( vec3_t origin, vec3_t angles );
|
||||
void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles );
|
||||
void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out);
|
||||
|
||||
|
|
|
@ -697,6 +697,11 @@ void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles )
|
|||
BG_CalculateVRPositionInWorld(vr->weaponposition, vr->weaponoffset, vr->weaponangles, origin, angles);
|
||||
}
|
||||
|
||||
void BG_CalculateVRSaberPosition( vec3_t origin, vec3_t angles )
|
||||
{
|
||||
BG_CalculateVRPositionInWorld(vr->weaponposition, vr->weaponoffset, vr->weaponangles_saber, origin, angles);
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
BG_PlayerTouchesItem
|
||||
|
|
|
@ -584,7 +584,7 @@ void G_InitCvars( void ) {
|
|||
com_buildScript = gi.cvar ("com_buildscript", "0", 0);
|
||||
|
||||
g_saberAutoBlocking = gi.cvar( "g_saberAutoBlocking", "1", CVAR_ARCHIVE|CVAR_CHEAT );//must press +block button to do any blocking
|
||||
g_saberRealisticCombat = gi.cvar( "g_saberRealisticCombat", "0", CVAR_ARCHIVE );//makes collision more precise, increases damage
|
||||
g_saberRealisticCombat = gi.cvar( "g_saberRealisticCombat", "1", CVAR_ARCHIVE );//makes collision more precise, increases damage
|
||||
g_saberMoveSpeed = gi.cvar( "g_saberMoveSpeed", "1", CVAR_ARCHIVE|CVAR_CHEAT );//how fast you run while attacking with a saber
|
||||
g_saberAnimSpeed = gi.cvar( "g_saberAnimSpeed", "1", CVAR_ARCHIVE|CVAR_CHEAT );//how fast saber animations run
|
||||
g_saberAutoAim = gi.cvar( "g_saberAutoAim", "1", CVAR_ARCHIVE|CVAR_CHEAT );//auto-aims at enemies when not moving or when just running forward
|
||||
|
|
Loading…
Reference in a new issue