diff --git a/Projects/Android/AndroidManifest.xml b/Projects/Android/AndroidManifest.xml index 0fe0142..eb1d0b9 100644 --- a/Projects/Android/AndroidManifest.xml +++ b/Projects/Android/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="11" + android:versionName="0.0.17" android:installLocation="auto" > diff --git a/Projects/Android/jni/Doom3Quest/VrCommon.h b/Projects/Android/jni/Doom3Quest/VrCommon.h index 54f17dc..161bcf8 100644 --- a/Projects/Android/jni/Doom3Quest/VrCommon.h +++ b/Projects/Android/jni/Doom3Quest/VrCommon.h @@ -26,8 +26,6 @@ extern "C" { #define ALOGV(...) #endif -#define TIC_RATE 60 - float screenYaw; float radians(float deg); diff --git a/Projects/Android/jni/Doom3Quest/VrInputDefault.c b/Projects/Android/jni/Doom3Quest/VrInputDefault.c index 89c1836..0b99988 100644 --- a/Projects/Android/jni/Doom3Quest/VrInputDefault.c +++ b/Projects/Android/jni/Doom3Quest/VrInputDefault.c @@ -59,6 +59,7 @@ extern bool inMenu; extern bool inGameGuiActive; extern bool objectiveSystemActive; extern bool inCinematic; +const int USERCMD_HZ = 60; void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking, @@ -360,6 +361,7 @@ void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDomina pVRClientInfo->offhandoffset[2] = pOff->HeadPose.Pose.Position.z - pVRClientInfo->hmdposition[2]; vec3_t rotation = {0}; + rotation[PITCH] = -45; QuatToYawPitchRoll(pOff->HeadPose.Pose.Orientation, rotation, pVRClientInfo->offhandangles); if (vr_walkdirection == 0) { @@ -375,10 +377,9 @@ void HandleInput_Default( int controlscheme, ovrInputStateTrackedRemote *pDomina { //Adjust positional factor for this sample based on how long the last frame took, it should //approximately even out the positional movement on a per frame basis (especially when fps is much lower than 60) - //NOTE: it'll never be above ~60fps since we use com_fixedTic of "-1" static float lastSampleTime = 0; float sampleTime = Sys_Milliseconds(); - float vr_positional_factor = 2400.0f * ((1000.0f / TIC_RATE) / (sampleTime-lastSampleTime)); + float vr_positional_factor = 2400.0f * ((1000.0f / USERCMD_HZ) / (sampleTime-lastSampleTime)); lastSampleTime = sampleTime; //This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp index fa8f5e1..a817ad2 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Player.cpp @@ -1043,6 +1043,9 @@ idPlayer::idPlayer() { flashlightModelDefHandle = -1; + hudHandle = -1; + memset( &hudEntity, 0, sizeof( hudEntity ) ); + skin = NULL; powerUpSkin = NULL; baseSkinName = ""; @@ -1422,6 +1425,12 @@ void idPlayer::Init( void ) { SetupFlashlightHolster(); SetupLaserSight(); + + // re-init hud model + memset( &hudEntity, 0, sizeof( hudEntity ) ); + hudEntity.hModel = renderModelManager->FindModel( "/models/mapobjects/hud.lwo" ); + hudEntity.customShader = declManager->FindMaterial( "vr/hud" ); + hudEntity.weaponDepthHack = true; } /* @@ -2103,6 +2112,12 @@ void idPlayer::Restore( idRestoreGame *savefile ) { SetupFlashlightHolster(); SetupLaserSight(); + + // re-init hud model + memset( &hudEntity, 0, sizeof( hudEntity ) ); + hudEntity.hModel = renderModelManager->FindModel( "/models/mapobjects/hud.lwo" ); + hudEntity.customShader = declManager->FindMaterial( "vr/hud" ); + hudEntity.weaponDepthHack = true; } void idPlayer::SetupLaserSight() @@ -2688,6 +2703,94 @@ void idPlayer::DrawHUD( idUserInterface *_hud ) { //cursor->Redraw( gameLocal.realClientTime ); } } + + renderSystem->CaptureRenderToImage( "_hudImage" ); +} + + +/* +============== +Koz +idPlayer::UpdateVrHud +============== +*/ +void idPlayer::UpdateVrHud() +{ + static idVec3 hudOrigin; + static idMat3 hudAxis; + float hudPitch; + + if (pVRClientInfo != nullptr) + + // update the hud model + if ( (pVRClientInfo == nullptr) || !pVRClientInfo->visible_hud || gameLocal.inCinematic) + { + // hide it + hudEntity.allowSurfaceInViewID = -1; + } + else + { + hudEntity.allowSurfaceInViewID = entityNumber + 1; + + { + hudPitch = 10.0f; + + float yaw; + { + // CalculateRenderView must have been called first + const idVec3 &viewOrigin = firstPersonViewOrigin; + const idMat3 &viewAxis = firstPersonViewAxis; + + if (pVRClientInfo) + { + idAngles angles; + float *pAngles = pVRClientInfo->offhandangles; + angles.pitch = pVRClientInfo->offhandangles[PITCH]; + angles.yaw = viewAngles.yaw + + (pVRClientInfo->offhandangles[YAW] - pVRClientInfo->hmdorientation[YAW]); + angles.roll = pVRClientInfo->offhandangles[ROLL]; + + hudAxis = angles.ToMat3(); + + idVec3 offpos( -pVRClientInfo->offhandoffset[2], + -pVRClientInfo->offhandoffset[0], + pVRClientInfo->offhandoffset[1]); + + idAngles a(0, viewAngles.yaw - pVRClientInfo->hmdorientation[YAW], 0); + offpos *= a.ToMat3(); + offpos *= cvarSystem->GetCVarFloat( "vr_worldscale" ); + + { + hudOrigin = viewOrigin + offpos; + } + } + +// GetViewPos( hudOrigin, hudAxis ); +// yaw = viewAngles.yaw; + } + //hudAxis = idAngles( hudPitch, yaw, 0.0f ).ToMat3(); + + //hudOrigin += hudAxis[0] * 24.0f;//vr_hudPosDis.GetFloat(); + hudOrigin += hudAxis[1] * -8.0f; + hudOrigin += hudAxis[2] * 16.0f; + } + + hudAxis *= 0.7; + + hudEntity.axis = hudAxis; + hudEntity.origin = hudOrigin; + hudEntity.weaponDepthHack = true; + + } + + if ( hudHandle == -1 ) + { + hudHandle = gameRenderWorld->AddEntityDef( &hudEntity ); + } + else + { + gameRenderWorld->UpdateEntityDef( hudHandle, &hudEntity ); + } } /* @@ -6367,10 +6470,7 @@ void idPlayer::Think( void ) { pVRClientInfo->weaponid = -1; } cvarSystem->SetCVarBool("vr_weapon_stabilised", pVRClientInfo->weapon_stabilised); - pVRClientInfo->velocitytriggered = ( - currentWeapon == WEAPON_FISTS || - currentWeapon == WEAPON_FLASHLIGHT); - + pVRClientInfo->velocitytriggered = currentWeapon == WEAPON_FLASHLIGHT; pVRClientInfo->pistol = currentWeapon == WEAPON_PISTOL; } @@ -6511,6 +6611,8 @@ void idPlayer::Think( void ) { UpdateLaserSight(); + UpdateVrHud(); + UpdateDeathSkin( false ); if ( gameLocal.isMultiplayer ) { diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Player.h b/Projects/Android/jni/d3es-multithread-master/neo/game/Player.h index 7fb0e90..f898c33 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Player.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Player.h @@ -237,6 +237,9 @@ public: renderEntity_t flashlightRenderEntity; // used to present a model to the renderer qhandle_t flashlightModelDefHandle; // handle to static renderer model + renderEntity_t hudEntity; + qhandle_t hudHandle; + bool noclip; bool godmode; @@ -416,9 +419,9 @@ public: virtual void UpdateFlashlightHolster(); virtual void SetupLaserSight(); virtual void UpdateLaserSight( ); + virtual void UpdateVrHud(); - - void Kill( bool delayRespawn, bool nodamage ); + void Kill( bool delayRespawn, bool nodamage ); virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location ); void StartFxOnBone(const char *fx, const char *bone); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/PlayerView.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/PlayerView.cpp index c9e22b0..5b07172 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/PlayerView.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/PlayerView.cpp @@ -462,6 +462,8 @@ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view ) return; } + player->DrawHUD(hud); + // place the sound origin for the player gameSoundWorld->PlaceListener( view->vieworg, view->viewaxis, player->entityNumber + 1, gameLocal.time, hud ? hud->State().GetString( "location" ) : "Undefined" ); @@ -501,16 +503,6 @@ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view ) } } - vrClientInfo *pVRClientInfo = player->GetVRClientInfo(); - if (pVRClientInfo != nullptr && - pVRClientInfo->visible_hud) { - cvarSystem->SetCVarBool("vr_hud", true); - - player->DrawHUD(hud); - - cvarSystem->SetCVarBool("vr_hud", false); - } - // armor impulse feedback float armorPulse = ( gameLocal.time - player->lastArmorPulse ) / 250.0f; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/Image.h b/Projects/Android/jni/d3es-multithread-master/neo/renderer/Image.h index e893a5b..bf30705 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/Image.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/Image.h @@ -406,6 +406,8 @@ public: idImage * specular2DTableImage; // 2D intensity texture with our specular function with variable specularity idImage * borderClampImage; // white inside, black outside + idImage* hudImage; + //-------------------------------------------------------- idImage * AllocImage( const char *name ); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/Image_init.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/Image_init.cpp index c3261ba..29586e8 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/Image_init.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/Image_init.cpp @@ -369,6 +369,18 @@ static void R_RGBA8Image( idImage *image ) { TF_DEFAULT, false, TR_REPEAT, TD_HIGH_QUALITY ); } +// Koz begin +// used for Hud and PDA surfaces in VR +static void R_VRSurfaceImage( idImage* image ) +{ + byte *data = (byte*)malloc(1024 * 1024 * 4); + + memset( data, 0, sizeof( data ) ); + + image->GenerateImage( (byte *)data, 1024, 1024, + TF_DEFAULT, false, TR_CLAMP, TD_HIGH_QUALITY ); +} + #if 0 static void R_RGB8Image( idImage *image ) { byte data[DEFAULT_SIZE][DEFAULT_SIZE][4]; @@ -1782,6 +1794,9 @@ void idImageManager::Init() { scratchCubeMapImage = ImageFromFunction("_scratchCubeMap", makeNormalizeVectorCubeMap ); currentRenderImage = ImageFromFunction("_currentRender", R_RGBA8Image ); + hudImage = ImageFromFunction( "_hudImage", R_VRSurfaceImage ); // R_RGBA8Image ); + + cmdSystem->AddCommand( "reloadImages", R_ReloadImages_f, CMD_FL_RENDERER, "reloads images" ); cmdSystem->AddCommand( "listImages", R_ListImages_f, CMD_FL_RENDERER, "lists images" ); cmdSystem->AddCommand( "combineCubeImages", R_CombineCubeImages_f, CMD_FL_RENDERER, "combines six images for roq compression" ); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/ui/Window.cpp b/Projects/Android/jni/d3es-multithread-master/neo/ui/Window.cpp index 7abaa7a..98faa6a 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/ui/Window.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/ui/Window.cpp @@ -1197,18 +1197,9 @@ idWindow::Redraw ================ */ -enum eScalingType { - NONE, - SCALETO43, - VRHUD -}; - void idWindow::Redraw(float x, float y) { idStr str; - static int recursiveCount = 0; - recursiveCount++; - if (r_skipGuiShaders.GetInteger() == 1 || dc == NULL ) { return; } @@ -1223,32 +1214,19 @@ void idWindow::Redraw(float x, float y) { return; } - eScalingType scalingType = NONE; - // DG: allow scaling menus to 4:3 + bool fixupFor43 = false; if ( flags & WIN_DESKTOP ) { // only scale desktop windows (will automatically scale its sub-windows) // that EITHER have the scaleto43 flag set OR are fullscreen menus and r_scaleMenusTo43 is 1 if( (flags & WIN_SCALETO43) || ((flags & WIN_MENUGUI) && r_scaleMenusTo43.GetBool()) ) { - scalingType = SCALETO43; + fixupFor43 = true; dc->SetMenuScaleFix(true); } } - if (scalingType == NONE) { - bool scaledHUDForVR = cvarSystem->GetCVarBool("vr_hud"); - if (scaledHUDForVR) { - scalingType = VRHUD; - - //Only set this on the first call - if (recursiveCount == 1) { - dc->SetMenuScaleForVR(true); - } - } - } - if ( flags & WIN_SHOWTIME ) { dc->DrawText(va(" %0.1f seconds\n%s", (float)(time - timeLine) / 1000, gui->State().GetString("name")), 0.35f, 0, dc->colorWhite, idRectangle(100, 0, 80, 80), false); } @@ -1261,14 +1239,7 @@ void idWindow::Redraw(float x, float y) { } if (!visible) { - if (scalingType == SCALETO43) { // DG: gotta reset that before returning this function - dc->SetMenuScaleFix(false); - } - - recursiveCount--; - if (scalingType == VRHUD && - recursiveCount == 0) - { + if (fixupFor43) { // DG: gotta reset that before returning this function dc->SetMenuScaleFix(false); } return; @@ -1278,8 +1249,8 @@ void idWindow::Redraw(float x, float y) { SetFont(); //if (flags & WIN_DESKTOP) { - // see if this window forces a new aspect ratio - dc->SetSize(forceAspectWidth, forceAspectHeight); + // see if this window forces a new aspect ratio + dc->SetSize(forceAspectWidth, forceAspectHeight); //} //FIXME: go to screen coord tracking @@ -1339,14 +1310,7 @@ void idWindow::Redraw(float x, float y) { dc->EnableClipping(true); } - if (scalingType == SCALETO43) { // DG: gotta reset that before returning this function - dc->SetMenuScaleFix(false); - } - - recursiveCount--; - if (scalingType == VRHUD && - recursiveCount == 0) - { + if (fixupFor43) { // DG: gotta reset that before returning this function dc->SetMenuScaleFix(false); } diff --git a/assets/pak299/materials/vr.mtr b/assets/pak299/materials/vr.mtr new file mode 100644 index 0000000..e625b58 --- /dev/null +++ b/assets/pak299/materials/vr.mtr @@ -0,0 +1,14 @@ + + +vr/hud + +{ + qer_editorimage textures/zaphod/shotgun_laser.TGA + translucent + noShadows + { + blend add + map _hudImage + } +} + diff --git a/assets/pak299/models/mapobjects/hud.lwo b/assets/pak299/models/mapobjects/hud.lwo new file mode 100644 index 0000000..9f9baf6 Binary files /dev/null and b/assets/pak299/models/mapobjects/hud.lwo differ