Align chat with full camera rotation (not just yaw).

This commit is contained in:
Andrzej Kapolka 2013-05-30 13:46:53 -07:00
parent 27f4674c10
commit bcd3833898
4 changed files with 12 additions and 15 deletions

View file

@ -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());
}

View file

@ -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(); }

View file

@ -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);

View file

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