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;}