mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 15:29:42 +02:00
Dynamically resize lasers so they always end on UI
This commit is contained in:
parent
56ff74dd56
commit
004db004a6
3 changed files with 29 additions and 2 deletions
|
@ -490,8 +490,16 @@ void OculusManager::renderLaserPointer() {
|
||||||
|
|
||||||
glm::vec3 OculusManager::getLaserPointerTipPosition(const PalmData* palm) {
|
glm::vec3 OculusManager::getLaserPointerTipPosition(const PalmData* palm) {
|
||||||
#ifdef HAVE_LIBOVR
|
#ifdef HAVE_LIBOVR
|
||||||
const float PALM_TIP_ROD_LENGTH_MULT = 4.0f;
|
const ApplicationOverlay& applicationOverlay = Application::getInstance()->getApplicationOverlay();
|
||||||
return palm->getPosition() + (palm->getTipPosition() - palm->getPosition()) * PALM_TIP_ROD_LENGTH_MULT;
|
const float PALM_TIP_ROD_LENGTH_MULT = 40.0f;
|
||||||
|
|
||||||
|
glm::vec3 direction = glm::normalize(palm->getTipPosition() - palm->getPosition());
|
||||||
|
glm::vec3 result;
|
||||||
|
if (applicationOverlay.calculateRayUICollisionPoint(palm->getPosition(), direction, result)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return palm->getPosition();
|
||||||
#endif
|
#endif
|
||||||
return glm::vec3(0.0f);
|
return glm::vec3(0.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,6 +311,24 @@ QPoint ApplicationOverlay::getOculusPalmClickLocation(const PalmData *palm) cons
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ApplicationOverlay::calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction, glm::vec3& result) const {
|
||||||
|
Application* application = Application::getInstance();
|
||||||
|
MyAvatar* myAvatar = application->getAvatar();
|
||||||
|
|
||||||
|
glm::quat orientation = myAvatar->getOrientation();
|
||||||
|
|
||||||
|
glm::vec3 relativePosition = orientation * (position - myAvatar->getHead()->calculateAverageEyePosition());
|
||||||
|
glm::vec3 relativeDirection = orientation * direction;
|
||||||
|
|
||||||
|
float t;
|
||||||
|
if (raySphereIntersect(relativeDirection, relativePosition, 1, &t)){
|
||||||
|
result = position + direction * t;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Draws the FBO texture for Oculus rift.
|
// Draws the FBO texture for Oculus rift.
|
||||||
void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
void computeOculusPickRay(float x, float y, glm::vec3& direction) const;
|
void computeOculusPickRay(float x, float y, glm::vec3& direction) const;
|
||||||
void getClickLocation(int &x, int &y) const;
|
void getClickLocation(int &x, int &y) const;
|
||||||
QPoint getOculusPalmClickLocation(const PalmData *palm) const;
|
QPoint getOculusPalmClickLocation(const PalmData *palm) const;
|
||||||
|
bool calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction, glm::vec3& result) const;
|
||||||
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
Loading…
Reference in a new issue