Made the victory podium scenes full VR

This commit is contained in:
Simon 2022-02-06 15:31:17 +00:00
parent bd28df0c91
commit 3678133c67
13 changed files with 169 additions and 52 deletions

View File

@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.ioq3quest"
android:installLocation="preferExternal"
android:versionCode="10"
android:versionName="0.7.0">
android:versionCode="11"
android:versionName="0.7.1">
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
<uses-feature android:glEsVersion="0x00030001" />

View File

@ -1948,6 +1948,11 @@ static void CG_DrawCrosshair3D(void)
return;
}
if (cg.snap->ps.pm_type == PM_INTERMISSION)
{
return;
}
if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR) {
return;
}

View File

@ -651,6 +651,17 @@ static int CG_CalcViewValues( void ) {
static float hmdYaw = 0;
if ( ps->pm_type == PM_INTERMISSION ) {
VectorCopy( ps->origin, cg.refdef.vieworg );
static vec3_t mins = { -1, -1, -1 };
static vec3_t maxs = { 1, 1, 1 };
trace_t trace;
vec3_t forward;
vec3_t end;
AngleVectors(ps->viewangles, forward, NULL, NULL);
VectorMA(ps->origin, -80, forward, end);
CG_Trace( &trace, ps->origin, mins, maxs, end, cg.predictedPlayerState.clientNum, MASK_SOLID );
VectorCopy(trace.endpos, cg.refdef.vieworg);
VectorCopy(cgVR->hmdorientation, cg.refdefViewAngles);
cg.refdefViewAngles[YAW] += (ps->viewangles[YAW] - hmdYaw);
AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );

View File

@ -22,6 +22,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc
#include "client.h"
#include "../vr/vr_clientinfo.h"
extern vr_clientinfo_t vr;
qboolean scr_initialized; // ready to draw
@ -70,18 +73,39 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h ) {
// scale for screen sizes
xscale = cls.glconfig.vidWidth / 640.0;
yscale = cls.glconfig.vidHeight / 480.0;
if ( x ) {
if (vr.virtual_screen) {
if (x) {
*x *= xscale;
}
if ( y ) {
if (y) {
*y *= yscale;
}
if ( w ) {
if (w) {
*w *= xscale;
}
if ( h ) {
if (h) {
*h *= yscale;
}
} else {
float screenXScale = xscale / 2.75f;
float screenYScale = yscale / 2.25f;
if (x) {
*x *= screenXScale;
*x += (cls.glconfig.vidWidth - (640 * screenXScale)) / 2.0f;
}
if (y) {
*y *= screenYScale;
*y += (cls.glconfig.vidHeight - (480 * screenYScale)) / 2.0f;
}
if (w) {
*w *= screenXScale;
}
if (h) {
*h *= screenYScale;
}
}
}
/*

View File

@ -23,8 +23,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "client.h"
#include "../botlib/botlib.h"
#include "../vr/vr_clientinfo.h"
extern botlib_export_t *botlib_export;
extern vr_clientinfo_t vr;
vm_t *uivm;
@ -1140,6 +1142,12 @@ void CL_InitUI( void ) {
// init for this gamestate
VM_Call( uivm, UI_INIT, (clc.state >= CA_AUTHORIZING && clc.state < CA_ACTIVE) );
}
{
long val = (long)(&vr);
int *ptr = (int*)(&val); //HACK!!
VM_Call( uivm, UI_SET_VR_CLIENT_INFO, ptr[0], ptr[1] );
}
}
#ifndef STANDALONE

View File

@ -26,10 +26,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
User interface building blocks and support functions.
**********************************************************************/
#include "ui_local.h"
#include "../vr/vr_clientinfo.h"
uiStatic_t uis;
qboolean m_entersound; // after a frame, so caching won't disrupt the sound
extern vr_clientinfo_t *uiVR;
void QDECL Com_Error( int level, const char *error, ... ) {
va_list argptr;
char text[1024];
@ -52,6 +55,42 @@ void QDECL Com_Printf( const char *msg, ... ) {
trap_Print( text );
}
float UI_GetXScale()
{
if (uiVR == NULL || uiVR->virtual_screen) {
return uis.xscale;
} else {
return uis.xscale / 2.75f;
}
}
float UI_GetYScale()
{
if (uiVR == NULL || uiVR->virtual_screen) {
return uis.yscale;
} else {
return uis.yscale / 3.25f;
}
}
float UI_GetXOffset()
{
if (uiVR == NULL || uiVR->virtual_screen) {
return 0;
} else {
return (uis.glconfig.vidWidth - (640 * UI_GetXScale())) / 2.0f;
}
}
float UI_GetYOffset()
{
if (uiVR == NULL || uiVR->virtual_screen) {
return 0;
} else {
return (uis.glconfig.vidHeight - (480 * UI_GetYScale())) / 2.0f;
}
}
/*
=================
UI_ClampCvar
@ -351,15 +390,15 @@ static void UI_DrawBannerString2( int x, int y, const char* str, vec4_t color )
// draw the colored text
trap_R_SetColor( color );
ax = x * uis.xscale + uis.bias;
ay = y * uis.yscale;
ax = x * UI_GetXScale() + uis.bias + UI_GetXOffset();
ay = y * UI_GetYScale() + UI_GetYOffset();
s = str;
while ( *s )
{
ch = *s & 127;
if ( ch == ' ' ) {
ax += ((float)PROPB_SPACE_WIDTH + (float)PROPB_GAP_WIDTH)* uis.xscale;
ax += ((float)PROPB_SPACE_WIDTH + (float)PROPB_GAP_WIDTH)* UI_GetXScale();
}
else if ( ch >= 'A' && ch <= 'Z' ) {
ch -= 'A';
@ -367,10 +406,10 @@ static void UI_DrawBannerString2( int x, int y, const char* str, vec4_t color )
frow = (float)propMapB[ch][1] / 256.0f;
fwidth = (float)propMapB[ch][2] / 256.0f;
fheight = (float)PROPB_HEIGHT / 256.0f;
aw = (float)propMapB[ch][2] * uis.xscale;
ah = (float)PROPB_HEIGHT * uis.yscale;
aw = (float)propMapB[ch][2] * UI_GetXScale();
ah = (float)PROPB_HEIGHT * UI_GetYScale();
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, uis.charsetPropB );
ax += (aw + (float)PROPB_GAP_WIDTH * uis.xscale);
ax += (aw + (float)PROPB_GAP_WIDTH * UI_GetXScale());
}
s++;
}
@ -461,27 +500,27 @@ static void UI_DrawProportionalString2( int x, int y, const char* str, vec4_t co
// draw the colored text
trap_R_SetColor( color );
ax = x * uis.xscale + uis.bias;
ay = y * uis.yscale;
ax = x * UI_GetXScale() + uis.bias + UI_GetXOffset();
ay = y * UI_GetYScale() + UI_GetYOffset();
s = str;
while ( *s )
{
ch = *s & 127;
if ( ch == ' ' ) {
aw = (float)PROP_SPACE_WIDTH * uis.xscale * sizeScale;
aw = (float)PROP_SPACE_WIDTH * UI_GetXScale() * sizeScale;
}
else if ( propMap[ch][2] != -1 ) {
fcol = (float)propMap[ch][0] / 256.0f;
frow = (float)propMap[ch][1] / 256.0f;
fwidth = (float)propMap[ch][2] / 256.0f;
fheight = (float)PROP_HEIGHT / 256.0f;
aw = (float)propMap[ch][2] * uis.xscale * sizeScale;
ah = (float)PROP_HEIGHT * uis.yscale * sizeScale;
aw = (float)propMap[ch][2] * UI_GetXScale() * sizeScale;
ah = (float)PROP_HEIGHT * UI_GetYScale() * sizeScale;
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol+fwidth, frow+fheight, charset );
}
ax += (aw + (float)PROP_GAP_WIDTH * uis.xscale * sizeScale);
ax += (aw + (float)PROP_GAP_WIDTH * UI_GetXScale() * sizeScale);
s++;
}
@ -656,10 +695,10 @@ static void UI_DrawString2( int x, int y, const char* str, vec4_t color, int cha
// draw the colored text
trap_R_SetColor( color );
ax = x * uis.xscale + uis.bias;
ay = y * uis.yscale;
aw = charw * uis.xscale;
ah = charh * uis.yscale;
ax = x * UI_GetXScale() + uis.bias + UI_GetXOffset();
ay = y * UI_GetYScale() + UI_GetYOffset();
aw = charw * UI_GetXScale();
ah = charh * UI_GetYScale();
s = str;
while ( *s )
@ -883,7 +922,7 @@ void UI_MouseEvent( int dx, int dy )
return;
// convert X bias to 640 coords
bias = uis.bias / uis.xscale;
bias = uis.bias / UI_GetXScale();
// update mouse screen position
uis.cursorx += dx;
@ -1078,12 +1117,14 @@ void UI_Init( void ) {
// for 640x480 virtualized screen
uis.xscale = uis.glconfig.vidWidth * (1.0/640.0);
uis.yscale = uis.glconfig.vidHeight * (1.0/480.0);
if ( uis.glconfig.vidWidth * 480 > uis.glconfig.vidHeight * 640 ) {
/* if ( uis.glconfig.vidWidth * 480 > uis.glconfig.vidHeight * 640 ) {
// wide screen
uis.bias = 0.5 * ( uis.glconfig.vidWidth - ( uis.glconfig.vidHeight * (640.0/480.0) ) );
uis.xscale = uis.yscale;
UI_GetXScale() = UI_GetYScale();
}
else {
else
*/
{
// no wide screen
uis.bias = 0;
}
@ -1104,10 +1145,10 @@ Adjusted for resolution and screen aspect ratio
*/
void UI_AdjustFrom640( float *x, float *y, float *w, float *h ) {
// expect valid pointers
*x = *x * uis.xscale + uis.bias;
*y *= uis.yscale;
*w *= uis.xscale;
*h *= uis.yscale;
*x = *x * UI_GetXScale() + uis.bias + UI_GetXOffset();
*y = *y * UI_GetYScale() + UI_GetYOffset();
*w *= UI_GetXScale();
*h *= UI_GetYScale();
}
void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ) {

View File

@ -30,7 +30,9 @@ USER INTERFACE MAIN
#include "ui_local.h"
#include "../vr/vr_clientinfo.h"
vr_clientinfo_t *uiVR = NULL;
/*
================
@ -80,6 +82,13 @@ Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, i
return 0;
case UI_HASUNIQUECDKEY: // mod authors need to observe this
return qtrue; // change this to qfalse for mods!
case UI_SET_VR_CLIENT_INFO:{
int ptr[2] = {arg0, arg1};
uiVR = (vr_clientinfo_t *) (*(long*)(ptr));
return 0;
}
}
return -1;

View File

@ -447,7 +447,7 @@ void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal )
inv_denom = DotProduct( normal, normal );
#ifndef Q3_VM
assert( Q_fabs(inv_denom) != 0.0f ); // zero vectors get here
// assert( Q_fabs(inv_denom) != 0.0f ); // zero vectors get here
#endif
inv_denom = 1.0f / inv_denom;

View File

@ -739,7 +739,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
// FIXME: HUGE hack
if (glRefConfig.framebufferObject)
{
FBO_Bind(backEnd.framePostProcessed ? NULL : tr.renderFbo);
FBO_Bind(tr.renderFbo);
}
RB_SetGL2D();

View File

@ -182,10 +182,12 @@ typedef enum {
UI_DRAW_CONNECT_SCREEN,
// void UI_DrawConnectScreen( qboolean overlay );
UI_HASUNIQUECDKEY
UI_HASUNIQUECDKEY,
// if !overlay, the background will be drawn, otherwise it will be
// overlayed over whatever the cgame has drawn.
// a GetClientState syscall will be made to get the current strings
UI_SET_VR_CLIENT_INFO
} uiExport_t;
#endif

View File

@ -23,12 +23,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// string allocation/management
#include "ui_shared.h"
#include "../vr/vr_clientinfo.h"
#define SCROLL_TIME_START 500
#define SCROLL_TIME_ADJUST 150
#define SCROLL_TIME_ADJUSTOFFSET 40
#define SCROLL_TIME_FLOOR 20
extern vr_clientinfo_t *uiVR;
typedef struct scrollInfo_s {
int nextScrollTime;
int nextAdjustTime;
@ -3641,11 +3644,25 @@ qboolean Item_Bind_HandleKey(itemDef_t *item, int key, qboolean down) {
void AdjustFrom640(float *x, float *y, float *w, float *h) {
//*x = *x * DC->scale + DC->bias;
if (uiVR == NULL || uiVR->virtual_screen) {
// expect valid pointers
*x *= DC->xscale;
*y *= DC->yscale;
*w *= DC->xscale;
*h *= DC->yscale;
} else {
float screenXScale = DC->xscale / 2.75f;
float screenYScale = DC->yscale / 2.75f;
*x *= screenXScale;
*y *= screenYScale;
*w *= screenXScale;
*h *= screenYScale;
*x += (DC->glconfig.vidWidth - (640 * screenXScale)) / 2.0f;
*y += (DC->glconfig.vidHeight - (480 * screenYScale)) / 2.0f;
}
}
void Item_Model_Paint(itemDef_t *item) {

View File

@ -93,13 +93,13 @@ engine_t* VR_GetEngine( void ) {
bool VR_useScreenLayer( void )
{
//intermission is never full screen
/* if ( cl.snap.ps.pm_type == PM_INTERMISSION )
if ( cl.snap.ps.pm_type == PM_INTERMISSION )
{
return qfalse;
}
*/
int keyCatcher = Key_GetCatcher( );
return (bool)( clc.state != CA_ACTIVE ||
return (bool)( clc.state == CA_CINEMATIC ||
( keyCatcher & (KEYCATCH_UI | KEYCATCH_CONSOLE) ));
}
//#endif

View File

@ -5,6 +5,7 @@
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
#include "../client/keycodes.h"
#include "../client/client.h"
#include "vr_base.h"
#include "../VrApi/Include/VrApi_Input.h"
#include "../VrApi/Include/VrApi_Helpers.h"
@ -253,7 +254,8 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
{
vrController_t* controller = isRightController == qtrue ? &rightController : &leftController;
if (vr.virtual_screen)
if (vr.virtual_screen ||
cl.snap.ps.pm_type == PM_INTERMISSION)
{
const float x = joystickX * 5.0;
const float y = joystickY * -5.0;
@ -342,7 +344,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
{
vrController_t* controller = isRightController == qtrue ? &rightController : &leftController;
if (isRightController == qfalse) {
{
if ((buttons & ovrButton_Enter) && !(controller->buttons & ovrButton_Enter)) {
Com_QueueEvent(in_vrEventTime, SE_KEY, K_ESCAPE, qtrue, 0, NULL);
} else if (!(buttons & ovrButton_Enter) && (controller->buttons & ovrButton_Enter)) {
@ -372,9 +374,7 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
}
if ((buttons & ovrButton_X) && !(controller->buttons & ovrButton_X)) {
#ifdef DEBUG
sendButtonActionSimple("fraglimit 1");
#endif
Com_QueueEvent(in_vrEventTime, SE_KEY, K_PAD0_X, qtrue, 0, NULL);
} else if (!(buttons & ovrButton_X) && (controller->buttons & ovrButton_X)) {
Com_QueueEvent(in_vrEventTime, SE_KEY, K_PAD0_X, qfalse, 0, NULL);