Lots of changes to get vehicles/animals working nicely

also fixed some of the 3rd person 6DoF movement
ensure force speed briefly affects FOV
This commit is contained in:
Simon 2023-05-14 22:50:24 +01:00
parent 7faa7755dd
commit 26487d6233
16 changed files with 185 additions and 28 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.jkxr"
android:versionCode="57"
android:versionName="1.1.5" android:installLocation="auto" >
android:versionCode="58"
android:versionName="1.1.6" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030002" android:required="true"/>

View file

@ -18,10 +18,17 @@ extern "C" {
}
#include <client/client.h>
#include <weapons.h>
#include <client_ui.h>
#ifdef JK2_MODE
#include "../OpenJK/codeJK2/game/weapons.h"
#else
#include "../OpenJK/code/game/weapons.h"
#include "../OpenJK/code/game/g_vehicles.h"
#endif
//#define ENABLE_GL_DEBUG
#define ENABLE_GL_DEBUG_VERBOSE 1
@ -146,7 +153,12 @@ void VR_SetHMDOrientation(float pitch, float yaw, float roll)
//Keep this for our records
VectorCopy(vr.hmdorientation, vr.hmdorientation_last);
if (!vr.third_person && !vr.remote_npc && !vr.remote_turret){
if (!vr.third_person && !vr.remote_npc && !vr.remote_turret
#ifndef JK2_MODE
&& !vr.in_vehicle
#endif
)
{
VectorCopy(vr.hmdorientation, vr.hmdorientation_first);
}
@ -242,6 +254,35 @@ void VR_GetMove(float *forward, float *side, float *pos_forward, float *pos_side
*pitch = vr.hmdorientation[PITCH];
*roll = 0.0f;
}
#ifndef JK2_MODE
//Special code for JKA's vehicles
else if (vr.in_vehicle) {
//in vehicle
*forward = remote_movementForward;
*pos_forward = 0.0f;
*up = 0.0f;
*side = remote_movementSideways;
*pos_side = 0.0f;
if (vr_vehicle_use_hmd_direction->integer)
{
*yaw = vr.hmdorientation[YAW] + vr.snapTurn;
*pitch = vr.hmdorientation[PITCH];
}
else
{
*yaw = vr.snapTurn + vr.hmdorientation_first[YAW];
if (vr.vehicle_type == VH_FIGHTER || vr.vehicle_type == VH_FLIER)
{
*pitch = (vr.weaponangles[ANGLES_ADJUSTED][PITCH] + vr.offhandangles[ANGLES_ADJUSTED][PITCH]) / 2.0f;
}
else
{
*pitch = 0.0f;
}
}
*roll = 0.0f;
}
#endif
else if (!vr.third_person) {
*forward = remote_movementForward;
*pos_forward = positional_movementForward;
@ -309,6 +350,9 @@ void VR_Init()
vr_haptic_intensity = Cvar_Get ("vr_haptic_intensity", "1.0", CVAR_ARCHIVE);
vr_comfort_vignette = Cvar_Get ("vr_comfort_vignette", "0.0", CVAR_ARCHIVE);
vr_saber_3rdperson_mode = Cvar_Get ("vr_saber_3rdperson_mode", "1", CVAR_ARCHIVE);
vr_vehicle_use_hmd_direction = Cvar_Get ("vr_vehicle_use_hmd_direction", "0", CVAR_ARCHIVE);
vr_vehicle_use_3rd_person = Cvar_Get ("vr_vehicle_use_3rd_person", "0", CVAR_ARCHIVE);
vr_vehicle_use_controller_for_speed = Cvar_Get ("vr_vehicle_use_controller_for_speed", "1", CVAR_ARCHIVE);
vr_gesture_triggered_use = Cvar_Get ("vr_gesture_triggered_use", "1", CVAR_ARCHIVE);
vr_use_gesture_boundary = Cvar_Get ("vr_use_gesture_boundary", "0.35", CVAR_ARCHIVE);
vr_align_weapons = Cvar_Get ("vr_align_weapons", "0", CVAR_ARCHIVE);

View file

@ -28,6 +28,7 @@ typedef struct {
bool remote_droid; // controlling a remote droid
bool remote_npc; // controlling a remote NPC (will also be true when controlling a droid)
bool in_vehicle; // controlling a vehicle
int vehicle_type;
vec3_t remote_angles; // The view angles of the remote thing we are controlling
float remote_snapTurn; // how much turn has been applied to the yaw by joystick for a remote controlled entity
int remote_cooldown;

View file

@ -20,6 +20,9 @@ extern cvar_t *vr_saber_block_debounce_time;
extern cvar_t *vr_haptic_intensity;
extern cvar_t *vr_comfort_vignette;
extern cvar_t *vr_saber_3rdperson_mode;
extern cvar_t *vr_vehicle_use_hmd_direction;
extern cvar_t *vr_vehicle_use_3rd_person;
extern cvar_t *vr_vehicle_use_controller_for_speed;
extern cvar_t *vr_gesture_triggered_use;
extern cvar_t *vr_use_gesture_boundary;
extern cvar_t *vr_align_weapons; // Only used for development

View file

@ -33,6 +33,9 @@ cvar_t *vr_saber_block_debounce_time;
cvar_t *vr_haptic_intensity;
cvar_t *vr_comfort_vignette;
cvar_t *vr_saber_3rdperson_mode;
cvar_t *vr_vehicle_use_hmd_direction;
cvar_t *vr_vehicle_use_3rd_person;
cvar_t *vr_vehicle_use_controller_for_speed;
cvar_t *vr_gesture_triggered_use;
cvar_t *vr_use_gesture_boundary;
cvar_t *vr_align_weapons;

View file

@ -23,6 +23,7 @@ Authors : Simon Brown
#include "../OpenJK/codeJK2/game/weapons.h"
#else
#include "../OpenJK/code/game/weapons.h"
#include "../OpenJK/code/game/g_vehicles.h"
#endif
void SV_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask, int capsule );
@ -851,10 +852,46 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
}
//JKA stuff for speeder bikes (and other vehicles)
#ifndef JK2_MODE
if (vr.in_vehicle)
{
//Allow the controllers to affect the yaw rotation of the vehicle
if (!vr_vehicle_use_hmd_direction->integer)
{
float refresh = TBXR_GetRefresh();
float weaponAngleToUse = cl.frame.ps.weapon == WP_SABER ? vr.offhandangles[ANGLES_ADJUSTED][ROLL] : vr.weaponangles[ANGLES_ADJUSTED][ROLL];
float yawAdjust = (weaponAngleToUse + vr.offhandangles[ANGLES_ADJUSTED][ROLL]) / refresh;
vr.snapTurn -= yawAdjust;
}
//Only use controller angle for forwards on the following types of vehicle
if (vr_vehicle_use_controller_for_speed->integer && (
vr.vehicle_type == VH_SPEEDER || vr.vehicle_type == VH_ANIMAL))
{
float weaponAngleToUse = cl.frame.ps.weapon == WP_SABER ? vr.offhandangles[ANGLES_ADJUSTED][PITCH] : vr.weaponangles[ANGLES_ADJUSTED][PITCH];
float value = ((weaponAngleToUse + vr.offhandangles[ANGLES_ADJUSTED][PITCH]) / 2.0f) / 30.0f;
if (fabs(value) < 0.3f)
value = 0.0f;
remote_movementForward = Com_Clamp(-1.0f, 1.0f, value);
}
if (vr_vehicle_use_3rd_person->integer)
{
sendButtonActionSimple("cg_thirdPerson 1");
}
else
{
sendButtonActionSimple("cg_thirdPerson 0");
}
}
#endif
//Use smooth in 3rd person
bool usingSnapTurn = vr_turn_mode->integer == 0 ||
(!vr.third_person && vr_turn_mode->integer == 1);
float previousSnap = vr.snapTurn;
static int increaseSnap = true;
if (!vr.item_selector) {
if (usingSnapTurn) {
@ -902,6 +939,12 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
increaseSnap = true;
}
}
//If we snapped/turned on a vehicle then resync the hmdorientation
if (previousSnap != vr.snapTurn && vr.in_vehicle)
{
VectorCopy(vr.hmdorientation, vr.hmdorientation_first);
}
}
//process force motion controls here

