From bcd3833898057d4d8db13c87e7300be2a4bdcb2a Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 30 May 2013 13:46:53 -0700 Subject: [PATCH 1/2] Align chat with full camera rotation (not just yaw). --- interface/src/Application.cpp | 4 ++-- interface/src/Application.h | 1 + interface/src/Avatar.cpp | 20 ++++++++------------ interface/src/Avatar.h | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3def951b14..e023cce81f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1667,13 +1667,13 @@ void Application::displaySide(Camera& whichCamera) { for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) { if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) { Avatar *avatar = (Avatar *)agent->getLinkedData(); - avatar->render(false, _myCamera.getPosition()); + avatar->render(false); } } agentList->unlock(); // Render my own Avatar - _myAvatar.render(_lookingInMirror->isChecked(), _myCamera.getPosition()); + _myAvatar.render(_lookingInMirror->isChecked()); _myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked()); } diff --git a/interface/src/Application.h b/interface/src/Application.h index f611a803b9..64959f1274 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -63,6 +63,7 @@ public: void wheelEvent(QWheelEvent* event); Avatar* getAvatar() { return &_myAvatar; } + Camera* getCamera() { return &_myCamera; } VoxelSystem* getVoxels() { return &_voxels; } Environment* getEnvironment() { return &_environment; } bool shouldEchoAudio() { return _echoAudioMode->isChecked(); } diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 7aaee8d62e..8f6ac7c991 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -758,9 +758,9 @@ void Avatar::setGravity(glm::vec3 gravity) { } } -void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) { +void Avatar::render(bool lookingInMirror) { - _cameraPosition = cameraPosition; + _cameraPosition = Application::getInstance()->getCamera()->getPosition(); if (!_owningAgent && usingBigSphereCollisionTest) { // show TEST big sphere @@ -799,18 +799,14 @@ void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) { } glPushMatrix(); - // extract the view direction from the modelview matrix: transform (0, 0, 1) by the - // transpose of the modelview to get its direction in world space, then use the X/Z - // components to determine the angle - float modelview[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, modelview); - - glTranslatef(_joint[AVATAR_JOINT_HEAD_BASE].springyPosition.x, - _joint[AVATAR_JOINT_HEAD_BASE].springyPosition.y + chatMessageHeight, - _joint[AVATAR_JOINT_HEAD_BASE].springyPosition.z); - glRotatef(atan2(-modelview[2], -modelview[10]) * 180 / PI, 0, 1, 0); + glm::vec3 chatPosition = _joint[AVATAR_JOINT_HEAD_BASE].springyPosition + getBodyUpDirection() * chatMessageHeight; + glTranslatef(chatPosition.x, chatPosition.y, chatPosition.z); + glm::quat chatRotation = Application::getInstance()->getCamera()->getRotation(); + glm::vec3 chatAxis = glm::axis(chatRotation); + glRotatef(glm::angle(chatRotation), chatAxis.x, chatAxis.y, chatAxis.z); glColor3f(0, 0.8, 0); + glRotatef(180, 0, 1, 0); glRotatef(180, 0, 0, 1); glScalef(chatMessageScale, chatMessageScale, 1.0f); diff --git a/interface/src/Avatar.h b/interface/src/Avatar.h index 262051655e..db8176898a 100644 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -51,7 +51,7 @@ public: void updateHeadFromGyros(float frametime, SerialInterface * serialInterface, glm::vec3 * gravity); void updateFromMouse(int mouseX, int mouseY, int screenWidth, int screenHeight); void addBodyYaw(float y) {_bodyYaw += y;}; - void render(bool lookingInMirror, glm::vec3 cameraPosition); + void render(bool lookingInMirror); //setters void setMousePressed (bool mousePressed ) { _mousePressed = mousePressed;} From f447230d26b28be3495424d7bf6366291d8032f2 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 30 May 2013 14:14:01 -0700 Subject: [PATCH 2/2] Use body orientation, not head orientation, for mirror mode. --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e023cce81f..1e9e119777 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -288,7 +288,7 @@ void Application::paintGL() { if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { _myCamera.setTightness (100.0f); _myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition()); - _myCamera.setTargetRotation(_myAvatar.getHead().getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); + _myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); } else if (OculusManager::isConnected()) { _myCamera.setUpShift (0.0f);