use a ray from the near clip for action ray

This commit is contained in:
Stephen Birarda 2014-11-04 11:40:47 -08:00
parent 8452182b45
commit f53455ee55
6 changed files with 17 additions and 6 deletions

View file

@ -81,7 +81,8 @@ function drawLobby() {
size: RETICLE_SPHERE_SIZE,
color: { red: 0, green: 255, blue: 0 },
alpha: 1.0,
solid: true
solid: true,
ignoreRayIntersection: true
});
// add an attachment on this avatar so other people see them in the lobby
@ -128,6 +129,7 @@ function cleanupLobby() {
function actionStartEvent(event) {
if (panelWall) {
// we've got an action event and our panel wall is up
// check if we hit a panel and if we should jump there
var result = Overlays.findRayIntersection(event.actionRay);

View file

@ -1117,7 +1117,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
if (!event->isAutoRepeat()) {
// this starts an HFActionEvent
HFActionEvent startActionEvent(HFActionEvent::startType(),
Application::getInstance()->getCamera()->getPickRay());
_viewFrustum.computePickRay(0.5f, 0.5f));
sendEvent(this, &startActionEvent);
}
@ -1208,7 +1208,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
case Qt::Key_Space: {
if (!event->isAutoRepeat()) {
// this ends the HFActionEvent
HFActionEvent endActionEvent(HFActionEvent::endType(), Application::getInstance()->getCamera()->getPickRay());
HFActionEvent endActionEvent(HFActionEvent::endType(), _viewFrustum.computePickRay(0.5f, 0.5f));
sendEvent(this, &endActionEvent);
}

View file

@ -56,8 +56,6 @@ public:
void setEyeOffsetOrientation(const glm::quat& o) { _eyeOffsetOrientation = o; }
void setScale(const float s) { _scale = s; }
PickRay getPickRay() const { return PickRay(getPosition(), getRotation() * IDENTITY_FRONT); }
glm::vec3 getPosition() const { return _position + _hmdPosition; }
glm::quat getRotation() const { return _rotation * _hmdRotation; }
const glm::vec3& getHmdPosition() const { return _hmdPosition; }

View file

@ -129,7 +129,8 @@ void JoystickScriptingInterface::update() {
: HFActionEvent::endType();
// global action events fire in the center of the screen
HFActionEvent actionEvent(actionType, Application::getInstance()->getCamera()->getPickRay());
HFActionEvent actionEvent(actionType,
Application::getInstance()->getViewFrustum()->computePickRay(0.5f, 0.5f));
qApp->sendEvent(qApp, &actionEvent);
}

View file

@ -583,6 +583,13 @@ bool ViewFrustum::isVerySimilar(const ViewFrustum& compareTo, bool debug) const
return result;
}
PickRay ViewFrustum::computePickRay(float x, float y) {
glm::vec3 pickRayOrigin;
glm::vec3 pickRayDirection;
computePickRay(x, y, pickRayOrigin, pickRayDirection);
return PickRay(pickRayOrigin, pickRayDirection);
}
void ViewFrustum::computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const {
origin = _nearTopLeft + x*(_nearTopRight - _nearTopLeft) + y*(_nearBottomLeft - _nearTopLeft);
direction = glm::normalize(origin - (_position + _orientation * _eyeOffsetPosition));

View file

@ -17,6 +17,8 @@
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <RegisteredMetaTypes.h>
#include "AABox.h"
#include "AACube.h"
#include "Plane.h"
@ -105,6 +107,7 @@ public:
bool isVerySimilar(const ViewFrustum& compareTo, bool debug = false) const;
bool isVerySimilar(const ViewFrustum* compareTo, bool debug = false) const { return isVerySimilar(*compareTo, debug); }
PickRay computePickRay(float x, float y);
void computePickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const;
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearValue, float& farValue,