Commit c2455793 authored by Robert Menzel's avatar Robert Menzel

reading of local Rift user config added

parent 4227315b
...@@ -59,6 +59,10 @@ public: ...@@ -59,6 +59,10 @@ public:
void setHMDRotation( const glm::mat3 &_rotation ); void setHMDRotation( const glm::mat3 &_rotation );
void setEyeHeight( float _eyeHeight) { if (_eyeHeight>0.0f) mEyeHeight = _eyeHeight; }
float getEyeHeight() { return mEyeHeight; }
private: private:
//! stored as a translation vector //! stored as a translation vector
glm::vec2 mProjectionCenterOffset; glm::vec2 mProjectionCenterOffset;
...@@ -71,6 +75,9 @@ private: ...@@ -71,6 +75,9 @@ private:
//! rotation of the HMD //! rotation of the HMD
glm::mat4 mHMDRotation; glm::mat4 mHMDRotation;
//! distance floor to eyes in meters (player height is a few cm more)
float mEyeHeight;
}; };
ACGL_SMARTPOINTER_TYPEDEFS(HMDCamera) ACGL_SMARTPOINTER_TYPEDEFS(HMDCamera)
......
...@@ -16,39 +16,82 @@ SimpleRiftController::SimpleRiftController( uint32_t _riftnumber ) ...@@ -16,39 +16,82 @@ SimpleRiftController::SimpleRiftController( uint32_t _riftnumber )
{ {
mSuccessfulConnected = false; mSuccessfulConnected = false;
mDistortionScaleFactor = 1.0f; mDistortionScaleFactor = 1.0f;
mUseDistortion = true; mUseDistortion = true;
mUseChromaticAberation = true; mUseChromaticAberation = true;
mPredictionTime = -1.0f; mPredictionTime = -1.0f;
mFoVMultiplier = 1.0f; mFoVMultiplier = 1.0f;
mORSensorFusion = NULL;
debug() << "try to connect to Oculus Rift via SDK " << OVR_VERSION_STRING << endl;
if (_riftnumber != 0) { if (_riftnumber != 0) {
error() << "opening any other Rift than ID 0 is not supported yet! Trying to open Rift nr 0" << endl; error() << "opening any other Rift than ID 0 is not supported yet! Trying to open Rift nr 0" << endl;
} }
System::Init( Log::ConfigureDefaultLog( LogMask_All) ); #ifdef ACGL_DEBUG
LogMaskConstants mask = LogMask_All;
#else
LogMaskConstants mask = LogMask_None;
#endif
System::Init( Log::ConfigureDefaultLog( mask) );
mORManager = *DeviceManager::Create();
if (!mORManager) {
error() << "could not create a Rift Device Manager" << endl;
mORDevice = NULL;
} else {
mORDevice = *mORManager->EnumerateDevices<HMDDevice>().CreateDevice();
}
// default values from the first devkit:
mORHMDInfo = new OVR::HMDInfo(); mORHMDInfo = new OVR::HMDInfo();
mORHMDInfo->HResolution = 1280; const char *profileName = NULL;
mORHMDInfo->VResolution = 800; OVR::Ptr<OVR::Profile> profile = NULL;
mORHMDInfo->HScreenSize = 0.14976f; if (mORDevice) {
mORHMDInfo->VScreenSize = 0.0935f; // get profile of this device:
mORHMDInfo->VScreenCenter = mORHMDInfo->VScreenSize*0.5f; profile = mORDevice->GetProfile();
mORHMDInfo->DistortionK[0] = 1.0f; profileName = mORDevice->GetProfileName();
mORHMDInfo->DistortionK[1] = 0.22f;
mORHMDInfo->DistortionK[2] = 0.24f; // get device info:
mORHMDInfo->EyeToScreenDistance = 0.041f; if (!mORDevice->GetDeviceInfo( mORHMDInfo )) {
mORHMDInfo->ChromaAbCorrection[0] = 0.996f; error() << "could not get HMD device info" << endl;
mORHMDInfo->ChromaAbCorrection[1] = -0.004f; return;
mORHMDInfo->ChromaAbCorrection[2] = 1.014f; }
mORHMDInfo->ChromaAbCorrection[3] = 0.0f;
mORHMDInfo->LensSeparationDistance = 0.0635f; mORSensor = *mORDevice->GetSensor();
mORHMDInfo->InterpupillaryDistance = 0.064f; if (!mORSensor) {
mORHMDInfo->DisplayDeviceName[0] = 0; error() << "could not get sensor of HMD (is the USB pluged in?)" << endl;
#ifdef __linux
error() << "do you have read/write permissions of /dev/hidraw* ?" << endl;
#endif
} else {
// configure sensor
mORSensorFusion = new OVR::SensorFusion();
mORSensorFusion->AttachToSensor( mORSensor );
mSuccessfulConnected = true;
}
} else {
// get the default profile:
OVR::Ptr<OVR::ProfileManager> pm = *OVR::ProfileManager::Create();
profileName = pm->GetDefaultProfileName(OVR::Profile_RiftDK1);
profile = pm->LoadProfile(OVR::Profile_RiftDK1, profileName);
// default device info from the first devkit:
mORHMDInfo->HResolution = 1280;
mORHMDInfo->VResolution = 800;
mORHMDInfo->HScreenSize = 0.14976f;
mORHMDInfo->VScreenSize = 0.0935f;
mORHMDInfo->VScreenCenter = mORHMDInfo->VScreenSize*0.5f;
mORHMDInfo->DistortionK[0] = 1.0f;
mORHMDInfo->DistortionK[1] = 0.22f;
mORHMDInfo->DistortionK[2] = 0.24f;
mORHMDInfo->EyeToScreenDistance = 0.041f;
mORHMDInfo->ChromaAbCorrection[0] = 0.996f;
mORHMDInfo->ChromaAbCorrection[1] = -0.004f;
mORHMDInfo->ChromaAbCorrection[2] = 1.014f;
mORHMDInfo->ChromaAbCorrection[3] = 0.0f;
mORHMDInfo->LensSeparationDistance = 0.0635f;
mORHMDInfo->InterpupillaryDistance = 0.064f;
mORHMDInfo->DisplayDeviceName[0] = 0;
}
mCamera = SharedHMDCamera(); // set to NULL mCamera = SharedHMDCamera(); // set to NULL
attachCamera( SharedHMDCamera( new HMDCamera() ) ); // attach a blank camera attachCamera( SharedHMDCamera( new HMDCamera() ) ); // attach a blank camera
...@@ -57,38 +100,26 @@ SimpleRiftController::SimpleRiftController( uint32_t _riftnumber ) ...@@ -57,38 +100,26 @@ SimpleRiftController::SimpleRiftController( uint32_t _riftnumber )
mCamera->resize( viewport.x/2, viewport.y ); mCamera->resize( viewport.x/2, viewport.y );
updateCameraFoV(); // indirectly based on the viewport updateCameraFoV(); // indirectly based on the viewport
mORManager = *DeviceManager::Create(); if (profile) {
if (!mORManager) { mCamera->setInterpupillaryDistance( profile->GetIPD() );
error() << "could not create a Rift Device Manager" << endl; mCamera->setEyeHeight( profile->GetEyeHeight() );
return;
}
mORDevice = *mORManager->EnumerateDevices<HMDDevice>().CreateDevice();
if (!mORDevice) {
error() << "could not create a Rift device" << endl;
return;
} }
debug() << "found HMD" << endl; if (mSuccessfulConnected) {
bool magneticYawCorrection = (mORSensorFusion->IsYawCorrectionEnabled() && mORSensorFusion->HasMagCalibration());
if (!mORDevice->GetDeviceInfo( mORHMDInfo )) { if (magneticYawCorrection && profile) {
error() << "could not get HMD device info" << endl; debug() << "Connected to Rift (SDK: "<<OVR_VERSION_STRING<<"). Using local user settings of profile " << profileName << ". Yaw correction active." << endl;
return; } else if (!magneticYawCorrection && profile) {
} debug() << "Connected to Rift (SDK: "<<OVR_VERSION_STRING<<"). Using local user settings of profile " << profileName << ". Yaw correction inactive." << endl;
} else if (magneticYawCorrection && !profile) {
mORSensor = *mORDevice->GetSensor(); debug() << "Connected to Rift (SDK: "<<OVR_VERSION_STRING<<"). Yaw correction active. No local user profile found." << endl;
if (!mORSensor) { } else {
error() << "could not get sensor of HMD" << endl; debug() << "Connected to Rift (SDK: "<<OVR_VERSION_STRING<<"). Yaw correction inactive. No local user profile found." << endl;
#ifdef __linux }
error() << "do you have read/write permissions of /dev/hidraw* ?" << endl; } else {
#endif error() << "could not create a Rift device - using default values (SDK: "<<OVR_VERSION_STRING<<")." << endl;
return;
} }
mORSensorFusion = new OVR::SensorFusion();
mORSensorFusion->AttachToSensor( mORSensor );
mSuccessfulConnected = true;
} }
SimpleRiftController::~SimpleRiftController() SimpleRiftController::~SimpleRiftController()
...@@ -96,7 +127,6 @@ SimpleRiftController::~SimpleRiftController() ...@@ -96,7 +127,6 @@ SimpleRiftController::~SimpleRiftController()
// setting the reference counted pointers to NULL will call the object destructors: // setting the reference counted pointers to NULL will call the object destructors:
debug() << "disconnecting from Oculus Rift..." << endl; debug() << "disconnecting from Oculus Rift..." << endl;
//mORSensorFusion->AttachToSensor( NULL );
mORSensor = NULL; mORSensor = NULL;
mORDevice = NULL; mORDevice = NULL;
mORManager = NULL; mORManager = NULL;
...@@ -207,7 +237,7 @@ void SimpleRiftController::updateCameraFoV() ...@@ -207,7 +237,7 @@ void SimpleRiftController::updateCameraFoV()
if (vfov >= 175.0f) vfov = 175.0f; if (vfov >= 175.0f) vfov = 175.0f;
mCamera->setVerticalFieldOfView( vfov ); mCamera->setVerticalFieldOfView( vfov );
debug() << "update VFoV: " << vfov << endl; //debug() << "update VFoV: " << vfov << endl;
} }
glm::uvec2 SimpleRiftController::getPhysicalScreenResolution() glm::uvec2 SimpleRiftController::getPhysicalScreenResolution()
......
...@@ -14,6 +14,7 @@ HMDCamera::HMDCamera() ...@@ -14,6 +14,7 @@ HMDCamera::HMDCamera()
setStereoMode( GenericCamera::PARALLEL_SHIFT ); setStereoMode( GenericCamera::PARALLEL_SHIFT );
mNeckToEyeVerticalDistance = 0.0f; mNeckToEyeVerticalDistance = 0.0f;
mNeckToEyeHorizontalDistance = 0.0f; mNeckToEyeHorizontalDistance = 0.0f;
mEyeHeight = 1.68f; // average eye height in m for a 178cm person
mHMDRotation = glm::mat4(1.0f); mHMDRotation = glm::mat4(1.0f);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment