faceshift drives head mouse, improved reticle

This commit is contained in:
PhilipRosedale 2013-10-02 10:46:31 -07:00
parent 99c866dba4
commit 6d2585a732

View file

@ -2069,16 +2069,15 @@ void Application::updateAvatar(float deltaTime) {
// Update head mouse from faceshift if active // Update head mouse from faceshift if active
if (_faceshift.isActive()) { if (_faceshift.isActive()) {
//glm::quat headRotation = _faceshift.getHeadRotation(); glm::vec3 headVelocity = _faceshift.getHeadAngularVelocity();
/*
_headMouseX = _glWidget->getWidth() / 2 + _faceshift.getHeadAngularVelocity() // sets how quickly head angular rotation moves the head mouse
_headMouseX = max(_headMouseX, 0); const float HEADMOUSE_FACESHIFT_YAW_SCALE = 40.f;
_headMouseX = min(_headMouseX, _glWidget->width()); const float HEADMOUSE_FACESHIFT_PITCH_SCALE = 30.f;
_headMouseY = max(_headMouseY, 0); _headMouseX -= headVelocity.y * HEADMOUSE_FACESHIFT_YAW_SCALE;
_headMouseY = min(_headMouseY, _glWidget->height()); _headMouseY -= headVelocity.x * HEADMOUSE_FACESHIFT_PITCH_SCALE;
*/
} }
if (_serialHeadSensor.isActive()) { if (_serialHeadSensor.isActive()) {
// Grab latest readings from the gyros // Grab latest readings from the gyros
@ -2094,10 +2093,6 @@ void Application::updateAvatar(float deltaTime) {
_headMouseX -= measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime; _headMouseX -= measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime;
_headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime; _headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime;
} }
_headMouseX = max(_headMouseX, 0);
_headMouseX = min(_headMouseX, _glWidget->width());
_headMouseY = max(_headMouseY, 0);
_headMouseY = min(_headMouseY, _glWidget->height());
const float MIDPOINT_OF_SCREEN = 0.5; const float MIDPOINT_OF_SCREEN = 0.5;
@ -2117,6 +2112,13 @@ void Application::updateAvatar(float deltaTime) {
} }
} }
// Constrain head-driven mouse to edges of screen
_headMouseX = max(_headMouseX, 0);
_headMouseX = min(_headMouseX, _glWidget->width());
_headMouseY = max(_headMouseY, 0);
_headMouseY = min(_headMouseY, _glWidget->height());
if (OculusManager::isConnected()) { if (OculusManager::isConnected()) {
float yaw, pitch, roll; float yaw, pitch, roll;
@ -2668,15 +2670,20 @@ void Application::displayOverlay() {
// Display small target box at center or head mouse target that can also be used to measure LOD // Display small target box at center or head mouse target that can also be used to measure LOD
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
glDisable(GL_LINE_SMOOTH); glDisable(GL_LINE_SMOOTH);
const int PIXEL_BOX = 20; const int PIXEL_BOX = 16;
glBegin(GL_LINE_STRIP); glBegin(GL_LINES);
glVertex2f(_headMouseX - PIXEL_BOX/2, _headMouseY - PIXEL_BOX/2); glVertex2f(_headMouseX - PIXEL_BOX/2, _headMouseY);
glVertex2f(_headMouseX + PIXEL_BOX/2, _headMouseY - PIXEL_BOX/2); glVertex2f(_headMouseX + PIXEL_BOX/2, _headMouseY);
glVertex2f(_headMouseX + PIXEL_BOX/2, _headMouseY + PIXEL_BOX/2); glVertex2f(_headMouseX, _headMouseY - PIXEL_BOX/2);
glVertex2f(_headMouseX - PIXEL_BOX/2, _headMouseY + PIXEL_BOX/2); glVertex2f(_headMouseX, _headMouseY + PIXEL_BOX/2);
glVertex2f(_headMouseX - PIXEL_BOX/2, _headMouseY - PIXEL_BOX/2);
glEnd(); glEnd();
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
glColor3f(1.f, 0.f, 0.f);
glPointSize(3.0f);
glDisable(GL_POINT_SMOOTH);
glBegin(GL_POINTS);
glVertex2f(_headMouseX - 1, _headMouseY + 1);
glEnd();
} }
// Show detected levels from the serial I/O ADC channel sensors // Show detected levels from the serial I/O ADC channel sensors