Commit c2455793 authored by Robert Menzel's avatar Robert Menzel

reading of local Rift user config added

parent 4227315b
......@@ -59,6 +59,10 @@ public:
void setHMDRotation( const glm::mat3 &_rotation );
void setEyeHeight( float _eyeHeight) { if (_eyeHeight>0.0f) mEyeHeight = _eyeHeight; }
float getEyeHeight() { return mEyeHeight; }
private:
//! stored as a translation vector
glm::vec2 mProjectionCenterOffset;
......@@ -71,6 +75,9 @@ private:
//! rotation of the HMD
glm::mat4 mHMDRotation;
//! distance floor to eyes in meters (player height is a few cm more)
float mEyeHeight;
};
ACGL_SMARTPOINTER_TYPEDEFS(HMDCamera)
......
......@@ -16,23 +16,65 @@ SimpleRiftController::SimpleRiftController( uint32_t _riftnumber )
{
mSuccessfulConnected = false;
mDistortionScaleFactor = 1.0f;
mUseDistortion = true;
mUseChromaticAberation = true;
mPredictionTime = -1.0f;
mFoVMultiplier = 1.0f;
debug() << "try to connect to Oculus Rift via SDK " << OVR_VERSION_STRING << endl;
mORSensorFusion = NULL;
if (_riftnumber != 0) {
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();
const char *profileName = NULL;
OVR::Ptr<OVR::Profile> profile = NULL;
if (mORDevice) {
// get profile of this device:
profile = mORDevice->GetProfile();
profileName = mORDevice->GetProfileName();
// get device info:
if (!mORDevice->GetDeviceInfo( mORHMDInfo )) {
error() << "could not get HMD device info" << endl;
return;
}
mORSensor = *mORDevice->GetSensor();
if (!mORSensor) {
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;
......@@ -49,6 +91,7 @@ SimpleRiftController::SimpleRiftController( uint32_t _riftnumber )
mORHMDInfo->LensSeparationDistance = 0.0635f;
mORHMDInfo->InterpupillaryDistance = 0.064f;
mORHMDInfo->DisplayDeviceName[0] = 0;
}
mCamera = SharedHMDCamera(); // set to NULL
attachCamera( SharedHMDCamera( new HMDCamera() ) ); // attach a blank camera
......@@ -57,38 +100,26 @@ SimpleRiftController::SimpleRiftController( uint32_t _riftnumber )
mCamera->resize( viewport.x/2, viewport.y );
updateCameraFoV(); // indirectly based on the viewport
mORManager = *DeviceManager::Create();
if (!mORManager) {
error() << "could not create a Rift Device Manager" << endl;
return;
if (profile) {
mCamera->setInterpupillaryDistance( profile->GetIPD() );
mCamera->setEyeHeight( profile->GetEyeHeight() );
}
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 )) {
error() << "could not get HMD device info" << endl;
return;
if (magneticYawCorrection && profile) {
debug() << "Connected to Rift (SDK: "<<OVR_VERSION_STRING<<"). Using local user settings of profile " << profileName << ". Yaw correction active." << endl;
} 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) {
debug() << "Connected to Rift (SDK: "<<OVR_VERSION_STRING<<"). Yaw correction active. No local user profile found." << endl;
} else {
debug() << "Connected to Rift (SDK: "<<OVR_VERSION_STRING<<"). Yaw correction inactive. No local user profile found." << endl;
}
mORSensor = *mORDevice->GetSensor();
if (!mORSensor) {
error() << "could not get sensor of HMD" << endl;
#ifdef __linux
error() << "do you have read/write permissions of /dev/hidraw* ?" << endl;
#endif
return;
} else {
error() << "could not create a Rift device - using default values (SDK: "<<OVR_VERSION_STRING<<")." << endl;
}
mORSensorFusion = new OVR::SensorFusion();
mORSensorFusion->AttachToSensor( mORSensor );
mSuccessfulConnected = true;
}
SimpleRiftController::~SimpleRiftController()
......@@ -96,7 +127,6 @@ SimpleRiftController::~SimpleRiftController()
// setting the reference counted pointers to NULL will call the object destructors:
debug() << "disconnecting from Oculus Rift..." << endl;
//mORSensorFusion->AttachToSensor( NULL );
mORSensor = NULL;
mORDevice = NULL;
mORManager = NULL;
......@@ -207,7 +237,7 @@ void SimpleRiftController::updateCameraFoV()
if (vfov >= 175.0f) vfov = 175.0f;
mCamera->setVerticalFieldOfView( vfov );
debug() << "update VFoV: " << vfov << endl;
//debug() << "update VFoV: " << vfov << endl;
}
glm::uvec2 SimpleRiftController::getPhysicalScreenResolution()
......
......@@ -14,6 +14,7 @@ HMDCamera::HMDCamera()
setStereoMode( GenericCamera::PARALLEL_SHIFT );
mNeckToEyeVerticalDistance = 0.0f;
mNeckToEyeHorizontalDistance = 0.0f;
mEyeHeight = 1.68f; // average eye height in m for a 178cm person
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