diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1d5cbabd32..da86e7b54f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2805,8 +2805,11 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { bool mirrorMode = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR); { PerformanceTimer perfTimer("avatars"); - + _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, selfAvatarOnly); + + //Render the sixense lasers + _myAvatar->renderLaserPointers(); } if (!selfAvatarOnly) { diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index a58266fa71..45d6635226 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -1849,3 +1849,43 @@ void MyAvatar::applyCollision(const glm::vec3& contactPoint, const glm::vec3& pe } } +//Renders sixense laser pointers for UI selection with controllers +void MyAvatar::renderLaserPointers() { + const float PALM_TIP_ROD_RADIUS = 0.002f; + + //If the Oculus is enabled, we will draw a blue cursor ray + + for (size_t i = 0; i < getHand()->getNumPalms(); ++i) { + PalmData& palm = getHand()->getPalms()[i]; + if (palm.isActive()) { + glColor4f(0, 1, 1, 1); + glm::vec3 tip = getLaserPointerTipPosition(&palm); + glm::vec3 root = palm.getPosition(); + + //Scale the root vector with the avatar scale + scaleVectorRelativeToPosition(root); + + Avatar::renderJointConnectingCone(root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS); + } + } +} + +//Gets the tip position for the laser pointer +glm::vec3 MyAvatar::getLaserPointerTipPosition(const PalmData* palm) { + const ApplicationOverlay& applicationOverlay = Application::getInstance()->getApplicationOverlay(); + const float PALM_TIP_ROD_LENGTH_MULT = 40.0f; + + glm::vec3 direction = glm::normalize(palm->getTipPosition() - palm->getPosition()); + + glm::vec3 position = palm->getPosition(); + //scale the position with the avatar + scaleVectorRelativeToPosition(position); + + + glm::vec3 result; + if (applicationOverlay.calculateRayUICollisionPoint(position, direction, result)) { + return result; + } + + return palm->getPosition(); +} diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 0b2254bafa..8f99308530 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -127,6 +127,9 @@ public: void applyCollision(const glm::vec3& contactPoint, const glm::vec3& penetration); + /// Renders a laser pointer for UI picking + void renderLaserPointers(); + glm::vec3 getLaserPointerTipPosition(const PalmData* palm); public slots: void goHome(); void increaseSize(); diff --git a/interface/src/devices/OculusManager.cpp b/interface/src/devices/OculusManager.cpp index beb18bfc72..e6e958d89a 100644 --- a/interface/src/devices/OculusManager.cpp +++ b/interface/src/devices/OculusManager.cpp @@ -462,52 +462,4 @@ QSize OculusManager::getRenderTargetSize() { #else return QSize(100, 100); #endif -} - -//Renders sixense laser pointers for UI selection in the oculus -void OculusManager::renderLaserPointers() { -#ifdef HAVE_LIBOVR - const float PALM_TIP_ROD_RADIUS = 0.002f; - - MyAvatar* myAvatar = Application::getInstance()->getAvatar(); - - //If the Oculus is enabled, we will draw a blue cursor ray - - for (size_t i = 0; i < myAvatar->getHand()->getNumPalms(); ++i) { - PalmData& palm = myAvatar->getHand()->getPalms()[i]; - if (palm.isActive()) { - glColor4f(0, 1, 1, 1); - glm::vec3 tip = getLaserPointerTipPosition(&palm); - glm::vec3 root = palm.getPosition(); - - //Scale the root vector with the avatar scale - myAvatar->scaleVectorRelativeToPosition(root); - - Avatar::renderJointConnectingCone(root, tip, PALM_TIP_ROD_RADIUS, PALM_TIP_ROD_RADIUS); - } - } -#endif -} - -//Gets the tip position for the laser pointer -glm::vec3 OculusManager::getLaserPointerTipPosition(const PalmData* palm) { -#ifdef HAVE_LIBOVR - const ApplicationOverlay& applicationOverlay = Application::getInstance()->getApplicationOverlay(); - const float PALM_TIP_ROD_LENGTH_MULT = 40.0f; - - glm::vec3 direction = glm::normalize(palm->getTipPosition() - palm->getPosition()); - - glm::vec3 position = palm->getPosition(); - //scale the position with the avatar - Application::getInstance()->getAvatar()->scaleVectorRelativeToPosition(position); - - - glm::vec3 result; - if (applicationOverlay.calculateRayUICollisionPoint(position, direction, result)) { - return result; - } - - return palm->getPosition(); -#endif - return glm::vec3(0.0f); -} +} \ No newline at end of file diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index 871e5d649a..db7a6e3f59 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -42,10 +42,6 @@ public: /// param \roll[out] roll in radians static void getEulerAngles(float& yaw, float& pitch, float& roll); static QSize getRenderTargetSize(); - - /// Renders a laser pointer for UI picking - static void renderLaserPointers(); - static glm::vec3 getLaserPointerTipPosition(const PalmData* palm); private: #ifdef HAVE_LIBOVR diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 7b3db26d8d..b6c08f6f4f 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -64,6 +64,7 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) { _textureFov = Menu::getInstance()->getOculusUIAngularSize() * RADIANS_PER_DEGREE; + Application* application = Application::getInstance(); Overlays& overlays = application->getOverlays(); @@ -272,7 +273,7 @@ QPoint ApplicationOverlay::getOculusPalmClickLocation(const PalmData *palm) cons QGLWidget* glWidget = application->getGLWidget(); MyAvatar* myAvatar = application->getAvatar(); - glm::vec3 tip = OculusManager::getLaserPointerTipPosition(palm); + glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm); glm::vec3 eyePos = myAvatar->getHead()->calculateAverageEyePosition(); glm::quat orientation = glm::inverse(myAvatar->getOrientation()); glm::vec3 dir = orientation * glm::normalize(application->getCamera()->getPosition() - tip); //direction of ray goes towards camera @@ -340,7 +341,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { MyAvatar* myAvatar = application->getAvatar(); //Render the sixense lasers - OculusManager::renderLaserPointers(); + myAvatar->renderLaserPointers(); glActiveTexture(GL_TEXTURE0); @@ -700,7 +701,7 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) { PalmData& palm = myAvatar->getHand()->getPalms()[i]; if (palm.isActive()) { - glm::vec3 tip = OculusManager::getLaserPointerTipPosition(&palm); + glm::vec3 tip = myAvatar->getLaserPointerTipPosition(&palm); glm::vec3 tipPos = (tip - eyePos); float length = glm::length(eyePos - tip);