From 7cc4c4f2811b4bba9d077af7cc12b353afc6e86e Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 28 Sep 2022 23:07:22 +0100 Subject: [PATCH] Several changes - Jedi Outcast now running properly - Added Use to right thumbstick to bypass cutscenes --- Projects/Android/jni/JKVR/VrClientInfo.h | 4 + Projects/Android/jni/JKVR/VrCommon.h | 1 - Projects/Android/jni/JKVR/VrInputDefault.cpp | 7 + .../Android/jni/OpenJK/Android_client_ja.mk | 2 +- .../Android/jni/OpenJK/Android_client_jo.mk | 2 +- Projects/Android/jni/OpenJK/Android_gles.mk | 2 +- .../jni/OpenJK/code/cgame/cg_camera.cpp | 2 - .../Android/jni/OpenJK/code/cgame/cg_draw.cpp | 4 +- .../jni/OpenJK/code/cgame/cg_drawtools.cpp | 2 - .../jni/OpenJK/code/cgame/cg_event.cpp | 4 +- .../Android/jni/OpenJK/code/cgame/cg_main.cpp | 42 +++++- .../Android/jni/OpenJK/code/cgame/cg_public.h | 1 + .../Android/jni/OpenJK/code/cgame/cg_view.cpp | 2 - .../jni/OpenJK/code/cgame/cg_weapons.cpp | 2 - .../jni/OpenJK/code/client/cl_cgame.cpp | 4 + .../jni/OpenJK/code/client/cl_main.cpp | 1 + .../Android/jni/OpenJK/code/game/bg_misc.cpp | 2 - .../jni/OpenJK/code/rd-vanilla/tr_model.cpp | 2 - .../jni/OpenJK/code/rd-vanilla/tr_scene.cpp | 2 - .../jni/OpenJK/codeJK2/cgame/cg_camera.cpp | 12 +- .../jni/OpenJK/codeJK2/cgame/cg_draw.cpp | 21 ++- .../jni/OpenJK/codeJK2/cgame/cg_drawtools.cpp | 128 ++++++++++++++++-- .../jni/OpenJK/codeJK2/cgame/cg_event.cpp | 4 +- .../jni/OpenJK/codeJK2/cgame/cg_local.h | 23 ++++ .../jni/OpenJK/codeJK2/cgame/cg_main.cpp | 17 ++- .../jni/OpenJK/codeJK2/cgame/cg_marks.cpp | 8 +- .../jni/OpenJK/codeJK2/cgame/cg_players.cpp | 10 +- .../jni/OpenJK/codeJK2/cgame/cg_public.h | 1 + .../jni/OpenJK/codeJK2/cgame/cg_syscalls.cpp | 4 + .../jni/OpenJK/codeJK2/cgame/cg_view.cpp | 24 +++- .../jni/OpenJK/codeJK2/cgame/cg_weapons.cpp | 118 +++++++++++++++- .../jni/OpenJK/codeJK2/game/bg_local.h | 10 ++ .../jni/OpenJK/codeJK2/game/bg_misc.cpp | 54 +++++++- java/com/drbeef/jkquest/GLES3JNIActivity.java | 7 +- 34 files changed, 463 insertions(+), 66 deletions(-) diff --git a/Projects/Android/jni/JKVR/VrClientInfo.h b/Projects/Android/jni/JKVR/VrClientInfo.h index 8f47e71..e2a115c 100644 --- a/Projects/Android/jni/JKVR/VrClientInfo.h +++ b/Projects/Android/jni/JKVR/VrClientInfo.h @@ -82,4 +82,8 @@ typedef struct { } vr_client_info_t; +#ifndef JKVR_CLIENT +extern vr_client_info_t *vr; +#endif + #endif //vr_client_info_h \ No newline at end of file diff --git a/Projects/Android/jni/JKVR/VrCommon.h b/Projects/Android/jni/JKVR/VrCommon.h index 75a8d1f..3a59807 100644 --- a/Projects/Android/jni/JKVR/VrCommon.h +++ b/Projects/Android/jni/JKVR/VrCommon.h @@ -8,7 +8,6 @@ #include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" - #include "VrClientInfo.h" #define LOG_TAG "JKVR" diff --git a/Projects/Android/jni/JKVR/VrInputDefault.cpp b/Projects/Android/jni/JKVR/VrInputDefault.cpp index 514835e..c7ef710 100644 --- a/Projects/Android/jni/JKVR/VrInputDefault.cpp +++ b/Projects/Android/jni/JKVR/VrInputDefault.cpp @@ -472,6 +472,13 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG sendButtonAction("+movedown", (primaryButtonsNew & primaryButton1)); } + //Use + if ((pDominantTrackedRemoteNew->Buttons & ovrButton_RThumb) != + (pDominantTrackedRemoteOld->Buttons & ovrButton_RThumb)) { + + sendButtonAction("+use", (pDominantTrackedRemoteNew->Buttons & ovrButton_RThumb)); + } + //Weapon Chooser static bool itemSwitched = false; if (between(-0.2f, pPrimaryJoystick->x, 0.2f) && diff --git a/Projects/Android/jni/OpenJK/Android_client_ja.mk b/Projects/Android/jni/OpenJK/Android_client_ja.mk index cdaff92..5e31be1 100644 --- a/Projects/Android/jni/OpenJK/Android_client_ja.mk +++ b/Projects/Android/jni/OpenJK/Android_client_ja.mk @@ -9,7 +9,7 @@ LOCAL_MODULE := openjk_ja LOCAL_CFLAGS := $(JK3_BASE_CFLAGS) -LOCAL_CPPFLAGS := $(JK3_BASE_CPPFLAGS) -DBOTLIB -D_JK2EXE +LOCAL_CPPFLAGS := $(JK3_BASE_CPPFLAGS) -DBOTLIB -D_JK2EXE -DJKVR_CLIENT LOCAL_LDLIBS := $(JK3_BASE_LDLIBS) diff --git a/Projects/Android/jni/OpenJK/Android_client_jo.mk b/Projects/Android/jni/OpenJK/Android_client_jo.mk index 08a665a..ca33f0f 100644 --- a/Projects/Android/jni/OpenJK/Android_client_jo.mk +++ b/Projects/Android/jni/OpenJK/Android_client_jo.mk @@ -9,7 +9,7 @@ LOCAL_MODULE := openjk_jo LOCAL_CFLAGS := $(JK3_BASE_CFLAGS) -LOCAL_CPPFLAGS := $(JK3_BASE_CPPFLAGS) -DBOTLIB -D_JK2EXE -DJK2_MODE +LOCAL_CPPFLAGS := $(JK3_BASE_CPPFLAGS) -DBOTLIB -D_JK2EXE -DJK2_MODE -DJKVR_CLIENT LOCAL_LDLIBS := $(JK3_BASE_LDLIBS) diff --git a/Projects/Android/jni/OpenJK/Android_gles.mk b/Projects/Android/jni/OpenJK/Android_gles.mk index b0069f6..4e5f4d3 100644 --- a/Projects/Android/jni/OpenJK/Android_gles.mk +++ b/Projects/Android/jni/OpenJK/Android_gles.mk @@ -8,7 +8,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := rd-gles_arm -LOCAL_CFLAGS := $(JK3_BASE_CFLAGS) -DHAVE_GLES -DRENDERER -D_JK2EXE -DSP_GAME -Wno-narrowing +LOCAL_CFLAGS := $(JK3_BASE_CFLAGS) -DHAVE_GLES -DRENDERER -D_JK2EXE -DJK2_MODE -DSP_GAME -Wno-narrowing LOCAL_CPPFLAGS := $(JK3_BASE_CPPFLAGS) LOCAL_LDLIBS := $(JK3_BASE_LDLIBS) diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_camera.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_camera.cpp index 4b3a3e8..1c590f7 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_camera.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_camera.cpp @@ -42,8 +42,6 @@ void CGCam_DistanceDisable( void ); extern qboolean CG_CalcFOVFromX( float fov_x ); extern void WP_SaberCatch( gentity_t *self, gentity_t *saber, qboolean switchToSaber ); -extern vr_client_info_t *vr; - /* TODO: CloseUp, FullShot & Longshot commands: diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_draw.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_draw.cpp index 3c7489b..5799959 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_draw.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_draw.cpp @@ -35,8 +35,6 @@ extern vmCvar_t cg_debugHealthBars; extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent ); -extern vr_client_info_t *vr; - void CG_DrawIconBackground(void); void CG_DrawMissionInformation( void ); void CG_DrawInventorySelect( void ); @@ -4288,7 +4286,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) { cgi_R_LAGoggles(); } - if (!in_camera) { + if (!in_camera || vr->immersive_cinematics) { //Vertical Positional Movement cg.refdef.vieworg[2] -= (float)g_entities[cg.snap->ps.viewEntity].client->ps.viewheight; cg.refdef.vieworg[2] += (vr->hmdposition[1] + cg_heightAdjust.value) * cg_worldScale.value; diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_drawtools.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_drawtools.cpp index bdb658e..8d3a4db 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_drawtools.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_drawtools.cpp @@ -26,8 +26,6 @@ along with this program; if not, see . #include "cg_media.h" #include -extern vr_client_info_t *vr; - void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) { if (!vr->in_camera && !vr->using_screen_layer && !vr->scopeengaged) diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_event.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_event.cpp index 635dfe1..2ede39c 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_event.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_event.cpp @@ -463,9 +463,9 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { index = es->eventParm; // player predicted - if ( (char)index < 0 ) + if ( index < 0 ) { - index = -(char)index; + index = -index; bHadItem = qtrue; } diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_main.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_main.cpp index 7d8ee80..41093b4 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_main.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_main.cpp @@ -88,8 +88,6 @@ const char *inv_names[] = int force_icons[NUM_FORCE_POWERS]; -extern vr_client_info_t *vr; - void CG_DrawDataPadHUD( centity_t *cent ); void CG_DrawDataPadObjectives(const centity_t *cent ); @@ -331,6 +329,25 @@ vmCvar_t cg_hudFiles; vmCvar_t cg_neverHearThatDumbBeepingSoundAgain; +vmCvar_t vr_weapon_adjustment_1; +vmCvar_t vr_weapon_adjustment_2; +vmCvar_t vr_weapon_adjustment_3; +vmCvar_t vr_weapon_adjustment_4; +vmCvar_t vr_weapon_adjustment_5; +vmCvar_t vr_weapon_adjustment_6; +vmCvar_t vr_weapon_adjustment_7; +vmCvar_t vr_weapon_adjustment_8; +vmCvar_t vr_weapon_adjustment_9; +vmCvar_t vr_weapon_adjustment_10; +vmCvar_t vr_weapon_adjustment_11; +vmCvar_t vr_weapon_adjustment_12; +vmCvar_t vr_weapon_adjustment_13; +vmCvar_t vr_weapon_adjustment_14; +vmCvar_t vr_weapon_adjustment_18; +vmCvar_t vr_weapon_adjustment_19; +vmCvar_t vr_weapon_adjustment_20; +vmCvar_t vr_weapon_adjustment_22; + vmCvar_t cg_VariantSoundCap; // 0 = no capping, else cap to (n) max (typically just 1, but allows more) vmCvar_t cg_turnAnims; vmCvar_t cg_motionBoneComp; @@ -453,6 +470,27 @@ static cvarTable_t cvarTable[] = { { &cg_missionInfoFlashTime, "cg_missionInfoFlashTime", "10000", 0 }, { &cg_hudFiles, "cg_hudFiles", "ui/jahud.txt", CVAR_ARCHIVE}, + //Default Weapon adjustments - these WILL be overridden + // scale,right,up,forward,pitch,yaw,roll + { &vr_weapon_adjustment_1, "vr_weapon_adjustment_1", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_2, "vr_weapon_adjustment_2", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_3, "vr_weapon_adjustment_3", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_4, "vr_weapon_adjustment_4", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_5, "vr_weapon_adjustment_5", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_6, "vr_weapon_adjustment_6", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_7, "vr_weapon_adjustment_7", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_8, "vr_weapon_adjustment_8", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_9, "vr_weapon_adjustment_9", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_10, "vr_weapon_adjustment_10", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_11, "vr_weapon_adjustment_11", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_12, "vr_weapon_adjustment_12", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_13, "vr_weapon_adjustment_13", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_14, "vr_weapon_adjustment_14", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_18, "vr_weapon_adjustment_18", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_19, "vr_weapon_adjustment_19", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_20, "vr_weapon_adjustment_20", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &vr_weapon_adjustment_22, "vr_weapon_adjustment_22", "0.62,-9.8,11.3,-16.1,0.0,0.0,0.0", CVAR_ARCHIVE}, + { &cg_VariantSoundCap, "cg_VariantSoundCap", "0", 0 }, { &cg_turnAnims, "cg_turnAnims", "0", 0 }, { &cg_motionBoneComp, "cg_motionBoneComp", "2", 0 }, diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_public.h b/Projects/Android/jni/OpenJK/code/cgame/cg_public.h index 6f36740..8b041f7 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_public.h +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_public.h @@ -347,6 +347,7 @@ Ghoul2 Insert End CG_OPENJK_MENU_PAINT_JK2, CG_OPENJK_GETMENU_BYNAME_JK2, + CG_CVAR_GET_JK2, } cgameJK2Import_t; #endif diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_view.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_view.cpp index 6520624..0f4d800 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_view.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_view.cpp @@ -38,8 +38,6 @@ along with this program; if not, see . float cg_zoomFov; -extern vr_client_info_t *vr; - //#define CG_CAM_ABOVE 2 extern qboolean CG_OnMovingPlat( playerState_t *ps ); diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_weapons.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_weapons.cpp index 678b6ef..f69b914 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_weapons.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_weapons.cpp @@ -32,8 +32,6 @@ along with this program; if not, see . #include #include -extern vr_client_info_t *vr; - extern void CG_LightningBolt( centity_t *cent, vec3_t origin ); #define PHASER_HOLDFRAME 2 diff --git a/Projects/Android/jni/OpenJK/code/client/cl_cgame.cpp b/Projects/Android/jni/OpenJK/code/client/cl_cgame.cpp index c836863..db5173d 100644 --- a/Projects/Android/jni/OpenJK/code/client/cl_cgame.cpp +++ b/Projects/Android/jni/OpenJK/code/client/cl_cgame.cpp @@ -32,6 +32,7 @@ along with this program; if not, see . #include "vmachine.h" #include "qcommon/stringed_ingame.h" #include "sys/sys_loadlib.h" + #include vm_t cgvm; @@ -463,6 +464,9 @@ cgameImport_t CL_ConvertJK2SysCall( cgameJK2Import_t import ) case CG_CVAR_SET_JK2: return CG_CVAR_SET; break; + case CG_CVAR_GET_JK2: + return CG_CVAR_GET; + break; case CG_ARGC_JK2: return CG_ARGC; break; diff --git a/Projects/Android/jni/OpenJK/code/client/cl_main.cpp b/Projects/Android/jni/OpenJK/code/client/cl_main.cpp index a21bf1a..82c0b47 100644 --- a/Projects/Android/jni/OpenJK/code/client/cl_main.cpp +++ b/Projects/Android/jni/OpenJK/code/client/cl_main.cpp @@ -33,6 +33,7 @@ along with this program; if not, see . #include "qcommon/stringed_ingame.h" #include "sys/sys_loadlib.h" #include "qcommon/ojk_saved_game.h" + #include #define RETRANSMIT_TIMEOUT 3000 // time between connection packet retransmits diff --git a/Projects/Android/jni/OpenJK/code/game/bg_misc.cpp b/Projects/Android/jni/OpenJK/code/game/bg_misc.cpp index 87b737f..2527d33 100644 --- a/Projects/Android/jni/OpenJK/code/game/bg_misc.cpp +++ b/Projects/Android/jni/OpenJK/code/game/bg_misc.cpp @@ -31,8 +31,6 @@ along with this program; if not, see . #include "g_vehicles.h" #include -extern vr_client_info_t *vr; - extern weaponData_t weaponData[WP_NUM_WEAPONS]; extern ammoData_t ammoData[AMMO_MAX]; diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_model.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_model.cpp index 8297b08..3ec93fe 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_model.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_model.cpp @@ -32,8 +32,6 @@ along with this program; if not, see . #include "../qcommon/sstring.h" #include -extern vr_client_info_t *vr; - #define LL(x) x=LittleLong(x) #define LS(x) x=LittleShort(x) #define LF(x) x=LittleFloat(x) diff --git a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_scene.cpp b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_scene.cpp index 124986f..ec5b963 100644 --- a/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_scene.cpp +++ b/Projects/Android/jni/OpenJK/code/rd-vanilla/tr_scene.cpp @@ -43,8 +43,6 @@ int r_numpolyverts; int skyboxportal; int drawskyboxportal; -extern vr_client_info_t *vr; - /* ==================== R_InitNextFrame diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_camera.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_camera.cpp index 459fe4a..9b8e65c 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_camera.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_camera.cpp @@ -27,6 +27,7 @@ along with this program; if not, see . #include "cg_media.h" #include "../game/g_roff.h" +#include bool in_camera = false; camera_t client_camera={}; @@ -1080,7 +1081,8 @@ void CGCam_Update( void ) } else { - CG_CalcFOVFromX( client_camera.FOV ); + float fov = vr && vr->immersive_cinematics ? vr->fov : client_camera.FOV; + CG_CalcFOVFromX( fov ); } //Check for roffing angles @@ -1171,9 +1173,17 @@ void CGCam_Update( void ) //Normal fading - separate call because can finish after camera is disabled CGCam_UpdateFade(); + if (vr->immersive_cinematics) + { + float yaw = cg.refdefViewAngles[YAW] + vr->hmdorientation[YAW]; + VectorCopy(vr->hmdorientation, cg.refdefViewAngles); + cg.refdefViewAngles[YAW] = yaw; + } + //Update shaking if there's any //CGCam_UpdateSmooth( cg.refdef.vieworg, cg.refdefViewAngles ); CGCam_UpdateShake( cg.refdef.vieworg, cg.refdefViewAngles ); + AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); } /* diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_draw.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_draw.cpp index 35b0266..13f171a 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_draw.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_draw.cpp @@ -28,6 +28,7 @@ along with this program; if not, see . #include "cg_local.h" #include "cg_media.h" #include "../game/objectives.h" +#include void CG_DrawIconBackground(void); void CG_DrawMissionInformation( void ); @@ -2466,28 +2467,36 @@ void CG_DrawActive( stereoFrame_t stereoView ) { VectorNormalize( vright_n ); VectorNormalize( vup_n ); + cg.refdef.stereoView = stereoView; switch ( stereoView ) { case STEREO_CENTER: separation = 0; break; case STEREO_LEFT: - separation = -cg_stereoSeparation.value / 2; + separation = cg_worldScale.value * (-cg_stereoSeparation.value / 2); break; case STEREO_RIGHT: - separation = cg_stereoSeparation.value / 2; + separation = cg_worldScale.value * (cg_stereoSeparation.value / 2); break; default: separation = 0; CG_Error( "CG_DrawActive: Undefined stereoView" ); } + cg.refdef.worldscale = cg_worldScale.value; + if (!in_camera) { + VectorCopy(vr->hmdorientation, cg.refdef.viewangles); + cg.refdef.viewangles[YAW] = + SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]) + vr->hmdorientation[YAW] + vr->snapTurn; + AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis); + } // clear around the rendered view if sized down CG_TileClear(); // offset vieworg appropriately if we're doing stereo separation VectorCopy( cg.refdef.vieworg, baseOrg ); - if ( separation != 0 ) { + if ( separation != 0 && (!in_camera || vr->immersive_cinematics)) { VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg ); } @@ -2496,6 +2505,12 @@ void CG_DrawActive( stereoFrame_t stereoView ) { cgi_R_LAGoggles(); } + if (!in_camera || vr->immersive_cinematics) { + //Vertical Positional Movement + cg.refdef.vieworg[2] -= (float)g_entities[cg.snap->ps.viewEntity].client->ps.viewheight; + cg.refdef.vieworg[2] += (vr->hmdposition[1] + cg_heightAdjust.value) * cg_worldScale.value; + } + // draw 3D view cgi_R_RenderScene( &cg.refdef ); diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_drawtools.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_drawtools.cpp index badda59..b454626 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_drawtools.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_drawtools.cpp @@ -23,6 +23,95 @@ along with this program; if not, see . #include "cg_local.h" #include "cg_media.h" +#include + + +void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) { + if (!vr->in_camera && !vr->using_screen_layer && !vr->scopeengaged) + { + float screenXScale = 1.0f / 3.5f; + float screenYScale = 1.0f / 3.5f; + + float xoffset = -24; + if (cg.refdef.stereoView == 1) { + xoffset *= -1; + } + + *x *= screenXScale; + *y *= screenYScale; + if (w != NULL) { + *w *= screenXScale; + } + if (h != NULL) { + *h *= screenYScale; + } + + *x += (640 - (640 * screenXScale)) / 2.0f + xoffset; + *y += (480 - (480 * screenYScale)) / 2.0f; + } +} +void CG_AdjustFrom640Int( int *x, int *y, int *w, int *h ) { + if (!vr->in_camera && !vr->using_screen_layer && !vr->scopeengaged) + { + float screenXScale = 1.0f / 3.5f; + float screenYScale = 1.0f / 3.5f; + + float xoffset = -24; + if (cg.refdef.stereoView == 1) { + xoffset *= -1; + } + + *x *= screenXScale; + *y *= screenYScale; + if (w != NULL) { + *w *= screenXScale; + } + if (h != NULL) { + *h *= screenYScale; + } + + *x += (640 - (640 * screenXScale)) / 2.0f + xoffset; + *y += (480 - (480 * screenYScale)) / 2.0f; + } +} + +/* +================ +CG_DrawSides + +Coords are virtual 640x480 +================ +*/ +void CG_DrawSides(float x, float y, float w, float h, float size) { + //size *= cgs.screenXScale; + CG_AdjustFrom640(&x, &y, &w, &h); + cgi_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader ); + cgi_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, cgs.media.whiteShader ); +} + +void CG_DrawTopBottom(float x, float y, float w, float h, float size) { + //size *= cgs.screenYScale; + CG_AdjustFrom640(&x, &y, &w, &h); + cgi_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, cgs.media.whiteShader ); + cgi_R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, cgs.media.whiteShader ); +} + +/* +================ +CG_DrawRect + +Coordinates are 640*480 virtual values +================= +*/ +void CG_DrawRect( float x, float y, float width, float height, float size, const float *color ) { + cgi_R_SetColor( color ); + + CG_AdjustFrom640(&x, &y, &width, &height); + CG_DrawTopBottom(x, y, width, height, size); + CG_DrawSides(x, y, width, height, size); + + cgi_R_SetColor( NULL ); +} /* ================ @@ -33,6 +122,7 @@ Coordinates are 640*480 virtual values */ void CG_FillRect( float x, float y, float width, float height, const float *color ) { cgi_R_SetColor( color ); + CG_AdjustFrom640(&x, &y, &width, &height); cgi_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cgs.media.whiteShader); cgi_R_SetColor( NULL ); } @@ -48,6 +138,7 @@ Coordinates are 640*480 virtual values void CG_Scissor( float x, float y, float width, float height) { + CG_AdjustFrom640(&x, &y, &width, &height); cgi_R_Scissor( x, y, width, height); } @@ -62,6 +153,7 @@ A width of 0 will draw with the original image width ================= */ void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader ) { + CG_AdjustFrom640(&x, &y, &width, &height); cgi_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader ); } @@ -76,6 +168,7 @@ Can also specify the exact texture coordinates */ void CG_DrawPic2( float x, float y, float width, float height, float s1, float t1, float s2, float t2, qhandle_t hShader ) { + CG_AdjustFrom640(&x, &y, &width, &height); cgi_R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, hShader ); } @@ -89,6 +182,7 @@ rotates around the upper right corner of the passed in point ================= */ void CG_DrawRotatePic( float x, float y, float width, float height,float angle, qhandle_t hShader ) { + CG_AdjustFrom640(&x, &y, &width, &height); cgi_R_DrawRotatePic( x, y, width, height, 0, 0, 1, 1, angle, hShader ); } @@ -102,6 +196,7 @@ Actually rotates around the center point of the passed in coordinates ================= */ void CG_DrawRotatePic2( float x, float y, float width, float height,float angle, qhandle_t hShader ) { + CG_AdjustFrom640(&x, &y, &width, &height); cgi_R_DrawRotatePic2( x, y, width, height, 0, 0, 1, 1, angle, hShader ); } @@ -149,7 +244,8 @@ void CG_DrawChar( int x, int y, int width, int height, int ch ) { size = 0.03125; size2 = 0.0625; - cgi_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + size, frow + size2, + CG_AdjustFrom640(&ax, &ay, &aw, &ah); + cgi_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + size, frow + size2, cgs.media.charsetShader ); } @@ -212,7 +308,10 @@ void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, void CG_DrawSmallStringColor( int x, int y, const char *s, vec4_t color ) { - CG_DrawStringExt( x, y, s, color, qtrue, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT ); + auto fx = (float)x; + auto fy = (float)y; + CG_AdjustFrom640(&fx, &fy, NULL, NULL); + CG_DrawStringExt( (int)fx, (int)fy, s, color, qtrue, qfalse, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT ); } /* @@ -249,6 +348,8 @@ refresh window. static void CG_TileClearBox( int x, int y, int w, int h, qhandle_t hShader ) { float s1, t1, s2, t2; +// CG_AdjustFrom640Int(&x, &y, &w, &h); + s1 = x/64.0; t1 = y/64.0; s2 = (x+w)/64.0; @@ -394,17 +495,22 @@ void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charH { for (int i = 0; i < (width - l); i++ ) { + int _x = x; + int _y = y; + int _charWidth = charWidth; + int _charHeight = charHeight; + //CG_AdjustFrom640Int(&_x, &_y, &_charWidth, &_charHeight); switch(style) { case NUM_FONT_SMALL: - CG_DrawPic( x,y, charWidth, charHeight, cgs.media.smallnumberShaders[0] ); + CG_DrawPic( _x,_y, _charWidth, _charHeight, cgs.media.smallnumberShaders[0] ); break; case NUM_FONT_CHUNKY: - CG_DrawPic( x,y, charWidth, charHeight, cgs.media.chunkyNumberShaders[0] ); + CG_DrawPic( _x,_y, _charWidth, _charHeight, cgs.media.chunkyNumberShaders[0] ); break; default: case NUM_FONT_BIG: - CG_DrawPic( x,y, charWidth, charHeight, cgs.media.numberShaders[0] ); + CG_DrawPic( _x,_y, _charWidth, _charHeight, cgs.media.numberShaders[0] ); break; } x += 2 + (xWidth); @@ -423,18 +529,23 @@ void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charH else frame = *ptr -'0'; + int _x = x; + int _y = y; + int _charWidth = charWidth; + int _charHeight = charHeight; + //CG_AdjustFrom640Int(&_x, &_y, &_charWidth, &_charHeight); switch(style) { case NUM_FONT_SMALL: - CG_DrawPic( x,y, charWidth, charHeight, cgs.media.smallnumberShaders[frame] ); + CG_DrawPic( _x, _y, _charWidth, _charHeight, cgs.media.smallnumberShaders[frame] ); x++; // For a one line gap break; case NUM_FONT_CHUNKY: - CG_DrawPic( x,y, charWidth, charHeight, cgs.media.chunkyNumberShaders[frame] ); + CG_DrawPic( _x, _y, _charWidth, _charHeight, cgs.media.chunkyNumberShaders[frame] ); break; default: case NUM_FONT_BIG: - CG_DrawPic( x,y, charWidth, charHeight, cgs.media.numberShaders[frame] ); + CG_DrawPic( _x, _y, _charWidth, _charHeight, cgs.media.numberShaders[frame] ); break; } @@ -453,5 +564,6 @@ CG_DrawProportionalString void CG_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) { //assert(!style);//call this directly if you need style (OR it into the font handle) + CG_AdjustFrom640Int(&x, &y, NULL, NULL); cgi_R_Font_DrawString (x, y, str, color, cgs.media.qhFontMedium, -1, 1.0f); } \ No newline at end of file diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_event.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_event.cpp index cf050a3..fcadc43 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_event.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_event.cpp @@ -463,9 +463,9 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { index = es->eventParm; // player predicted - if ( (char)index < 0 ) + if ( index < 0 ) { - index = -(char)index; + index = -index; bHadItem = qtrue; } diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_local.h b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_local.h index fa696e1..be1c0a5 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_local.h +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_local.h @@ -608,6 +608,8 @@ extern vmCvar_t cg_saberAutoThird; extern vmCvar_t cg_gunAutoFirst; extern vmCvar_t cg_stereoSeparation; +extern vmCvar_t cg_worldScale; +extern vmCvar_t cg_heightAdjust; extern vmCvar_t cg_developer; extern vmCvar_t cg_timescale; extern vmCvar_t cg_skippingcin; @@ -639,6 +641,26 @@ extern vmCvar_t cg_smoothPlayerPos; extern vmCvar_t cg_smoothPlayerPlat; extern vmCvar_t cg_smoothPlayerPlatAccel; + +//VR Weapon Offsets +extern vmCvar_t vr_weapon_adjustment_1; +extern vmCvar_t vr_weapon_adjustment_2; +extern vmCvar_t vr_weapon_adjustment_3; +extern vmCvar_t vr_weapon_adjustment_4; +extern vmCvar_t vr_weapon_adjustment_5; +extern vmCvar_t vr_weapon_adjustment_6; +extern vmCvar_t vr_weapon_adjustment_7; +extern vmCvar_t vr_weapon_adjustment_8; +extern vmCvar_t vr_weapon_adjustment_9; +extern vmCvar_t vr_weapon_adjustment_10; +extern vmCvar_t vr_weapon_adjustment_11; +extern vmCvar_t vr_weapon_adjustment_12; +extern vmCvar_t vr_weapon_adjustment_13; +extern vmCvar_t vr_weapon_adjustment_14; +extern vmCvar_t vr_weapon_adjustment_18; +extern vmCvar_t vr_weapon_adjustment_19; +extern vmCvar_t vr_weapon_adjustment_20; +extern vmCvar_t vr_weapon_adjustment_22; void CG_NewClientinfo( int clientNum ); // // cg_main.c @@ -919,6 +941,7 @@ int cgi_Milliseconds( void ); void cgi_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ); void cgi_Cvar_Update( vmCvar_t *vmCvar ); void cgi_Cvar_Set( const char *var_name, const char *value ); +char* cgi_Cvar_Get( const char *var_name ); // ServerCommand and ConsoleCommand parameter access diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_main.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_main.cpp index 1474c1d..5fee8d1 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_main.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_main.cpp @@ -29,6 +29,7 @@ along with this program; if not, see . #include "../../code/qcommon/sstring.h" #include "../code/qcommon/ojk_saved_game_helper.h" +#include //NOTENOTE: Be sure to change the mirrored code in g_shared.h typedef std::map< sstring_t, unsigned char, std::less > namePrecache_m; @@ -107,8 +108,10 @@ extern "C" Q_EXPORT intptr_t vmMain( intptr_t command, intptr_t arg0, intptr_t a centity_t *cent; switch ( command ) { - case CG_INIT: - CG_Init( arg0 ); + case CG_INIT: { + vr = (vr_client_info_t *) (arg1); + CG_Init(arg0); + } return 0; case CG_SHUTDOWN: CG_Shutdown(); @@ -223,6 +226,8 @@ centity_t cg_entities[MAX_GENTITIES]; weaponInfo_t cg_weapons[MAX_WEAPONS]; itemInfo_t cg_items[MAX_ITEMS]; +vr_client_info_t *vr; + typedef struct { qboolean registered; // Has the player picked it up qboolean active; // Is it the chosen inventory item @@ -299,6 +304,8 @@ vmCvar_t cg_thirdPersonAutoAlpha; vmCvar_t cg_thirdPersonHorzOffset; vmCvar_t cg_stereoSeparation; +vmCvar_t cg_worldScale; +vmCvar_t cg_heightAdjust; vmCvar_t cg_developer; vmCvar_t cg_timescale; vmCvar_t cg_skippingcin; @@ -361,7 +368,9 @@ static cvarTable_t cvarTable[] = { { &cg_drawGun, "cg_drawGun", "1", CVAR_ARCHIVE }, { &cg_fov, "cg_fov", "80", CVAR_ARCHIVE }, { &cg_fovAspectAdjust, "cg_fovAspectAdjust", "0", CVAR_ARCHIVE }, - { &cg_stereoSeparation, "cg_stereoSeparation", "0.4", CVAR_ARCHIVE }, + { &cg_stereoSeparation, "cg_stereoSeparation", "0.065", CVAR_ARCHIVE }, + { &cg_worldScale, "cg_worldScale", "37.5", CVAR_ARCHIVE }, + { &cg_heightAdjust, "cg_heightAdjust", "0.0", CVAR_ARCHIVE }, { &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE }, { &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE }, @@ -371,7 +380,7 @@ static cvarTable_t cvarTable[] = { { &cg_drawFPS, "cg_drawFPS", "0", CVAR_ARCHIVE }, { &cg_drawSnapshot, "cg_drawSnapshot", "0", CVAR_ARCHIVE }, { &cg_drawAmmoWarning, "cg_drawAmmoWarning", "1", CVAR_ARCHIVE }, - { &cg_drawCrosshair, "cg_drawCrosshair", "1", CVAR_ARCHIVE }, + { &cg_drawCrosshair, "cg_drawCrosshair", "0", CVAR_ARCHIVE }, { &cg_dynamicCrosshair, "cg_dynamicCrosshair", "1", CVAR_ARCHIVE }, { &cg_crosshairIdentifyTarget, "cg_crosshairIdentifyTarget", "1", CVAR_ARCHIVE }, { &cg_crosshairForceHint, "cg_crosshairForceHint", "1", CVAR_ARCHIVE|CVAR_SAVEGAME|CVAR_NORESTART }, diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_marks.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_marks.cpp index f4bcfa8..99c533d 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_marks.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_marks.cpp @@ -125,8 +125,8 @@ temporary marks will not be stored or randomly oriented, but immediately passed to the renderer. ================= */ -#define MAX_MARK_FRAGMENTS 128 -#define MAX_MARK_POINTS 384 +#define MAX_MARK_FRAGMENTS 256 +#define MAX_MARK_POINTS 768 void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, float orientation, float red, float green, float blue, float alpha, @@ -225,8 +225,8 @@ void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, CG_AddMarks =============== */ -#define MARK_TOTAL_TIME 10000 -#define MARK_FADE_TIME 1000 +#define MARK_TOTAL_TIME 20000 +#define MARK_FADE_TIME 10000 void CG_AddMarks( void ) { int j; diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp index 904aea6..ffe357d 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp @@ -30,6 +30,7 @@ along with this program; if not, see . #include "../game/ghoul2_shared.h" #include "../game/anims.h" #include "../game/wp_saber.h" +#include "bg_local.h" #define LOOK_SWING_SCALE 0.5 @@ -5787,7 +5788,14 @@ Ghoul2 Insert End //FIXME: allow it to be put anywhere and move this out of if(torso.hModel) //Will have to call CG_PositionRotatedEntityOnTag - CG_PositionEntityOnTag( &gun, &torso, torso.hModel, "tag_weapon"); + //CG_PositionEntityOnTag( &gun, &torso, torso.hModel, "tag_weapon"); + + vec3_t angs; + BG_CalculateVRWeaponPosition(gun.origin, angs); + AnglesToAxis(angs, gun.axis); + //Gotta move this forward but test for now + VectorCopy( gun.origin, gun.lightingOrigin ); + //--------------------- start saber hacks diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_public.h b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_public.h index 7a8d78f..6243edf 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_public.h +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_public.h @@ -198,6 +198,7 @@ Ghoul2 Insert End CG_OPENJK_MENU_PAINT, CG_OPENJK_GETMENU_BYNAME, + CG_CVAR_GET } cgameImport_t; //---------------------------------------------- diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_syscalls.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_syscalls.cpp index d4e637c..0090166 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_syscalls.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_syscalls.cpp @@ -67,6 +67,10 @@ void cgi_Cvar_Set( const char *var_name, const char *value ) { Q_syscall( CG_CVAR_SET, var_name, value ); } +char* cgi_Cvar_Get( const char *var_name ) { + return (char*)Q_syscall( CG_CVAR_GET, var_name ); +} + int cgi_Argc( void ) { return Q_syscall( CG_ARGC ); } diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_view.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_view.cpp index 2abf893..56b18dc 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_view.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_view.cpp @@ -30,12 +30,14 @@ along with this program; if not, see . #include "../game/wp_saber.h" #include "../game/anims.h" #include "../game/g_functions.h" +#include #define MASK_CAMERACLIP (MASK_SOLID) #define CAMERA_SIZE 4 float cg_zoomFov; + //#define CG_CAM_ABOVE 2 extern qboolean CG_OnMovingPlat( playerState_t *ps ); @@ -1353,7 +1355,8 @@ static qboolean CG_CalcFov( void ) { if ( &g_entities[cg.snap->ps.viewEntity] && g_entities[cg.snap->ps.viewEntity].NPC ) {//FIXME: looks bad when take over a jedi... but never really do that, do we? - fov_x = g_entities[cg.snap->ps.viewEntity].NPC->stats.hfov; + //fov_x = g_entities[cg.snap->ps.viewEntity].NPC->stats.hfov; + fov_x = vr ? vr->fov : 90.0f; //sanity-cap? if ( fov_x > 120 ) { @@ -1372,7 +1375,8 @@ static qboolean CG_CalcFov( void ) { } else { - fov_x = 120;//FIXME: read from the NPC's fov stats? + //fov_x = 120;//FIXME: read from the NPC's fov stats? + fov_x = vr ? vr->fov : 90.0f; } } } @@ -1380,6 +1384,7 @@ static qboolean CG_CalcFov( void ) { { fov_x = CG_ForceSpeedFOV(); } else { + /* // user selectable if ( cg.overrides.active & CG_OVERRIDE_FOV ) { @@ -1393,7 +1398,9 @@ static qboolean CG_CalcFov( void ) { fov_x = 1; } else if ( fov_x > 160 ) { fov_x = 160; - } + }*/ + + fov_x = vr ? vr->fov : 90.0f; // Disable zooming when in third person if ( cg.zoomMode && cg.zoomMode < 3 )//&& !cg.renderingThirdPerson ) // light amp goggles do none of the zoom silliness @@ -1891,11 +1898,13 @@ wasForceSpeed=isForceSpeed; } cgi_SetUserCmdValue( cg.weaponSelect, speed, mPitchOverride, mYawOverride ); - // this counter will be bumped for every valid scene we generate - cg.clientFrame++; + if ( stereoView == STEREO_LEFT ) { + // this counter will be bumped for every valid scene we generate + cg.clientFrame++; - // update cg.predicted_player_state - CG_PredictPlayerState(); + // update cg.predicted_player_state + CG_PredictPlayerState(); + } // decide on third person view cg.renderingThirdPerson = (qboolean)( @@ -1910,6 +1919,7 @@ wasForceSpeed=isForceSpeed; cg.renderingThirdPerson = qfalse; } + vr->in_camera = in_camera; if ( in_camera ) { // The camera takes over the view diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp index 6bfbbd5..dfe6be5 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp @@ -27,6 +27,8 @@ along with this program; if not, see . #include "../game/wp_saber.h" #include "../game/g_local.h" #include "../game/anims.h" +#include +#include extern void CG_LightningBolt( centity_t *cent, vec3_t origin ); @@ -779,6 +781,82 @@ void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) angles[PITCH] += (scale * 0.5f ) * fracsin * 0.01; } +static float CG_CalculateWeaponPositionAndScale( playerState_t *ps, vec3_t origin, vec3_t angles ) { + + BG_CalculateVRWeaponPosition(origin, angles); + + vec3_t offset; + + //Weapon offset debugging + float scale=1.0f; + if (strcmp(cgi_Cvar_Get("vr_control_scheme"), "99") == 0) { + vr->weaponid = ps->weapon; + scale = vr->test_scale; + + //Adjust angles for weapon models that aren't aligned very well + matrix4x4 m1, m2, m3; + vec3_t zero; + VectorClear(zero); + Matrix4x4_CreateFromEntity(m1, angles, zero, 1.0); + Matrix4x4_CreateFromEntity(m2, vr->test_angles, zero, 1.0); + Matrix4x4_Concat(m3, m1, m2); + Matrix4x4_ConvertToEntity(m3, angles, zero); + + VectorCopy(vr->test_offset, offset); + + CG_CenterPrint( vr->test_name, SMALLCHAR_WIDTH ); + } else { + if (ps->weapon != 0) + { + char cvar_name[64]; + Com_sprintf(cvar_name, sizeof(cvar_name), "vr_weapon_adjustment_%i", ps->weapon); + + char* weapon_adjustment = cgi_Cvar_Get(cvar_name); + + if (strlen(weapon_adjustment) > 0) { + vec3_t adjust; + vec3_t temp_offset; + VectorClear(temp_offset); + VectorClear(adjust); + + sscanf(weapon_adjustment, "%f,%f,%f,%f,%f,%f,%f", &scale, + &(temp_offset[0]), &(temp_offset[1]), &(temp_offset[2]), + &(adjust[PITCH]), &(adjust[YAW]), &(adjust[ROLL])); + VectorScale(temp_offset, scale, offset); + + if (!vr->right_handed) + { + //yaw needs to go in the other direction as left handed model is reversed + adjust[YAW] *= -1.0f; + } + + //Adjust angles for weapon models that aren't aligned very well + matrix4x4 m1, m2, m3; + vec3_t zero; + VectorClear(zero); + Matrix4x4_CreateFromEntity(m1, angles, zero, 1.0); + Matrix4x4_CreateFromEntity(m2, adjust, zero, 1.0); + Matrix4x4_Concat(m3, m1, m2); + Matrix4x4_ConvertToEntity(m3, angles, zero); + } + } + } + + + //Now move weapon closer to proper origin + vec3_t forward, right, up; + AngleVectors( angles, forward, right, up ); + VectorMA( origin, offset[2], forward, origin ); + VectorMA( origin, offset[1], up, origin ); + if (vr->right_handed) { + VectorMA(origin, offset[0], right, origin); + } else { + VectorMA(origin, -offset[0], right, origin); + } + + return scale; +} + /* ====================== CG_MachinegunSpinAngle @@ -1028,22 +1106,54 @@ void CG_AddViewWeapon( playerState_t *ps ) return; } - // set up gun position - CG_CalculateWeaponPosition( hand.origin, angles ); + if (strcmp(cgi_Cvar_Get("vr_control_scheme"), "99") == 0) { + vec3_t origin; + vec3_t endForward, endRight, endUp; + vec3_t angles; + clientInfo_t ci; + BG_CalculateVRWeaponPosition( origin, angles ); + vec3_t forward, right, up; + AngleVectors(angles, forward, right, up); + + trace_t trace; + VectorMA(origin, 256, forward, endForward); + CG_TestLine(origin, endForward, FRAMETIME, 0xFF0000, 0.5 ); + + VectorMA(origin, 20, right, endRight); + CG_TestLine(origin, endRight, FRAMETIME, 0x00FF00, 0.5 ); + + VectorMA(origin, 20, up, endUp); + CG_TestLine(origin, endUp, FRAMETIME, 0x0000FF, 0.5 ); + + CG_CenterPrint(vr->test_name, 240); + + } + + // set up gun position + float scale = CG_CalculateWeaponPositionAndScale( ps, hand.origin, angles ); + VectorMA( hand.origin, cg_gun_x.value, cg.refdef.viewaxis[0], hand.origin ); VectorMA( hand.origin, (cg_gun_y.value+leanOffset), cg.refdef.viewaxis[1], hand.origin ); VectorMA( hand.origin, (cg_gun_z.value+fovOffset), cg.refdef.viewaxis[2], hand.origin ); AnglesToAxis( angles, hand.axis ); - if ( cg_fovViewmodel.integer ) + //scale the whole model (hand and weapon) + for ( int i = 0; i < 3; i++ ) { + VectorScale( hand.axis[i], (vr->right_handed || i != 1 ) ? scale : -scale, hand.axis[i] ); + } + + //Gotta move this forward but test for now + VectorCopy( hand.origin, hand.lightingOrigin ); + +/* if ( cg_fovViewmodel.integer ) { float fracDistFOV = tanf( cg.refdef.fov_x * ( M_PI/180 ) * 0.5f ); float fracWeapFOV = ( 1.0f / fracDistFOV ) * tanf( cgFov * ( M_PI/180 ) * 0.5f ); VectorScale( hand.axis[0], fracWeapFOV, hand.axis[0] ); } - +*/ // map torso animations to weapon animations if ( cg_gun_frame.integer ) { diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/bg_local.h b/Projects/Android/jni/OpenJK/codeJK2/game/bg_local.h index 59f6064..fb2a234 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/bg_local.h +++ b/Projects/Android/jni/OpenJK/codeJK2/game/bg_local.h @@ -23,6 +23,9 @@ along with this program; if not, see . // bg_local.h -- local definitions for the bg (both games) files +#ifndef _BG_LOCAL_H +#define _BG_LOCAL_H + #define TIMER_LAND 130 #define TIMER_GESTURE (34*66+50) @@ -75,5 +78,12 @@ void PM_AddEvent( int newEvent ); qboolean PM_SlideMove( float gravity ); 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_CalculateVROffHandPosition( vec3_t origin, vec3_t angles ); +void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out); + +#endif + diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/bg_misc.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/bg_misc.cpp index 8fd1193..95b9596 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/bg_misc.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/bg_misc.cpp @@ -21,11 +21,13 @@ along with this program; if not, see . =========================================================================== */ -// included in both game dll and client +#define GAME_INCLUDE +#include "../cgame/cg_local.h" #include "g_local.h" #include "bg_public.h" #include "g_items.h" +#include extern weaponData_t weaponData[WP_NUM_WEAPONS]; @@ -645,6 +647,56 @@ void PlayerStateToEntityState( playerState_t *ps, entityState_t *s ) { } +void rotateAboutOrigin(float x, float y, float rotation, vec2_t out) +{ + out[0] = cosf(DEG2RAD(-rotation)) * x + sinf(DEG2RAD(-rotation)) * y; + out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x; +} + +void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out) +{ + vec3_t vrSpace; + VectorSet(vrSpace, in[2], in[0], in[1] ); + + vec2_t r; + rotateAboutOrigin(vrSpace[0], vrSpace[1], cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW], r); + + vrSpace[0] = -r[0]; + vrSpace[1] = -r[1]; + + vec3_t temp; + VectorScale(vrSpace, cg_worldScale.value, temp); + + if (offset) { + VectorAdd(temp, offset, out); + } else { + VectorCopy(temp, out); + } +} + +static void BG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles ) +{ + vec3_t offset; + VectorCopy(in_offset, offset); + offset[1] = 0; // up/down is index 1 in this case + BG_ConvertFromVR(offset, cg.refdef.vieworg, origin); + origin[2] -= (float)g_entities[cg.snap->ps.viewEntity].client->ps.viewheight; + origin[2] += in_position[1] * cg_worldScale.value; + + VectorCopy(in_orientation, angles); + angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]); +} + +void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles ) +{ + BG_CalculateVRPositionInWorld(vr->offhandposition, vr->offhandoffset, vr->offhandangles, origin, angles); +} + +void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles ) +{ + BG_CalculateVRPositionInWorld(vr->weaponposition, vr->weaponoffset, vr->weaponangles, origin, angles); +} + /* ============ BG_PlayerTouchesItem diff --git a/java/com/drbeef/jkquest/GLES3JNIActivity.java b/java/com/drbeef/jkquest/GLES3JNIActivity.java index 034fd95..884d25e 100644 --- a/java/com/drbeef/jkquest/GLES3JNIActivity.java +++ b/java/com/drbeef/jkquest/GLES3JNIActivity.java @@ -40,7 +40,7 @@ import static android.system.Os.setenv; // Load the gles3jni library right away to make sure JNI_OnLoad() gets called as the very first thing. static { - System.loadLibrary( "openjk_ja" ); + System.loadLibrary( "openjk_jo" ); } private static final String TAG = "JKQuest"; @@ -59,16 +59,11 @@ import static android.system.Os.setenv; // Main components protected static GLES3JNIActivity mSingleton; - // Audio - protected static AudioTrack mAudioTrack; - protected static AudioRecord mAudioRecord; public static void initialize() { // The static nature of the singleton and Android quirkyness force us to initialize everything here // Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values mSingleton = null; - mAudioTrack = null; - mAudioRecord = null; } public void shutdown() {