This commit is contained in:
Simon 2020-03-18 23:32:10 +00:00
parent d6c0ac2d32
commit d6434d11dc
4 changed files with 26 additions and 51 deletions

View file

@ -808,7 +808,7 @@ void FGLRenderer::Flush()
glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
//Only adjust HUD if we are 3D and not showing menu (otherwise we are rendering to a cylinder compositor layer) //Only adjust HUD if we are 3D and not showing menu (otherwise we are rendering to a cylinder compositor layer)
//if (!is2D && !isMenuActive()) stereo3dMode.getEyePose(eye_ix)->AdjustHud(); if (!is2D && !isMenuActive()) stereo3dMode.getEyePose(eye_ix)->AdjustHud();
m2DDrawer->Draw(); m2DDrawer->Draw();
FGLDebug::PopGroup(); FGLDebug::PopGroup();

View file

@ -149,66 +149,50 @@ namespace s3d
return true; return true;
} }
VSMatrix OculusQuestEyePose::getQuadInWorld( VSMatrix OculusQuestEyePose::getQuadInWorld() const
float distance, // meters
float width, // meters
bool doFixPitch,
float pitchOffset) const
{ {
VSMatrix new_projection; VSMatrix new_projection;
new_projection.loadIdentity(); new_projection.loadIdentity();
float stereo_separation = (vr_ipd * 0.5) * vr_vunits_per_meter * (eye == 1 ? -1.0 : 1.0);
new_projection.translate(stereo_separation, 0, 0);
// doom_units from meters // doom_units from meters
new_projection.scale( new_projection.scale(
-vr_vunits_per_meter, -vr_vunits_per_meter,
vr_vunits_per_meter, vr_vunits_per_meter,
-vr_vunits_per_meter); -vr_vunits_per_meter);
double pixelstretch = level.info ? level.info->pixelstretch : 1.2; double pixelstretch = level.info ? level.info->pixelstretch : 1.2;
new_projection.scale(1.0, pixelstretch, 1.0); // Doom universe is scaled by 1990s pixel aspect ratio new_projection.scale(pixelstretch, pixelstretch, 1.0); // Doom universe is scaled by 1990s pixel aspect ratio
const OculusQuestEyePose * activeEye = this;
// eye coordinates from hmd coordinates
//VSMatrix e2h(activeEye->eyeToHeadTransform);
//e2h.transpose();
//new_projection.multMatrix(e2h);
// Follow HMD orientation, EXCEPT for roll angle (keep weapon upright) // Follow HMD orientation, EXCEPT for roll angle (keep weapon upright)
/*if (activeEye->currentPose) { {
float vrRollDegrees = RAD2DEG(-eulerAnglesFromMatrix(activeEye->currentPose->mDeviceToAbsoluteTracking).v[2]); new_projection.rotate(-hmdorientation[ROLL], 0, 0, 1);
new_projection.rotate(-vrRollDegrees, 0, 0, 1);
if (doFixPitch) { {
float vrPitchDegrees = RAD2DEG(-eulerAnglesFromMatrix(activeEye->currentPose->mDeviceToAbsoluteTracking).v[1]); new_projection.rotate(-hmdorientation[PITCH], 1, 0, 0);
new_projection.rotate(-vrPitchDegrees, 1, 0, 0);
} }
}*/
new_projection.rotate(30, 1, 0, 0);
if (pitchOffset != 0) }
new_projection.rotate(-pitchOffset, 1, 0, 0);
// hmd coordinates (meters) from ndc coordinates // hmd coordinates (meters) from ndc coordinates
// const float weapon_distance_meters = 0.55f; // const float weapon_distance_meters = 0.55f;
// const float weapon_width_meters = 0.3f; // const float weapon_width_meters = 0.3f;
const float aspect = SCREENWIDTH / float(SCREENHEIGHT); const float aspect = SCREENWIDTH / float(SCREENHEIGHT);
new_projection.translate(0.0, 0.0, distance); new_projection.translate(0.0, 0.0, 1.0);
new_projection.scale( new_projection.scale(
-width, -0.5,
width / aspect, 0.5,
-width); -0.5);
// ndc coordinates from pixel coordinates // ndc coordinates from pixel coordinates
new_projection.translate(-1.0, 1.0, 0); new_projection.translate(-1.0, 1.0, 0);
new_projection.scale(2.0 / SCREENWIDTH, -2.0 / SCREENHEIGHT, -1.0); new_projection.scale(2.0 / SCREENWIDTH, -2.0 / SCREENHEIGHT, -1.0);
ovrTracking2 tracking;
const OculusQuestMode * mode3d = static_cast<const OculusQuestMode*>(&Stereo3DMode::getCurrentMode());
mode3d->getTracking(&tracking);
VSMatrix proj = projection; VSMatrix proj = projection;
projection.multMatrix(new_projection); proj.multMatrix(new_projection);
new_projection = proj; new_projection = proj;
return new_projection; return new_projection;
@ -221,14 +205,7 @@ namespace s3d
return; return;
// Update HUD matrix to render on a separate quad // Update HUD matrix to render on a separate quad
const float menu_distance_meters = 1.0f; gl_RenderState.mProjectionMatrix = getQuadInWorld();
const float menu_width_meters = 0.4f * menu_distance_meters;
const float pitch_offset = -8.0;
gl_RenderState.mProjectionMatrix = getQuadInWorld(
menu_distance_meters,
menu_width_meters,
true,
pitch_offset);
gl_RenderState.ApplyMatrices(); gl_RenderState.ApplyMatrices();
} }
@ -342,7 +319,7 @@ namespace s3d
mat->rotate(-offhandangles[PITCH], 1, 0, 0); mat->rotate(-offhandangles[PITCH], 1, 0, 0);
mat->rotate(-offhandangles[ROLL], 0, 0, 1); mat->rotate(-offhandangles[ROLL], 0, 0, 1);
mat->translate(offhandoffset[0], hmdPosition[1] + offhandoffset[1] - vr_floor_offset, -offhandoffset[2]); mat->translate(-offhandoffset[0], hmdPosition[1] + offhandoffset[1] - vr_floor_offset, offhandoffset[2]);
} }
return true; return true;
@ -475,7 +452,7 @@ namespace s3d
vec3_t v_forward, v_right, v_up; vec3_t v_forward, v_right, v_up;
AngleVectors(angles, v_forward, v_right, v_up); AngleVectors(angles, v_forward, v_right, v_up);
player->mo->AttackDir = MapAttackDir;//DVector3(v_forward[0], v_forward[1], v_forward[2]); player->mo->AttackDir = MapAttackDir;
} }
//Positional Movement //Positional Movement

