//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 }
void Hand::renderHandTargets(bool isMine) { glPushMatrix(); MyAvatar* myAvatar = Application::getInstance()->getAvatar(); const float avatarScale = Application::getInstance()->getAvatar()->getScale(); const float alpha = 1.0f; const glm::vec3 handColor(1.0, 0.0, 0.0); // Color the hand targets red to be different than skin glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); if (isMine && Menu::getInstance()->isOptionChecked(MenuOption::DisplayHandTargets)) { for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; if (!palm.isActive()) { continue; } glm::vec3 targetPosition = palm.getTipPosition(); glPushMatrix(); glTranslatef(targetPosition.x, targetPosition.y, targetPosition.z); const float collisionRadius = 0.05f; glColor4f(0.5f,0.5f,0.5f, alpha); DependencyManager::get<GeometryCache>()->renderSphere(collisionRadius, 10, 10, false); glPopMatrix(); } } const float PALM_BALL_RADIUS = 0.03f * avatarScale; const float PALM_DISK_RADIUS = 0.06f * avatarScale; const float PALM_DISK_THICKNESS = 0.01f * avatarScale; const float PALM_FINGER_ROD_RADIUS = 0.003f * avatarScale; // Draw the palm ball and disk for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; if (palm.isActive()) { glColor4f(handColor.r, handColor.g, handColor.b, alpha); glm::vec3 tip = palm.getTipPosition(); glm::vec3 root = palm.getPosition(); //Scale the positions based on avatar scale myAvatar->scaleVectorRelativeToPosition(tip); myAvatar->scaleVectorRelativeToPosition(root); Avatar::renderJointConnectingCone(root, tip, PALM_FINGER_ROD_RADIUS, PALM_FINGER_ROD_RADIUS); // Render sphere at palm/finger root glm::vec3 offsetFromPalm = root + palm.getNormal() * PALM_DISK_THICKNESS; Avatar::renderJointConnectingCone(root, offsetFromPalm, PALM_DISK_RADIUS, 0.0f); glPushMatrix(); glTranslatef(root.x, root.y, root.z); DependencyManager::get<GeometryCache>()->renderSphere(PALM_BALL_RADIUS, 20.0f, 20.0f); glPopMatrix(); } } glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); glPopMatrix(); }