View file

@ -16,7 +16,7 @@ Authors : Simon Brown
cvar_t *sv_cheats;
void CG_CenterPrint( const char *str, int y, int charWidth );
void CG_CenterPrint( const char *str, int y, int charWidth, int delayOverride );
void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTrackedController* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTrackedController* pOffTracking,

View file

@ -2984,7 +2984,7 @@ static void CG_DrawCrosshair3D(int type) // 0 - force, 1 - weapons
return;
}
if ( in_camera ) {
if ( in_camera || vr->in_vehicle) {
return;
}
@ -4208,6 +4208,20 @@ static void CG_Draw2D( void )
CGCam_DrawWideScreen();
}
static bool was_in_vehicle = false;
if (!was_in_vehicle && vr->in_vehicle)
{
if (vr->vehicle_type == VH_WALKER)
{
CG_CenterPrint("Tilt controllers to steer. Thumbstick to move.", 240, 5000);
}
else
{
CG_CenterPrint("Tilt controllers to steer/move", 240, 5000);
}
}
was_in_vehicle = vr->in_vehicle;
if (cg.zoomMode == 4)
{
CG_DrawWeapReticle();
@ -4571,7 +4585,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
}
//Immersive cinematic sequence 6DoF
if ((in_camera && vr->immersive_cinematics) || vr->emplaced_gun || cg.renderingThirdPerson)
if ((in_camera && vr->immersive_cinematics) || vr->emplaced_gun || cg.renderingThirdPerson || vr->in_vehicle)
{
BG_ConvertFromVR(vr->hmdposition_offset, cg.refdef.vieworg, cg.refdef.vieworg);
}

