mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-23 01:18:46 +00:00
OVR: Get orientation
This commit is contained in:
parent
925a11fc14
commit
d699bf9f3c
2 changed files with 39 additions and 45 deletions
|
@ -185,13 +185,14 @@ private:
|
||||||
UDriver *m_Driver;
|
UDriver *m_Driver;
|
||||||
|
|
||||||
CTextureUser *m_GUITexture;
|
CTextureUser *m_GUITexture;
|
||||||
|
NL3D::CTextureUser *m_SceneTexture;
|
||||||
|
|
||||||
UMaterial m_UnlitMat;
|
UMaterial m_UnlitMat;
|
||||||
NLMISC::CRefPtr<CVertexProgramOVR> m_VP;
|
NLMISC::CRefPtr<CVertexProgramOVR> m_VP;
|
||||||
NLMISC::CRefPtr<CPixelProgramOVR> m_PP;
|
NLMISC::CRefPtr<CPixelProgramOVR> m_PP;
|
||||||
|
|
||||||
|
|
||||||
/*NL3D::CTextureUser *m_SceneTexture;
|
/*
|
||||||
NL3D::UMaterial m_BarrelMat;
|
NL3D::UMaterial m_BarrelMat;
|
||||||
NLMISC::CQuadUV m_BarrelQuadLeft;
|
NLMISC::CQuadUV m_BarrelQuadLeft;
|
||||||
NLMISC::CQuadUV m_BarrelQuadRight;
|
NLMISC::CQuadUV m_BarrelQuadRight;
|
||||||
|
|
|
@ -246,7 +246,7 @@ CStereoOVR::CStereoOVR(const CStereoOVRDeviceFactory *factory) : m_DevicePtr(NUL
|
||||||
// get distortion mesh
|
// get distortion mesh
|
||||||
ovrDistortionMesh meshData;
|
ovrDistortionMesh meshData;
|
||||||
ovrHmd_CreateDistortionMesh(m_DevicePtr, (ovrEyeType)eye, fov,
|
ovrHmd_CreateDistortionMesh(m_DevicePtr, (ovrEyeType)eye, fov,
|
||||||
ovrDistortionCap_Chromatic | ovrDistortionCap_TimeWarp | ovrDistortionCap_Vignette,
|
ovrDistortionCap_Chromatic /*| ovrDistortionCap_TimeWarp*/ | ovrDistortionCap_Vignette, // I believe the timewarp gimmick screws with parallax
|
||||||
&meshData);
|
&meshData);
|
||||||
ovrVector2f uvScaleOffset[2];
|
ovrVector2f uvScaleOffset[2];
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ CStereoOVR::CStereoOVR(const CStereoOVRDeviceFactory *factory) : m_DevicePtr(NUL
|
||||||
vba.setTexCoord(i, 2, ov.TanEyeAnglesB.x, ov.TanEyeAnglesB.y);
|
vba.setTexCoord(i, 2, ov.TanEyeAnglesB.x, ov.TanEyeAnglesB.y);
|
||||||
NLMISC::CRGBA color;
|
NLMISC::CRGBA color;
|
||||||
color.R = color.G = color.B = (uint8)(ov.VignetteFactor * 255.99f);
|
color.R = color.G = color.B = (uint8)(ov.VignetteFactor * 255.99f);
|
||||||
color.A = (uint8)(ov.TimeWarpFactor * 255.99f);
|
color.A = 255; // (uint8)(ov.TimeWarpFactor * 255.99f);
|
||||||
vba.setColor(i, color);
|
vba.setColor(i, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,12 +552,6 @@ void CStereoOVR::updateCamera(uint cid, const NL3D::UCamera *camera)
|
||||||
|
|
||||||
bool CStereoOVR::nextPass()
|
bool CStereoOVR::nextPass()
|
||||||
{
|
{
|
||||||
// Do not allow weird stuff.
|
|
||||||
uint32 width, height;
|
|
||||||
m_Driver->getWindowSize(width, height);
|
|
||||||
// nlassert(width == m_DevicePtr->HMDInfo.HResolution);
|
|
||||||
// nlassert(height == m_DevicePtr->HMDInfo.VResolution);
|
|
||||||
|
|
||||||
if (m_Driver->getPolygonMode() == UDriver::Filled)
|
if (m_Driver->getPolygonMode() == UDriver::Filled)
|
||||||
{
|
{
|
||||||
switch (m_Stage) // Previous stage
|
switch (m_Stage) // Previous stage
|
||||||
|
@ -742,15 +736,13 @@ bool CStereoOVR::beginRenderTarget()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin 3D scene render target
|
// Begin 3D scene render target
|
||||||
/*if (m_Driver && m_Stage == 3 && (m_Driver->getPolygonMode() == UDriver::Filled))
|
if (m_Driver && m_Stage == 3 && (m_Driver->getPolygonMode() == UDriver::Filled))
|
||||||
{
|
{
|
||||||
nlassert(!m_SceneTexture);
|
nlassert(!m_SceneTexture);
|
||||||
uint32 width, height;
|
m_SceneTexture = m_Driver->getRenderTargetManager().getRenderTarget(m_RenderTargetWidth, m_RenderTargetHeight);
|
||||||
m_Driver->getWindowSize(width, height); // Temporary limitation, TODO: scaling!
|
|
||||||
m_SceneTexture = m_Driver->getRenderTargetManager().getRenderTarget(width, height);
|
|
||||||
static_cast<CDriverUser *>(m_Driver)->setRenderTarget(*m_SceneTexture);
|
static_cast<CDriverUser *>(m_Driver)->setRenderTarget(*m_SceneTexture);
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -762,17 +754,6 @@ void CStereoOVR::setInterfaceMatrix(const NL3D::CMatrix &matrix)
|
||||||
|
|
||||||
void CStereoOVR::renderGUI()
|
void CStereoOVR::renderGUI()
|
||||||
{
|
{
|
||||||
|
|
||||||
/*CMatrix mat;
|
|
||||||
mat.translate(m_InterfaceCameraMatrix.getPos());
|
|
||||||
CVector dir = m_InterfaceCameraMatrix.getJ();
|
|
||||||
dir.z = 0;
|
|
||||||
dir.normalize();
|
|
||||||
if (dir.y < 0)
|
|
||||||
mat.rotateZ(float(NLMISC::Pi+asin(dir.x)));
|
|
||||||
else
|
|
||||||
mat.rotateZ(float(NLMISC::Pi+NLMISC::Pi-asin(dir.x)));
|
|
||||||
m_Driver->setModelMatrix(mat);*/
|
|
||||||
m_Driver->setModelMatrix(m_InterfaceCameraMatrix);
|
m_Driver->setModelMatrix(m_InterfaceCameraMatrix);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1022,27 +1003,39 @@ bool CStereoOVR::endRenderTarget()
|
||||||
|
|
||||||
NLMISC::CQuat CStereoOVR::getOrientation() const
|
NLMISC::CQuat CStereoOVR::getOrientation() const
|
||||||
{
|
{
|
||||||
//if (m_OrientationCached)
|
if (m_OrientationCached)
|
||||||
return m_OrientationCache;
|
return m_OrientationCache;
|
||||||
/*
|
|
||||||
OVR::Quatf quatovr = m_DevicePtr->SensorFusion.GetPredictedOrientation();
|
ovrTrackingState ts = ovrHmd_GetTrackingState(m_DevicePtr, ovr_GetTimeInSeconds()); // TODO: Predict forward
|
||||||
NLMISC::CMatrix coordsys;
|
if (ts.StatusFlags & ovrStatus_OrientationTracked)
|
||||||
float csys[] = {
|
{
|
||||||
1.0f, 0.0f, 0.0f, 0.0f,
|
// get just the orientation
|
||||||
0.0f, 0.0f, -1.0f, 0.0f,
|
ovrQuatf quatovr = ts.HeadPose.ThePose.Orientation;
|
||||||
0.0f, 1.0f, 0.0f, 0.0f,
|
NLMISC::CMatrix coordsys;
|
||||||
0.0f, 0.0f, 0.0f, 1.0f,
|
float csys[] = {
|
||||||
};
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
coordsys.set(csys);
|
0.0f, 0.0f, -1.0f, 0.0f,
|
||||||
NLMISC::CMatrix matovr;
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
matovr.setRot(NLMISC::CQuat(quatovr.x, quatovr.y, quatovr.z, quatovr.w));
|
0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
NLMISC::CMatrix matr;
|
};
|
||||||
matr.rotateX(NLMISC::Pi * 0.5f); // fix this properly... :) (note: removing this allows you to use rift while lying down)
|
coordsys.set(csys);
|
||||||
NLMISC::CMatrix matnel = matr * matovr * coordsys;
|
NLMISC::CMatrix matovr;
|
||||||
NLMISC::CQuat finalquat = matnel.getRot();
|
matovr.setRot(NLMISC::CQuat(quatovr.x, quatovr.y, quatovr.z, quatovr.w));
|
||||||
m_OrientationCache = finalquat;
|
NLMISC::CMatrix matr;
|
||||||
m_OrientationCached = true;
|
matr.rotateX(NLMISC::Pi * 0.5f); // fix this properly... :) (note: removing this allows you to use rift while lying down)
|
||||||
return finalquat;*/
|
NLMISC::CMatrix matnel = matr * matovr * coordsys;
|
||||||
|
NLMISC::CQuat finalquat = matnel.getRot();
|
||||||
|
m_OrientationCache = finalquat;
|
||||||
|
m_OrientationCached = true;
|
||||||
|
return finalquat;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nlwarning("OVR: No orientation returned");
|
||||||
|
// return old orientation
|
||||||
|
m_OrientationCached = true;
|
||||||
|
return m_OrientationCache;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get GUI shift
|
/// Get GUI shift
|
||||||
|
|
Loading…
Reference in a new issue