|
|
@ -129,7 +129,7 @@ CStereoOVRSystem s_StereoOVRSystem;
|
|
|
|
class CStereoOVRDeviceHandle : public NLMISC::CRefCount
|
|
|
|
class CStereoOVRDeviceHandle : public NLMISC::CRefCount
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
OVR::DeviceHandle DeviceHandle;
|
|
|
|
OVR::DeviceEnumerator<OVR::HMDDevice> DeviceHandle;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
sint s_DeviceCounter = 0;
|
|
|
|
sint s_DeviceCounter = 0;
|
|
|
@ -140,6 +140,8 @@ class CStereoOVRDevicePtr
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
OVR::Ptr<OVR::HMDDevice> HMDDevice;
|
|
|
|
OVR::Ptr<OVR::HMDDevice> HMDDevice;
|
|
|
|
|
|
|
|
OVR::Ptr<OVR::SensorDevice> SensorDevice;
|
|
|
|
|
|
|
|
OVR::SensorFusion SensorFusion;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CStereoOVR::CStereoOVR(const CStereoDeviceInfo &deviceInfo)
|
|
|
|
CStereoOVR::CStereoOVR(const CStereoDeviceInfo &deviceInfo)
|
|
|
@ -147,20 +149,53 @@ CStereoOVR::CStereoOVR(const CStereoDeviceInfo &deviceInfo)
|
|
|
|
++s_DeviceCounter;
|
|
|
|
++s_DeviceCounter;
|
|
|
|
m_DevicePtr = new CStereoOVRDevicePtr();
|
|
|
|
m_DevicePtr = new CStereoOVRDevicePtr();
|
|
|
|
|
|
|
|
|
|
|
|
// CStereoOVRDeviceHandle *handle = static_cast<CStereoOVRDeviceHandle *>(deviceInfo.Factory.getPtr());
|
|
|
|
CStereoOVRDeviceHandle *handle = static_cast<CStereoOVRDeviceHandle *>(deviceInfo.Factory.getPtr());
|
|
|
|
// OVR::DeviceHandle dh = handle->DeviceHandle;
|
|
|
|
OVR::DeviceEnumerator<OVR::HMDDevice> dh = handle->DeviceHandle;
|
|
|
|
// dh.CreateDevice();
|
|
|
|
m_DevicePtr->HMDDevice = dh.CreateDevice();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_DevicePtr->HMDDevice)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_DevicePtr->SensorDevice = m_DevicePtr->HMDDevice->GetSensor();
|
|
|
|
|
|
|
|
m_DevicePtr->SensorFusion.AttachToSensor(m_DevicePtr->SensorDevice);
|
|
|
|
|
|
|
|
m_DevicePtr->SensorFusion.SetGravityEnabled(true);
|
|
|
|
|
|
|
|
m_DevicePtr->SensorFusion.SetPredictionEnabled(true);
|
|
|
|
|
|
|
|
m_DevicePtr->SensorFusion.SetYawCorrectionEnabled(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CStereoOVR::~CStereoOVR()
|
|
|
|
CStereoOVR::~CStereoOVR()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
if (m_DevicePtr->SensorDevice)
|
|
|
|
|
|
|
|
m_DevicePtr->SensorDevice->Release();
|
|
|
|
|
|
|
|
m_DevicePtr->SensorDevice.Clear();
|
|
|
|
|
|
|
|
if (m_DevicePtr->HMDDevice)
|
|
|
|
|
|
|
|
m_DevicePtr->HMDDevice->Release();
|
|
|
|
|
|
|
|
m_DevicePtr->HMDDevice.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
delete m_DevicePtr;
|
|
|
|
delete m_DevicePtr;
|
|
|
|
m_DevicePtr = NULL;
|
|
|
|
m_DevicePtr = NULL;
|
|
|
|
--s_DeviceCounter;
|
|
|
|
--s_DeviceCounter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLMISC::CQuat CStereoOVR::getOrientation()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OVR::Quatf quatovr = m_DevicePtr->SensorFusion.GetPredictedOrientation();
|
|
|
|
|
|
|
|
NLMISC::CMatrix coordsys;
|
|
|
|
|
|
|
|
float csys[] = {
|
|
|
|
|
|
|
|
1.0f, 0.0f, 0.0f, 0.0f,
|
|
|
|
|
|
|
|
0.0f, 0.0f, -1.0f, 0.0f,
|
|
|
|
|
|
|
|
0.0f, 1.0f, 0.0f, 0.0f,
|
|
|
|
|
|
|
|
0.0f, 0.0f, 0.0f, 1.0f,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
coordsys.set(csys);
|
|
|
|
|
|
|
|
NLMISC::CMatrix matovr;
|
|
|
|
|
|
|
|
matovr.setRot(NLMISC::CQuat(quatovr.x, quatovr.y, quatovr.z, quatovr.w));
|
|
|
|
|
|
|
|
NLMISC::CMatrix matr;
|
|
|
|
|
|
|
|
matr.rotateX(NLMISC::Pi * 0.5f); // fix this properly... :) (note: removing this allows you to use rift while lying down)
|
|
|
|
|
|
|
|
NLMISC::CMatrix matnel = matr * matovr * coordsys;
|
|
|
|
|
|
|
|
return matnel.getRot();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CStereoOVR::listDevices(std::vector<CStereoDeviceInfo> &devicesOut)
|
|
|
|
void CStereoOVR::listDevices(std::vector<CStereoDeviceInfo> &devicesOut)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
s_StereoOVRSystem.Init();
|
|
|
|
s_StereoOVRSystem.Init();
|
|
|
@ -190,7 +225,7 @@ void CStereoOVR::listDevices(std::vector<CStereoDeviceInfo> &devicesOut)
|
|
|
|
|
|
|
|
|
|
|
|
CStereoOVR *CStereoOVR::createDevice(const CStereoDeviceInfo &deviceInfo)
|
|
|
|
CStereoOVR *CStereoOVR::createDevice(const CStereoDeviceInfo &deviceInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
return new CStereoOVR(deviceInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CStereoOVR::isLibraryInUse()
|
|
|
|
bool CStereoOVR::isLibraryInUse()
|
|
|
@ -205,6 +240,11 @@ void CStereoOVR::releaseLibrary()
|
|
|
|
s_StereoOVRSystem.Release();
|
|
|
|
s_StereoOVRSystem.Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CStereoOVR::isDeviceCreated()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return m_DevicePtr->HMDDevice != NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} /* namespace NL3D */
|
|
|
|
} /* namespace NL3D */
|
|
|
|
|
|
|
|
|
|
|
|
/* end of file */
|
|
|
|
/* end of file */
|
|
|
|