From 223d9cf32e47a5fc2996fa754ea5ff3eb8a5f295 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 30 Apr 2014 21:29:50 -0700 Subject: [PATCH] =?UTF-8?q?Added=20back=20ability=20to=20see/debug=20head?= =?UTF-8?q?=20and=20eye=20gaze=20position=20with=20=E2=80=98Head=20Mouse?= =?UTF-8?q?=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interface/src/Application.cpp | 2 +- interface/src/avatar/MyAvatar.cpp | 67 +++++++++++++------------------ interface/src/avatar/MyAvatar.h | 4 +- 3 files changed, 31 insertions(+), 42 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7ee4fdc90d..ba73ffd63a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2704,7 +2704,7 @@ void Application::displayOverlay() { if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) { - _myAvatar->renderHeadMouse(); + _myAvatar->renderHeadMouse(_glWidget->width(), _glWidget->height()); } // Display stats and log text onscreen diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 40e350dcb7..c2d6d331be 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -82,11 +82,8 @@ MyAvatar::~MyAvatar() { } void MyAvatar::reset() { - // TODO? resurrect headMouse stuff? - //_headMouseX = _glWidget->width() / 2; - //_headMouseY = _glWidget->height() / 2; _skeletonModel.reset(); - getHead()->reset(); + getHead()->reset(); getHand()->reset(); _oculusYawOffset = 0.0f; @@ -103,23 +100,7 @@ void MyAvatar::update(float deltaTime) { // Faceshift drive is enabled, set the avatar drive based on the head position moveWithLean(); } - - // Update head mouse from faceshift if active - Faceshift* faceshift = Application::getInstance()->getFaceshift(); - if (faceshift->isActive()) { - // TODO? resurrect headMouse stuff? - //glm::vec3 headVelocity = faceshift->getHeadAngularVelocity(); - //// sets how quickly head angular rotation moves the head mouse - //const float HEADMOUSE_FACESHIFT_YAW_SCALE = 40.0f; - //const float HEADMOUSE_FACESHIFT_PITCH_SCALE = 30.0f; - //_headMouseX -= headVelocity.y * HEADMOUSE_FACESHIFT_YAW_SCALE; - //_headMouseY -= headVelocity.x * HEADMOUSE_FACESHIFT_PITCH_SCALE; - // - //// Constrain head-driven mouse to edges of screen - //_headMouseX = glm::clamp(_headMouseX, 0, _glWidget->width()); - //_headMouseY = glm::clamp(_headMouseY, 0, _glWidget->height()); - } - + // Get audio loudness data from audio input device Audio* audio = Application::getInstance()->getAudio(); head->setAudioLoudness(audio->getLastInputLoudness()); @@ -422,32 +403,41 @@ void MyAvatar::render(const glm::vec3& cameraPosition, RenderMode renderMode) { } } -void MyAvatar::renderHeadMouse() const { - // TODO? resurrect headMouse stuff? - /* +void MyAvatar::renderHeadMouse(int screenWidth, int screenHeight) const { + + Faceshift* faceshift = Application::getInstance()->getFaceshift(); + // Display small target box at center or head mouse target that can also be used to measure LOD + float headPitch = getHead()->getFinalPitch(); + float headYaw = getHead()->getFinalYaw(); + // + // It should be noted that the following constant is a function + // how far the viewer's head is away from both the screen and the size of the screen, + // which are both things we cannot know without adding a calibration phase. + // + const float PIXELS_PER_VERTICAL_DEGREE = 20.0f; + float aspectRatio = (float) screenWidth / (float) screenHeight; + int headMouseX = screenWidth / 2.f - headYaw * aspectRatio * PIXELS_PER_VERTICAL_DEGREE; + int headMouseY = screenHeight / 2.f - headPitch * PIXELS_PER_VERTICAL_DEGREE; + glColor3f(1.0f, 1.0f, 1.0f); glDisable(GL_LINE_SMOOTH); const int PIXEL_BOX = 16; glBegin(GL_LINES); - glVertex2f(_headMouseX - PIXEL_BOX/2, _headMouseY); - glVertex2f(_headMouseX + PIXEL_BOX/2, _headMouseY); - glVertex2f(_headMouseX, _headMouseY - PIXEL_BOX/2); - glVertex2f(_headMouseX, _headMouseY + PIXEL_BOX/2); + glVertex2f(headMouseX - PIXEL_BOX/2, headMouseY); + glVertex2f(headMouseX + PIXEL_BOX/2, headMouseY); + glVertex2f(headMouseX, headMouseY - PIXEL_BOX/2); + glVertex2f(headMouseX, headMouseY + PIXEL_BOX/2); glEnd(); glEnable(GL_LINE_SMOOTH); - glColor3f(1.0f, 0.0f, 0.0f); - glPointSize(3.0f); - glDisable(GL_POINT_SMOOTH); - glBegin(GL_POINTS); - glVertex2f(_headMouseX - 1, _headMouseY + 1); - glEnd(); // If Faceshift is active, show eye pitch and yaw as separate pointer - if (_faceshift.isActive()) { - const float EYE_TARGET_PIXELS_PER_DEGREE = 40.0; - int eyeTargetX = (_glWidget->width() / 2) - _faceshift.getEstimatedEyeYaw() * EYE_TARGET_PIXELS_PER_DEGREE; - int eyeTargetY = (_glWidget->height() / 2) - _faceshift.getEstimatedEyePitch() * EYE_TARGET_PIXELS_PER_DEGREE; + if (faceshift->isActive()) { + float avgEyePitch = faceshift->getEstimatedEyePitch(); + float avgEyeYaw = faceshift->getEstimatedEyeYaw(); + int eyeTargetX = (screenWidth / 2) - avgEyeYaw * aspectRatio * PIXELS_PER_VERTICAL_DEGREE; + int eyeTargetY = (screenHeight / 2) - avgEyePitch * PIXELS_PER_VERTICAL_DEGREE; + glColor3f(0.0f, 1.0f, 1.0f); glDisable(GL_LINE_SMOOTH); glBegin(GL_LINES); @@ -458,7 +448,6 @@ void MyAvatar::renderHeadMouse() const { glEnd(); } - */ } void MyAvatar::setLocalGravity(glm::vec3 gravity) { diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index a5312b0016..0f0fdbf6cd 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -45,7 +45,7 @@ public: void renderBody(RenderMode renderMode); bool shouldRenderHead(const glm::vec3& cameraPosition, RenderMode renderMode) const; void renderDebugBodyPoints(); - void renderHeadMouse() const; + void renderHeadMouse(int screenWidth, int screenHeight) const; // setters void setMousePressed(bool mousePressed) { _mousePressed = mousePressed; } @@ -123,7 +123,7 @@ private: glm::vec3 _gravity; glm::vec3 _environmentGravity; float _distanceToNearestAvatar; // How close is the nearest avatar? - + // motion stuff glm::vec3 _lastCollisionPosition; bool _speedBrakes;