void OculusSocketServerApp::update() { mOculusVR->handleMessages(); if( mOculusVR && mOculusVR->isConnected() && mSocketConnected ) { boost::format fmt("{ \"m\" : \"update\", \"o\" : [%f,%f,%f,%f], \"a\" : [%f,%f,%f] }"); orientation = mOculusVR->getOrientation(); acceleration = mOculusVR->getAcceleration(); fmt % orientation.w; fmt % orientation.v.x; fmt % orientation.v.y; fmt % orientation.v.z; fmt % acceleration.x; fmt % acceleration.y; fmt % acceleration.z; mServer.write(fmt.str()); } if(mOculusVR && mOculusVR->isConnected()){ if(!mOculusConnected){ sendHMDConfig(); mOculusConnected = true; } } else { mOculusConnected = false; } mServer.poll(); }
void OculusSocketServerApp::sendHMDConfig(){ if(mOculusVR && mOculusVR->isConnected() && mSocketConnected) { float fov = mOculusVR->getFov(); float ipd = mOculusVR->getIPD(); float lensDistance = mOculusVR->getLensSeparationDistance(); float eyeToScreen = mOculusVR->getEyeToScreenDistance(); Vec4f distortionValues = mOculusVR->getDistortionParams(); Vec2f screenSize = mOculusVR->getScreenSize(); Vec2f screenResolution = mOculusVR->getScreenResolution(); boost::format fmt("{ \"m\" : \"config\", \"fov\" : %f, \"interpupillaryDistance\" : %f, \"eyeToScreen\" : %f, \"lensDistance\" : %f, \"distortion\" : [%f,%f,%f,%f], \"screenSize\" : [%f,%f], \"screenResolution\" : [%f,%f] }"); fmt % fov; fmt % ipd; fmt % eyeToScreen; fmt % lensDistance; fmt % distortionValues.x; fmt % distortionValues.y; fmt % distortionValues.z; fmt % distortionValues.w; fmt % screenSize.x; fmt % screenSize.y; fmt % screenResolution.x; fmt % screenResolution.y; mServer.write(fmt.str()); } }
void OculusSocketServerApp::draw() { gl::setMatricesWindow(getWindowWidth(), getWindowHeight()); glColor3f(1.0, 1.0, 1.0); gl::draw(mBackgroundTexture); glColor3f(0.16078431372549, 0.83921568627451, 0.88235294117647); if(mSocketConnected) { gl::drawSolidRect( Rectf(358, 30, 370, 42) ); } if(mOculusVR && mOculusVR->isConnected()) { gl::drawSolidRect( Rectf(358, 104, 370, 116) ); } }