View file

@ -60,12 +60,7 @@ protected:
mutable uint32_t framebuffer; mutable uint32_t framebuffer;
int eye; int eye;
VSMatrix getQuadInWorld( VSMatrix getQuadInWorld() const;
float distance,
float width,
bool doFixPitch,
float pitchOffset
) const;
mutable VSMatrix projection; mutable VSMatrix projection;
}; };

View file

@ -51,6 +51,7 @@
CVAR(Bool, gl_interpolate_model_frames, true, CVAR_ARCHIVE) CVAR(Bool, gl_interpolate_model_frames, true, CVAR_ARCHIVE)
EXTERN_CVAR(Bool, r_drawvoxels) EXTERN_CVAR(Bool, r_drawvoxels)
EXTERN_CVAR(Int, vr_control_scheme)
extern TDeletingArray<FVoxel *> Voxels; extern TDeletingArray<FVoxel *> Voxels;
extern TDeletingArray<FVoxelDef *> VoxelDefs; extern TDeletingArray<FVoxelDef *> VoxelDefs;
@ -190,10 +191,12 @@ void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY)
if (smf == nullptr) if (smf == nullptr)
return; return;
// The model position and orientation has to be drawn independently from the position of the player, long oculusquest_rightHanded = vr_control_scheme < 10;
// The model position and orientation has to be drawn independently from the position of the player,
// but we need to position it correctly in the world for light to work properly. // but we need to position it correctly in the world for light to work properly.
VSMatrix objectToWorldMatrix = GetViewToWorldMatrix(); VSMatrix objectToWorldMatrix = GetViewToWorldMatrix();
if (s3d::Stereo3DMode::getCurrentMode().GetHandTransform(1, &objectToWorldMatrix)) if (s3d::Stereo3DMode::getCurrentMode().GetHandTransform(oculusquest_rightHanded ? 1 : 0, &objectToWorldMatrix))
{ {
float scale = 0.01f; float scale = 0.01f;
objectToWorldMatrix.scale(scale, scale, scale); objectToWorldMatrix.scale(scale, scale, scale);