View file

@ -400,6 +400,7 @@ typedef struct {
// centerprinting
int centerPrintTime;
int centerPrintDelayOverride;
int centerPrintY;
char centerPrint[1024];
int centerPrintLines;
@ -810,7 +811,7 @@ void CG_AdjustFrom640Int( int *x, int *y, int *w, int *h );
//
// cg_draw.c
//
void CG_CenterPrint( const char *str, int y );
void CG_CenterPrint( const char *str, int y, int delayOverride = -1 );
void CG_DrawActive( stereoFrame_t stereoView );
void CG_ScrollText( const char *str, int iPixelWidth );
void CG_CaptionText( const char *str, int sound );

View file

@ -682,7 +682,7 @@ Called for important messages that should stay in the center of the screen
for a few moments
==============
*/
void CG_CenterPrint( const char *str, int y) {
void CG_CenterPrint( const char *str, int y, int delayOverride) {
char *s;
// Find text to match the str given
@ -704,6 +704,7 @@ void CG_CenterPrint( const char *str, int y) {
}
cg.centerPrintTime = cg.time;
cg.centerPrintDelayOverride = delayOverride;
cg.centerPrintY = y;
// count the number of lines for centering
@ -734,7 +735,10 @@ void CG_DrawCenterString( void )
return;
}
color = CG_FadeColor( cg.centerPrintTime, 1000 * 2 );
//Default time is 2 seconds
int printTime = cg.centerPrintDelayOverride == -1 ? 2000 : cg.centerPrintDelayOverride;
color = CG_FadeColor( cg.centerPrintTime, printTime );
if ( !color ) {
return;
}

View file

@ -2153,7 +2153,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
CGCam_UpdateFade();
// build cg.refdef
inwater = CG_CalcViewValues();
cg.refdef.override_fov = inwater;
cg.refdef.override_fov |= inwater;
}
if (cg.zoomMode)
@ -2173,9 +2173,15 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
//Calculate all angles upfront
{
//Only vehicle in JK2 is the AT-ST
vr->in_vehicle = (g_entities[0].client &&
g_entities[0].client->NPC_class == CLASS_ATST);
(g_entities[0].client->NPC_class == CLASS_VEHICLE || g_entities[0].client->NPC_class == CLASS_ATST ||
g_entities[0].s.m_iVehicleNum != 0 ));
vr->vehicle_type = VH_NONE;
if (vr->in_vehicle)
{
vr->vehicle_type = (int)g_entities[g_entities[0].s.m_iVehicleNum].m_pVehicle->m_pVehicleInfo->type;
}
vr->remote_npc = !Q_stricmp( "NPC", g_entities[cg.snap->ps.viewEntity].classname );
vr->remote_droid = false;
vr->remote_turret = false;
@ -2216,6 +2222,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
!in_misccamera &&
!vr->remote_droid &&
!vr->remote_npc &&
!vr->in_vehicle &&
!usingScope &&
!cg.renderingThirdPerson)
{
@ -2252,7 +2259,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
//Normal 3rd person view angles
if (!in_camera &&
!in_misccamera &&
cg.renderingThirdPerson)
(vr->in_vehicle || cg.renderingThirdPerson))
{
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
cg.refdef.viewangles[YAW] = vr->clientviewangles[YAW] +
@ -2356,7 +2363,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
&& !(g_entities[cg.snap->ps.viewEntity].client->ps.dualSabers && cg.snap->ps.weapon == WP_SABER)
&& cg.snap->ps.weapon != WP_MELEE
&& !vr->weapon_stabilised
&& !vr->in_vehicle
&& (vr->vehicle_type != VH_WALKER)
&& !cg_pano.integer
&& (cg.snap->ps.viewEntity == 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD))
{
@ -2376,7 +2383,8 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
(cg.snap->ps.forcePowersActive & (1<<FP_GRIP)) ||
(cg.snap->ps.forcePowersActive & (1<<FP_LIGHTNING)) ||
(cg.snap->ps.forcePowersActive & (1<<FP_ABSORB)) ||
(cg.snap->ps.forcePowersActive & (1<<FP_DRAIN)))
(cg.snap->ps.forcePowersActive & (1<<FP_DRAIN)) ||
(cg.snap->ps.forcePowersActive & (1<<FP_RAGE)))
{
handEnt.hModel = cgs.media.handModel_force;
}

