Immersive Cutscene 6DoF

also:
- 6DoF using mounted guns
- Better HUD scaling when Zoomed
This commit is contained in:
Simon 2022-10-30 23:15:58 +00:00
parent b1207a60ca
commit 89f925c373
16 changed files with 64 additions and 51 deletions

View file

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

View file

@ -821,14 +821,12 @@ void setHMDPosition( float x, float y, float z )
{ {
s_useScreen = JKVR_useScreenLayer(); s_useScreen = JKVR_useScreenLayer();
//Record player height on transition //Record player position on transition
playerHeight = y; VectorSet(vr.hmdposition_snap, x, y, z);
VectorCopy(vr.hmdorientation_snap, vr.hmdorientation);
} }
if (!JKVR_useScreenLayer()) VectorSubtract(vr.hmdposition, vr.hmdposition_snap, vr.hmdposition_offset);
{
playerYaw = vr.hmdorientation[YAW];
}
} }
bool isMultiplayer() bool isMultiplayer()
@ -1257,7 +1255,6 @@ void initialize_gl4es();
void JKVR_Init() void JKVR_Init()
{ {
//Initialise all our variables //Initialise all our variables
playerYaw = 0.0f;
remote_movementSideways = 0.0f; remote_movementSideways = 0.0f;
remote_movementForward = 0.0f; remote_movementForward = 0.0f;
remote_movementUp = 0.0f; remote_movementUp = 0.0f;
@ -1751,7 +1748,7 @@ void JKVR_submitFrame()
// Add a simple cylindrical layer // Add a simple cylindrical layer
gAppState.Layers[gAppState.LayerCount++].Cylinder = gAppState.Layers[gAppState.LayerCount++].Cylinder =
BuildCylinderLayer(&gAppState.Scene.CylinderRenderer, BuildCylinderLayer(&gAppState.Scene.CylinderRenderer,
gAppState.Scene.CylinderWidth, gAppState.Scene.CylinderHeight, &tracking, radians(playerYaw) ); gAppState.Scene.CylinderWidth, gAppState.Scene.CylinderHeight, &tracking, radians(vr.hmdorientation_snap[YAW]) );
for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ ) for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ )
{ {

View file

@ -20,11 +20,14 @@ typedef struct {
vec3_t hmdposition; vec3_t hmdposition;
vec3_t hmdposition_last; // Don't use this, it is just for calculating delta! vec3_t hmdposition_last; // Don't use this, it is just for calculating delta!
vec3_t hmdposition_delta; vec3_t hmdposition_delta; // delta since last frame
vec3_t hmdposition_snap; // The position the HMD was in last time the menu was up (snapshot position)
vec3_t hmdposition_offset; // offset from the position the HMD was in last time the menu was up
vec3_t hmdorientation; vec3_t hmdorientation;
vec3_t hmdorientation_last; // Don't use this, it is just for calculating delta! vec3_t hmdorientation_last; // Don't use this, it is just for calculating delta!
vec3_t hmdorientation_delta; vec3_t hmdorientation_delta;
vec3_t hmdorientation_snap;
vec3_t weaponangles_saber; vec3_t weaponangles_saber;
vec3_t weaponangles; vec3_t weaponangles;

View file

@ -33,8 +33,6 @@ typedef enum control_scheme {
extern bool openjk_initialised; extern bool openjk_initialised;
extern long long global_time; extern long long global_time;
extern float playerHeight;
extern float playerYaw;
extern ovrTracking2 tracking; extern ovrTracking2 tracking;
extern int ducked; extern int ducked;
extern vr_client_info_t vr; extern vr_client_info_t vr;

View file

@ -153,7 +153,7 @@ ovrLayerCylinder2 BuildCylinderLayer( ovrRenderer * cylinderRenderer,
const float density = 15000.0f; const float density = 15000.0f;
const float rotateYaw = 0.0f; const float rotateYaw = 0.0f;
const float radius = 10.0f; const float radius = 10.0f;
const ovrVector3f translation = { 0.0f, playerHeight/1.8f, -vr_screen_dist->value }; const ovrVector3f translation = { 0.0f, vr.hmdposition_snap[1]/1.8f, -vr_screen_dist->value };
ovrMatrix4f cylinderTransform = ovrMatrix4f cylinderTransform =
CylinderModelMatrix( textureWidth, textureHeight, translation, CylinderModelMatrix( textureWidth, textureHeight, translation,

View file

@ -49,8 +49,6 @@ float positional_movementSideways;
float positional_movementForward; float positional_movementForward;
bool openjk_initialised; bool openjk_initialised;
long long global_time; long long global_time;
float playerHeight;
float playerYaw;
ovrTracking2 tracking; ovrTracking2 tracking;
int ducked; int ducked;
vr_client_info_t vr; vr_client_info_t vr;

View file

@ -4026,9 +4026,9 @@ static void CG_Draw2D( void )
if ( cg.snap->ps.pm_type == PM_INTERMISSION ) if ( cg.snap->ps.pm_type == PM_INTERMISSION )
{ {
cg.drawingHUD = true; cg.drawingHUD = CG_HUD_SCALED;
CG_DrawIntermission(); CG_DrawIntermission();
cg.drawingHUD = false; cg.drawingHUD = CG_HUD_NORMAL;
return; return;
} }
@ -4048,7 +4048,7 @@ static void CG_Draw2D( void )
} }
//Everything below here needs to be fitted into the visible portion of the display //Everything below here needs to be fitted into the visible portion of the display
cg.drawingHUD = true; cg.drawingHUD = CG_HUD_SCALED;
CG_DrawBatteryCharge(); CG_DrawBatteryCharge();
@ -4060,9 +4060,9 @@ static void CG_Draw2D( void )
// Draw this before the text so that any text won't get clipped off // Draw this before the text so that any text won't get clipped off
if ( !in_camera ) if ( !in_camera )
{ {
cg.drawingHUD = false; cg.drawingHUD = CG_HUD_NORMAL;
CG_DrawZoomMask(); CG_DrawZoomMask();
cg.drawingHUD = true; cg.drawingHUD = CG_HUD_SCALED;
} }
CG_DrawScrollText(); CG_DrawScrollText();
@ -4070,12 +4070,12 @@ static void CG_Draw2D( void )
if ( in_camera ) if ( in_camera )
{//still draw the saber clash flare, but nothing else {//still draw the saber clash flare, but nothing else
cg.drawingHUD = false; cg.drawingHUD = CG_HUD_NORMAL;
CG_SaberClashFlare(); CG_SaberClashFlare();
return; return;
} }
cg.drawingHUD = false; cg.drawingHUD = CG_HUD_NORMAL;
if ( CG_RenderingFromMiscCamera()) if ( CG_RenderingFromMiscCamera())
{ {
// purposely doing an early out when in a misc_camera, change it if needed. // purposely doing an early out when in a misc_camera, change it if needed.
@ -4084,7 +4084,7 @@ static void CG_Draw2D( void )
CG_DrawCenterString(); CG_DrawCenterString();
return; return;
} }
cg.drawingHUD = true; cg.drawingHUD = CG_HUD_SCALED;
if ( (cg.snap->ps.forcePowersActive&(1<<FP_SEE)) ) if ( (cg.snap->ps.forcePowersActive&(1<<FP_SEE)) )
{//force sight is on {//force sight is on

View file

@ -30,10 +30,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 && !vr->scopeengaged)
{ {
float screenXScale = 1.0f / 2.5f; float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
float screenYScale = 1.0f / 2.5f; float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
float xoffset = -20; float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
if (cg.refdef.stereoView == STEREO_LEFT) { if (cg.refdef.stereoView == STEREO_LEFT) {
xoffset *= -1; xoffset *= -1;
} }

View file

@ -292,6 +292,10 @@ typedef struct {
#define CG_OVERRIDE_3RD_PERSON_APH 0x00000040 #define CG_OVERRIDE_3RD_PERSON_APH 0x00000040
#define CG_OVERRIDE_FOV 0x00000080 #define CG_OVERRIDE_FOV 0x00000080
#define CG_HUD_NORMAL 0x00
#define CG_HUD_SCALED 0x01
#define CG_HUD_ZOOM 0x02
typedef struct { typedef struct {
//NOTE: these probably get cleared in save/load!!! //NOTE: these probably get cleared in save/load!!!
int active; //bit-flag field of which overrides are active int active; //bit-flag field of which overrides are active
@ -432,7 +436,7 @@ typedef struct {
int itemPickupTime; int itemPickupTime;
int itemPickupBlendTime; // the pulse around the crosshair is timed seperately int itemPickupBlendTime; // the pulse around the crosshair is timed seperately
bool drawingHUD; int drawingHUD;
float iconHUDPercent; // How far into opening sequence the icon HUD is float iconHUDPercent; // How far into opening sequence the icon HUD is
int iconSelectTime; // How long the Icon HUD has been active int iconSelectTime; // How long the Icon HUD has been active
qboolean iconHUDActive; qboolean iconHUDActive;

View file

@ -83,7 +83,7 @@ void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles );
void BG_CalculateVRSaberPosition( 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_CalculateVROffHandPosition( vec3_t origin, vec3_t angles );
void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out); void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out);
void BG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles ); void BG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles );
#endif #endif

View file

@ -733,14 +733,14 @@ void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
} }
} }
void BG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles ) void BG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles )
{ {
vec3_t offset; vec3_t offset;
VectorCopy(in_offset, offset); VectorCopy(in_offset, offset);
offset[1] = 0; // up/down is index 1 in this case offset[1] = 0; // up/down is index 1 in this case
BG_ConvertFromVR(offset, cg.refdef.vieworg, origin); BG_ConvertFromVR(offset, cg.refdef.vieworg, origin);
origin[2] -= DEFAULT_PLAYER_HEIGHT; origin[2] -= DEFAULT_PLAYER_HEIGHT;
origin[2] += in_position[1] * cg_worldScale.value; origin[2] += (in_position[1] + cg_heightAdjust.value) * cg_worldScale.value;
VectorCopy(in_orientation, angles); VectorCopy(in_orientation, angles);
angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]); angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]);

