mirror of
https://github.com/DrBeef/RTCWQuest.git
synced 2024-11-15 00:51:32 +00:00
Positional Tracking now seems to be working
This commit is contained in:
parent
8a4ad32dd1
commit
8a8631f03e
10 changed files with 83 additions and 55 deletions
|
@ -138,6 +138,7 @@ qboolean RTCWVR_useScreenLayer()
|
|||
(cls.state == CA_CINEMATIC) ||
|
||||
(cls.state == CA_LOADING) ||
|
||||
(clc.demoplaying) ||
|
||||
(cl.cameraMode) ||
|
||||
( Key_GetCatcher( ) & KEYCATCH_UI ) ||
|
||||
( Key_GetCatcher( ) & KEYCATCH_CONSOLE ));
|
||||
}
|
||||
|
@ -846,20 +847,20 @@ void QuatToYawPitchRoll(ovrQuatf q, vec3_t rotation, vec3_t out) {
|
|||
|
||||
void setWorldPosition( float x, float y, float z )
|
||||
{
|
||||
positionDeltaThisFrame[0] = (worldPosition[0] - x);
|
||||
positionDeltaThisFrame[1] = (worldPosition[1] - y);
|
||||
positionDeltaThisFrame[2] = (worldPosition[2] - z);
|
||||
vr.positionDeltaThisFrame[0] = (vr.worldPosition[0] - x);
|
||||
vr.positionDeltaThisFrame[1] = (vr.worldPosition[1] - y);
|
||||
vr.positionDeltaThisFrame[2] = (vr.worldPosition[2] - z);
|
||||
|
||||
worldPosition[0] = x;
|
||||
worldPosition[1] = y;
|
||||
worldPosition[2] = z;
|
||||
vr.worldPosition[0] = x;
|
||||
vr.worldPosition[1] = y;
|
||||
vr.worldPosition[2] = z;
|
||||
}
|
||||
|
||||
void setHMDPosition( float x, float y, float z, float yaw )
|
||||
{
|
||||
static qboolean s_useScreen = qfalse;
|
||||
|
||||
VectorSet(hmdPosition, x, y, z);
|
||||
VectorSet(vr.hmdPosition, x, y, z);
|
||||
|
||||
if (s_useScreen != RTCWVR_useScreenLayer())
|
||||
{
|
||||
|
@ -903,13 +904,6 @@ void RTCWVR_Vibrate( float duration, int channel, float intensity )
|
|||
vibration_channel_intensity[channel] = intensity;
|
||||
}
|
||||
|
||||
void getVROrigins(vec3_t _weaponoffset, vec3_t _weaponangles, vec3_t _hmdPosition)
|
||||
{
|
||||
VectorCopy(weaponoffset, _weaponoffset);
|
||||
VectorCopy(weaponangles, _weaponangles);
|
||||
VectorCopy(hmdPosition, _hmdPosition);
|
||||
}
|
||||
|
||||
void VR_GetMove( float *forward, float *side, float *pos_forward, float *pos_side, float *up, float *yaw, float *pitch, float *roll )
|
||||
{
|
||||
*forward = remote_movementForward;
|
||||
|
@ -917,12 +911,11 @@ void VR_GetMove( float *forward, float *side, float *pos_forward, float *pos_sid
|
|||
*up = remote_movementUp;
|
||||
*side = remote_movementSideways;
|
||||
*pos_side = positional_movementSideways;
|
||||
*yaw = hmdorientation[YAW] + snapTurn;
|
||||
*pitch = hmdorientation[PITCH];
|
||||
*roll = hmdorientation[ROLL];
|
||||
*yaw = vr.hmdorientation[YAW] + snapTurn;
|
||||
*pitch = vr.hmdorientation[PITCH];
|
||||
*roll = vr.hmdorientation[ROLL];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
||||
|
@ -1589,8 +1582,8 @@ void RTCWVR_getHMDOrientation() {//Get orientation
|
|||
const ovrQuatf quatHmd = tracking.HeadPose.Pose.Orientation;
|
||||
const ovrVector3f positionHmd = tracking.HeadPose.Pose.Position;
|
||||
vec3_t rotation = {0};
|
||||
QuatToYawPitchRoll(quatHmd, rotation, hmdorientation);
|
||||
setHMDPosition(positionHmd.x, positionHmd.y, positionHmd.z, hmdorientation[YAW]);
|
||||
QuatToYawPitchRoll(quatHmd, rotation, vr.hmdorientation);
|
||||
setHMDPosition(positionHmd.x, positionHmd.y, positionHmd.z, vr.hmdorientation[YAW]);
|
||||
|
||||
//TODO: fix - set to use HMD position for world position
|
||||
setWorldPosition(positionHmd.x, positionHmd.y, positionHmd.z);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <android/log.h>
|
||||
|
||||
#include "mathlib.h"
|
||||
#include "VrOrientation.h"
|
||||
|
||||
#define LOG_TAG "RTCWVR"
|
||||
|
||||
|
@ -33,18 +34,6 @@ float vrFOV;
|
|||
|
||||
ovrTracking2 tracking;
|
||||
|
||||
vec3_t worldPosition;
|
||||
|
||||
vec3_t hmdPosition;
|
||||
vec3_t hmdorientation;
|
||||
vec3_t positionDeltaThisFrame;
|
||||
|
||||
vec3_t weaponangles;
|
||||
vec3_t weaponoffset;
|
||||
|
||||
vec3_t flashlightangles;
|
||||
vec3_t flashlightoffset;
|
||||
|
||||
#define DUCK_NOTDUCKED 0
|
||||
#define DUCK_BUTTON 1
|
||||
#define DUCK_CROUCHED 2
|
||||
|
@ -52,6 +41,8 @@ int ducked;
|
|||
|
||||
qboolean player_moving;
|
||||
|
||||
vr_orientation_t vr;
|
||||
|
||||
|
||||
float radians(float deg);
|
||||
float degrees(float rad);
|
||||
|
|
|
@ -84,23 +84,23 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
//dominant hand stuff first
|
||||
{
|
||||
///Weapon location relative to view
|
||||
weaponoffset[0] = pDominantTracking->HeadPose.Pose.Position.x - hmdPosition[0];
|
||||
weaponoffset[1] = pDominantTracking->HeadPose.Pose.Position.y - hmdPosition[1];
|
||||
weaponoffset[2] = pDominantTracking->HeadPose.Pose.Position.z - hmdPosition[2];
|
||||
vr.weaponoffset[0] = pDominantTracking->HeadPose.Pose.Position.x - vr.hmdPosition[0];
|
||||
vr.weaponoffset[1] = pDominantTracking->HeadPose.Pose.Position.y - vr.hmdPosition[1];
|
||||
vr.weaponoffset[2] = pDominantTracking->HeadPose.Pose.Position.z - vr.hmdPosition[2];
|
||||
|
||||
{
|
||||
vec2_t v;
|
||||
rotateAboutOrigin(-weaponoffset[0], weaponoffset[2], (cl.viewangles[YAW] - hmdorientation[YAW]), v);
|
||||
weaponoffset[0] = v[0];
|
||||
weaponoffset[2] = v[1];
|
||||
rotateAboutOrigin(-vr.weaponoffset[0], vr.weaponoffset[2], (cl.viewangles[YAW] - vr.hmdorientation[YAW]), v);
|
||||
vr.weaponoffset[0] = v[0];
|
||||
vr.weaponoffset[2] = v[1];
|
||||
}
|
||||
|
||||
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
|
||||
vec3_t rotation = {0};
|
||||
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
||||
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, weaponangles);
|
||||
weaponangles[YAW] += (cl.viewangles[YAW] - hmdorientation[YAW]);
|
||||
weaponangles[ROLL] *= -1.0f;
|
||||
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles);
|
||||
vr.weaponangles[YAW] += (cl.viewangles[YAW] - vr.hmdorientation[YAW]);
|
||||
vr.weaponangles[ROLL] *= -1.0f;
|
||||
|
||||
|
||||
if (vr_weapon_stabilised->value == 1.0f)
|
||||
|
@ -111,7 +111,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
VectorSet(weaponangles, -degrees(atanf(y / zxDist)), (cl.viewangles[YAW] - hmdorientation[YAW]) - degrees(atan2f(x, -z)), weaponangles[ROLL]);
|
||||
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)), (cl.viewangles[YAW] - vr.hmdorientation[YAW]) - degrees(atan2f(x, -z)), vr.weaponangles[ROLL]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,22 +172,22 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
float controllerYawHeading = 0.0f;
|
||||
//off-hand stuff
|
||||
{
|
||||
flashlightoffset[0] = pOffTracking->HeadPose.Pose.Position.x - hmdPosition[0];
|
||||
flashlightoffset[1] = pOffTracking->HeadPose.Pose.Position.y - hmdPosition[1];
|
||||
flashlightoffset[2] = pOffTracking->HeadPose.Pose.Position.z - hmdPosition[2];
|
||||
vr.flashlightoffset[0] = pOffTracking->HeadPose.Pose.Position.x - vr.hmdPosition[0];
|
||||
vr.flashlightoffset[1] = pOffTracking->HeadPose.Pose.Position.y - vr.hmdPosition[1];
|
||||
vr.flashlightoffset[2] = pOffTracking->HeadPose.Pose.Position.z - vr.hmdPosition[2];
|
||||
|
||||
vec2_t v;
|
||||
rotateAboutOrigin(-flashlightoffset[0], flashlightoffset[2], (cl.viewangles[YAW] - hmdorientation[YAW]), v);
|
||||
flashlightoffset[0] = v[0];
|
||||
flashlightoffset[2] = v[1];
|
||||
rotateAboutOrigin(-vr.flashlightoffset[0], vr.flashlightoffset[2], (cl.viewangles[YAW] - vr.hmdorientation[YAW]), v);
|
||||
vr.flashlightoffset[0] = v[0];
|
||||
vr.flashlightoffset[2] = v[1];
|
||||
|
||||
vec3_t rotation = {0};
|
||||
QuatToYawPitchRoll(pOffTracking->HeadPose.Pose.Orientation, rotation, flashlightangles);
|
||||
QuatToYawPitchRoll(pOffTracking->HeadPose.Pose.Orientation, rotation, vr.flashlightangles);
|
||||
|
||||
flashlightangles[YAW] += (cl.viewangles[YAW] - hmdorientation[YAW]);
|
||||
vr.flashlightangles[YAW] += (cl.viewangles[YAW] - vr.hmdorientation[YAW]);
|
||||
|
||||
if (vr_walkdirection->value == 0) {
|
||||
controllerYawHeading = -cl.viewangles[YAW] + flashlightangles[YAW];
|
||||
controllerYawHeading = -cl.viewangles[YAW] + vr.flashlightangles[YAW];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -205,8 +205,8 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
//This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the
|
||||
//player is facing for positional tracking
|
||||
vec2_t v;
|
||||
rotateAboutOrigin(-positionDeltaThisFrame[0] * vr_positional_factor->value,
|
||||
positionDeltaThisFrame[2] * vr_positional_factor->value, - hmdorientation[YAW], v);
|
||||
rotateAboutOrigin(-vr.positionDeltaThisFrame[0] * vr_positional_factor->value,
|
||||
vr.positionDeltaThisFrame[2] * vr_positional_factor->value, - vr.hmdorientation[YAW], v);
|
||||
positional_movementSideways = v[0];
|
||||
positional_movementForward = v[1];
|
||||
|
||||
|
|
20
Projects/Android/jni/RTCWVR/VrOrientation.h
Normal file
20
Projects/Android/jni/RTCWVR/VrOrientation.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#if !defined(vrorientation_h)
|
||||
#define vrorientation_h
|
||||
|
||||
#include "mathlib.h"
|
||||
|
||||
typedef struct {
|
||||
vec3_t worldPosition;
|
||||
|
||||
vec3_t hmdPosition;
|
||||
vec3_t hmdorientation;
|
||||
vec3_t positionDeltaThisFrame;
|
||||
|
||||
vec3_t weaponangles;
|
||||
vec3_t weaponoffset;
|
||||
|
||||
vec3_t flashlightangles;
|
||||
vec3_t flashlightoffset;
|
||||
} vr_orientation_t;
|
||||
|
||||
#endif //vrorientation_h
|
|
@ -31,12 +31,14 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "cg_local.h"
|
||||
#include "../ui/ui_shared.h"
|
||||
#include "../../../RTCWVR/VrOrientation.h"
|
||||
|
||||
//----(SA) added to make it easier to raise/lower our statsubar by only changing one thing
|
||||
#define STATUSBARHEIGHT 452
|
||||
//----(SA) end
|
||||
|
||||
extern displayContextDef_t cgDC;
|
||||
extern vr_orientation_t cgVR;
|
||||
menuDef_t *menuScoreboard = NULL;
|
||||
|
||||
int sortedTeamPlayers[TEAM_MAXOVERLAY];
|
||||
|
@ -3577,8 +3579,8 @@ void CG_DrawActive( int stereoView ) {
|
|||
VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg );
|
||||
}
|
||||
|
||||
|
||||
cg.refdef.vieworg[2] -= cg.predictedPlayerState.viewheight;
|
||||
cg.refdef.vieworg[2] -= DEFAULT_VIEWHEIGHT;
|
||||
cg.refdef.vieworg[2] += (cgVR.hmdPosition[1] /*+ vr_height_adjust->value*/) * cg_worldScale.value;
|
||||
|
||||
|
||||
cg.refdef.glfog.registered = 0; // make sure it doesn't use fog from another scene
|
||||
|
|
|
@ -36,8 +36,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "cg_local.h"
|
||||
#include "../ui/ui_shared.h"
|
||||
#include "../../../RTCWVR/VrOrientation.h"
|
||||
|
||||
displayContextDef_t cgDC;
|
||||
vr_orientation_t cgVR;
|
||||
|
||||
int forceModelModificationCount = -1;
|
||||
|
||||
|
@ -89,6 +91,9 @@ int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int a
|
|||
cgDC.cursory = cgs.cursorY;
|
||||
CG_MouseEvent( arg0, arg1 );
|
||||
return 0;
|
||||
case CG_SET_VR_ORIENTATION:
|
||||
memcpy(&cgVR, (vr_orientation_t*)arg0, sizeof(vr_orientation_t));
|
||||
return 0;
|
||||
default:
|
||||
CG_Error( "vmMain: unknown command %i", command );
|
||||
break;
|
||||
|
|
|
@ -271,6 +271,8 @@ typedef enum {
|
|||
CG_GET_TAG,
|
||||
// qboolean CG_GetTag( int clientNum, char *tagname, orientation_t *or );
|
||||
|
||||
CG_SET_VR_ORIENTATION,
|
||||
|
||||
MAX_CGAME_EXPORT
|
||||
|
||||
} cgameExport_t;
|
||||
|
|
|
@ -31,6 +31,9 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "client.h"
|
||||
|
||||
#include "../game/botlib.h"
|
||||
#include "../../../RTCWVR/VrOrientation.h"
|
||||
|
||||
extern vr_orientation_t vr;
|
||||
|
||||
extern botlib_export_t *botlib_export;
|
||||
|
||||
|
@ -1051,6 +1054,15 @@ void CL_CGameRendering( stereoFrame_t stereo ) {
|
|||
VM_Debug( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_CGameRendering
|
||||
=====================
|
||||
*/
|
||||
void CL_CGameSetVROrientation( ) {
|
||||
VM_Call( cgvm, CG_SET_VR_ORIENTATION, &vr );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
|
|
|
@ -494,6 +494,7 @@ void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
|
|||
// }
|
||||
case CA_LOADING:
|
||||
case CA_PRIMED:
|
||||
CL_CGameSetVROrientation();
|
||||
// draw the game information screen and loading progress
|
||||
CL_CGameRendering( stereoFrame );
|
||||
|
||||
|
@ -504,6 +505,7 @@ void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
|
|||
VM_Call( uivm, UI_DRAW_CONNECT_SCREEN, qtrue );
|
||||
break;
|
||||
case CA_ACTIVE:
|
||||
CL_CGameSetVROrientation();
|
||||
CL_CGameRendering( stereoFrame );
|
||||
SCR_DrawDemoRecording();
|
||||
break;
|
||||
|
|
|
@ -569,6 +569,7 @@ void CIN_CloseAllVideos( void );
|
|||
void CL_InitCGame( void );
|
||||
void CL_ShutdownCGame( void );
|
||||
qboolean CL_GameCommand( void );
|
||||
void CL_CGameSetVROrientation( );
|
||||
void CL_CGameRendering( stereoFrame_t stereo );
|
||||
void CL_SetCGameTime( void );
|
||||
void CL_FirstSnapshot( void );
|
||||
|
|
Loading…
Reference in a new issue