View file

@ -2885,6 +2885,16 @@ void CG_ItemSelectorSelect_f( void )
}
if (cg.itemSelectorType == ST_WEAPON) // weapons
{
centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
if (vr->in_vehicle
&& vr->vehicle_type != VH_WALKER
&& cent->currentState.weapon == WP_SABER)
{
//If holding saber, put it away
CG_NextWeapon_f();
}
else
{
if (cg.weaponSelect == cg.itemSelectorSelection)
{
@ -2894,6 +2904,7 @@ void CG_ItemSelectorSelect_f( void )
cg.weaponSelectTime = cg.time;
cg.weaponSelect = cg.itemSelectorSelection;
}
}
else if (cg.itemSelectorType == ST_GADGET) // gadgets
{
cg.inventorySelectTime = cg.time;
@ -3019,6 +3030,11 @@ void CG_DrawItemSelector( void )
VectorSubtract(vr->weaponposition, cg.itemSelectorOrigin, controllerOffset);
}
if (vr->in_vehicle)
{
BG_ConvertFromVR(vr->hmdposition_offset, controllerOrigin, controllerOrigin);
}
vec3_t wheelAngles, wheelOrigin, beamOrigin, wheelForward, wheelRight, wheelUp;
vec3_t angles;
VectorClear(angles);
@ -3058,7 +3074,7 @@ void CG_DrawItemSelector( void )
{
case ST_WEAPON: //weapons
if (vr->in_vehicle)
count = 2;
count = vr->vehicle_type == VH_WALKER ? 2 : 1;
else
count = WP_MELEE;
beam.shaderRGBA[0] = 0xff;
@ -3177,10 +3193,18 @@ void CG_DrawItemSelector( void )
int itemId = index;
if (cg.itemSelectorType == ST_WEAPON) {
if (vr->in_vehicle)
{
if (vr->vehicle_type == VH_WALKER)
{
itemId = WP_ATST_MAIN + index;
}
else
{
//Only choice on a speeder/animal is the saber
itemId = WP_SABER;
}
}
else
{
itemId = index + 1; // We need to ignore WP_NONE for weapons
if (itemId == count)
@ -3197,7 +3221,7 @@ void CG_DrawItemSelector( void )
switch (cg.itemSelectorType)
{
case ST_WEAPON: //weapons
selectable = vr->in_vehicle || // both ATST weapons are always selectable
selectable = vr->in_vehicle ||
(CG_WeaponSelectable(itemId, cg.weaponSelect, qfalse) && cg.snap->ps.ammo[weaponData[itemId].ammoIndex]);
break;
case ST_GADGET: //gadgets

View file

@ -716,9 +716,15 @@ void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
float getHMDYawForCalc()
{
if (!vr->third_person && vr->cgzoommode != 2 && vr->cgzoommode != 4 ) {
if (vr->in_vehicle || vr->third_person)
{
return vr->hmdorientation_first[YAW];
}
if (vr->cgzoommode != 2 && vr->cgzoommode != 4) {
return vr->hmdorientation[YAW];
}
return 0.0f;
}
@ -790,6 +796,11 @@ void BG_CalculateVRSaberPosition( int saberNum, vec3_t origin, vec3_t angles )
BG_CalculateVRPositionInWorld(vr->offhandposition[0], vr->offhandoffset, vr->offhandangles[ANGLES_SABER], origin, angles);
}
if (vr->in_vehicle)
{
BG_ConvertFromVR(vr->hmdposition_offset, origin, origin);
}
//Move position down a bit
vec3_t axis[3];
AnglesToAxis(angles, axis);

View file

@ -5364,9 +5364,10 @@ extern cvar_t *g_skippingcin;
{
// Vehicle Camera Overrides
//--------------------------
cg.overrides.active |= ( CG_OVERRIDE_3RD_PERSON_RNG | CG_OVERRIDE_FOV | CG_OVERRIDE_3RD_PERSON_VOF | CG_OVERRIDE_3RD_PERSON_POF );
// in VR - Vehicles mustn't affect FOV
cg.overrides.active |= ( CG_OVERRIDE_3RD_PERSON_RNG | /*CG_OVERRIDE_FOV |*/ CG_OVERRIDE_3RD_PERSON_VOF | CG_OVERRIDE_3RD_PERSON_POF );
cg.overrides.thirdPersonRange = pPlayerVeh->m_pVehicleInfo->cameraRange;
cg.overrides.fov = pPlayerVeh->m_pVehicleInfo->cameraFOV;
//cg.overrides.fov = pPlayerVeh->m_pVehicleInfo->cameraFOV;
cg.overrides.thirdPersonVertOffset = pPlayerVeh->m_pVehicleInfo->cameraVertOffset;
cg.overrides.thirdPersonPitchOffset = pPlayerVeh->m_pVehicleInfo->cameraPitchOffset;

View file

@ -12944,7 +12944,7 @@ void WP_ForcePowerStart( gentity_t *self, forcePowers_t forcePower, int override
}
}
void CG_CenterPrint( const char *str, int y );
void CG_CenterPrint( const char *str, int y, int delayOverride);
qboolean WP_ForcePowerAvailable( gentity_t *self, forcePowers_t forcePower, int overrideAmt )
{
if ( forcePower == FP_LEVITATION )

View file

@ -23,7 +23,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
// Current version of the single player game
#include "../win32/AutoVersion.h"
#define JKXR_VERSION "1.1.5-ea"
#define JKXR_VERSION "1.1.6-ea"
#ifdef _DEBUG
#define Q3_VERSION "(debug)OpenJK: v" VERSION_STRING_DOTTED " JKXR: " JKXR_VERSION