View file

@ -1851,7 +1851,8 @@ static void CG_DrawCrosshair3D(int type) // 0 - force, 1 - weapons
if ( type == 1 && (cg.snap->ps.weapon == WP_NONE || if ( type == 1 && (cg.snap->ps.weapon == WP_NONE ||
cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_SABER ||
cg.snap->ps.weapon == WP_STUN_BATON )) cg.snap->ps.weapon == WP_STUN_BATON ||
cg.snap->ps.weapon == WP_THERMAL ))
{ {
return; return;
} }
@ -2531,9 +2532,9 @@ static void CG_Draw2D( void )
if ( cg.snap->ps.pm_type == PM_INTERMISSION ) if ( cg.snap->ps.pm_type == PM_INTERMISSION )
{ {
cg.drawingHUD = true; cg.drawingHUD = CG_HUD_SCALED;
CG_DrawIntermission(); CG_DrawIntermission();
cg.drawingHUD = false; cg.drawingHUD = CG_HUD_NORMAL;
return; return;
} }
@ -2549,29 +2550,32 @@ static void CG_Draw2D( void )
CGCam_DrawWideScreen(); CGCam_DrawWideScreen();
} }
cg.drawingHUD = true; cg.drawingHUD = CG_HUD_SCALED;
CG_DrawBatteryCharge(); CG_DrawBatteryCharge();
// Draw this before the text so that any text won't get clipped off // Draw this before the text so that any text won't get clipped off
if ( !in_camera ) if ( !in_camera )
{ {
cg.drawingHUD = false; cg.drawingHUD = CG_HUD_ZOOM;
CG_DrawZoomMask(); CG_DrawZoomMask();
cg.drawingHUD = true; cg.drawingHUD = CG_HUD_SCALED;
} }
CG_DrawScrollText(); CG_DrawScrollText();
CG_DrawCaptionText();
if (!vr->immersive_cinematics) {
CG_DrawCaptionText();
}
if ( in_camera ) if ( in_camera )
{//still draw the saber clash flare, but nothing else {//still draw the saber clash flare, but nothing else
cg.drawingHUD = false; cg.drawingHUD = CG_HUD_NORMAL;
CG_SaberClashFlare(); CG_SaberClashFlare();
return; return;
} }
cg.drawingHUD = false; cg.drawingHUD = CG_HUD_NORMAL;
if ( CG_RenderingFromMiscCamera()) if ( CG_RenderingFromMiscCamera())
{ {
// purposely doing an early out when in a misc_camera, change it if needed. // purposely doing an early out when in a misc_camera, change it if needed.
@ -2580,7 +2584,7 @@ static void CG_Draw2D( void )
CG_DrawCenterString(); CG_DrawCenterString();
return; return;
} }
cg.drawingHUD = true; cg.drawingHUD = CG_HUD_SCALED;
// don't draw any status if dead // don't draw any status if dead
if ( cg.snap->ps.stats[STAT_HEALTH] > 0 ) if ( cg.snap->ps.stats[STAT_HEALTH] > 0 )
@ -2720,7 +2724,7 @@ static void CG_Draw2D( void )
} }
} }
cg.drawingHUD = false; cg.drawingHUD = CG_HUD_NORMAL;
} }
@ -2774,6 +2778,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
in_misccamera = ( !Q_stricmp( "misc_camera", g_entities[cg.snap->ps.viewEntity].classname )) in_misccamera = ( !Q_stricmp( "misc_camera", g_entities[cg.snap->ps.viewEntity].classname ))
|| ( !Q_stricmp( "NPC", g_entities[cg.snap->ps.viewEntity].classname )); || ( !Q_stricmp( "NPC", g_entities[cg.snap->ps.viewEntity].classname ));
bool in_turret = ( cg_entities[cg.snap->ps.clientNum].currentState.eFlags & EF_LOCKED_TO_WEAPON );
cg.refdef.worldscale = cg_worldScale.value; cg.refdef.worldscale = cg_worldScale.value;
if (!in_camera && if (!in_camera &&
@ -2785,6 +2790,11 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis); AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
} }
if ((in_camera && vr->immersive_cinematics) || in_turret)
{
BG_ConvertFromVR(vr->hmdposition_offset, cg.refdef.vieworg, cg.refdef.vieworg);
}
// clear around the rendered view if sized down // clear around the rendered view if sized down
CG_TileClear(); CG_TileClear();
@ -2799,8 +2809,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
cgi_R_LAGoggles(); cgi_R_LAGoggles();
} }
bool in_turret = ( cg_entities[cg.snap->ps.clientNum].currentState.eFlags & EF_LOCKED_TO_WEAPON ); if (!in_turret && !in_misccamera && !in_camera) {
if (!in_turret && !in_misccamera && (!in_camera || vr->immersive_cinematics)) {
//Vertical Positional Movement //Vertical Positional Movement
cg.refdef.vieworg[2] -= DEFAULT_PLAYER_HEIGHT; cg.refdef.vieworg[2] -= DEFAULT_PLAYER_HEIGHT;
cg.refdef.vieworg[2] += (vr->hmdposition[1] + cg_heightAdjust.value) * cg_worldScale.value; cg.refdef.vieworg[2] += (vr->hmdposition[1] + cg_heightAdjust.value) * cg_worldScale.value;

View file

@ -29,10 +29,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 && !vr->scopeengaged)
{ {
float screenXScale = 1.0f / 2.5f; float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
float screenYScale = 1.0f / 2.5f; float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
float xoffset = -20; float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
if (cg.refdef.stereoView == STEREO_LEFT) { if (cg.refdef.stereoView == STEREO_LEFT) {
xoffset *= -1; xoffset *= -1;
} }

View file

@ -282,6 +282,10 @@ typedef struct {
#define CG_OVERRIDE_3RD_PERSON_APH 0x00000040 #define CG_OVERRIDE_3RD_PERSON_APH 0x00000040
#define CG_OVERRIDE_FOV 0x00000080 #define CG_OVERRIDE_FOV 0x00000080
#define CG_HUD_NORMAL 0x00
#define CG_HUD_SCALED 0x01
#define CG_HUD_ZOOM 0x02
typedef struct { typedef struct {
//NOTE: these probably get cleared in save/load!!! //NOTE: these probably get cleared in save/load!!!
int active; //bit-flag field of which overrides are active int active; //bit-flag field of which overrides are active
@ -429,7 +433,7 @@ typedef struct {
int itemPickupTime; int itemPickupTime;
int itemPickupBlendTime; // the pulse around the crosshair is timed seperately int itemPickupBlendTime; // the pulse around the crosshair is timed seperately
bool drawingHUD; int drawingHUD;
float iconHUDPercent; // How far into opening sequence the icon HUD is float iconHUDPercent; // How far into opening sequence the icon HUD is
int iconSelectTime; // How long the Icon HUD has been active int iconSelectTime; // How long the Icon HUD has been active
qboolean iconHUDActive; qboolean iconHUDActive;

View file

@ -83,7 +83,7 @@ void BG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles );
void BG_CalculateVRSaberPosition( 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_CalculateVROffHandPosition( vec3_t origin, vec3_t angles );
void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out); void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out);
void BG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles ); void BG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles );
#endif #endif

View file

@ -674,14 +674,14 @@ void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
} }
} }
void BG_CalculateVRPositionInWorld( vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles ) void BG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset, vec3_t in_orientation, vec3_t origin, vec3_t angles )
{ {
vec3_t offset; vec3_t offset;
VectorCopy(in_offset, offset); VectorCopy(in_offset, offset);
offset[1] = 0; // up/down is index 1 in this case offset[1] = 0; // up/down is index 1 in this case
BG_ConvertFromVR(offset, cg.refdef.vieworg, origin); BG_ConvertFromVR(offset, cg.refdef.vieworg, origin);
origin[2] -= DEFAULT_PLAYER_HEIGHT; origin[2] -= DEFAULT_PLAYER_HEIGHT;
origin[2] += in_position[1] * cg_worldScale.value; origin[2] += (in_position[1] + cg_heightAdjust.value) * cg_worldScale.value;
VectorCopy(in_orientation, angles); VectorCopy(in_orientation, angles);
angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]); angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]);