mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #2756 from PhilipRosedale/master
Added back ability to see/debug head/gaze position with ‘Head Mouse'
This commit is contained in:
commit
2ad31793e2
3 changed files with 31 additions and 42 deletions
|
@ -2711,7 +2711,7 @@ void Application::displayOverlay() {
|
|||
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) {
|
||||
_myAvatar->renderHeadMouse();
|
||||
_myAvatar->renderHeadMouse(_glWidget->width(), _glWidget->height());
|
||||
}
|
||||
|
||||
// Display stats and log text onscreen
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
void renderBody(RenderMode renderMode, float glowLevel = 0.0f);
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue