From 0a54c2f1e900e661ee4bd2dbaadf1b85fda1b218 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 9 Oct 2013 11:52:56 -0700 Subject: [PATCH] Tweaking the growing heads. --- interface/src/Application.cpp | 8 ++++---- interface/src/avatar/Avatar.cpp | 26 ++++++++++++++++++++------ interface/src/avatar/Avatar.h | 2 ++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4299fcbf6a..83b5e2fb8c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1644,9 +1644,9 @@ Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, con glm::vec3 headPosition = avatar->getHead().getPosition(); float distance; if (rayIntersectsSphere(mouseRayOrigin, mouseRayDirection, headPosition, - HEAD_SPHERE_RADIUS * avatar->getScale(), distance)) { + HEAD_SPHERE_RADIUS * avatar->getHead().getScale(), distance)) { eyePosition = avatar->getHead().getEyePosition(); - _lookatIndicatorScale = avatar->getScale(); + _lookatIndicatorScale = avatar->getHead().getScale(); _lookatOtherPosition = headPosition; nodeID = avatar->getOwningNode()->getNodeID(); return avatar; @@ -1787,8 +1787,8 @@ void Application::update(float deltaTime) { _faceshift.getEstimatedEyePitch(), _faceshift.getEstimatedEyeYaw(), 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f); } - updateLookatTargetAvatar(lookAtRayOrigin, lookAtRayDirection, lookAtSpot); - if (_lookatTargetAvatar) { + updateLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, lookAtSpot); + if (_lookatTargetAvatar && !_faceshift.isActive()) { // If the mouse is over another avatar's head... _myAvatar.getHead().setLookAtPosition(lookAtSpot); } else if (_isHoverVoxel && !_faceshift.isActive()) { diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 5e95dcafdf..8e452bf979 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -102,6 +102,8 @@ Avatar::Avatar(Node* owningNode) : _leadingAvatar(NULL), _voxels(this), _moving(false), + _hoverOnDuration(0.0f), + _hoverOffDuration(0.0f), _initialized(false), _handHoldingPosition(0.0f, 0.0f, 0.0f), _maxArmLength(0.0f), @@ -388,15 +390,27 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) { } // head scale grows when avatar is looked at + const float BASE_MAX_SCALE = 3.0f; + float maxScale = BASE_MAX_SCALE * glm::distance(_position, Application::getInstance()->getCamera()->getPosition()); if (Application::getInstance()->getLookatTargetAvatar() == this) { - const float BASE_MAX_SCALE = 3.0f; - const float GROW_SPEED = 0.1f; - _head.setScale(min(BASE_MAX_SCALE * glm::distance(_position, Application::getInstance()->getCamera()->getPosition()), - _head.getScale() + deltaTime * GROW_SPEED)); + _hoverOnDuration += deltaTime; + _hoverOffDuration = 0.0f; + + const float GROW_DELAY = 1.0f; + const float GROW_DURATION = 1.0f; + if (_hoverOnDuration > GROW_DELAY) { + _head.setScale(glm::mix(_head.getScale(), maxScale, 0.1f)); + } } else { - const float SHRINK_SPEED = 100.0f; - _head.setScale(max(_scale, _head.getScale() - deltaTime * SHRINK_SPEED)); + _hoverOnDuration = 0.0f; + _hoverOffDuration += deltaTime; + + const float SHRINK_DELAY = 1.0f; + const float SHRINK_DURATION = 1.0f; + if (_hoverOffDuration > SHRINK_DELAY) { + _head.setScale(glm::mix(_head.getScale(), 1.0f, 0.1f)); + } } _head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll)); diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 9396480d27..9f7a70de28 100755 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -226,6 +226,8 @@ protected: AvatarVoxelSystem _voxels; bool _moving; ///< set when position is changing + float _hoverOnDuration; + float _hoverOffDuration; // protected methods... glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }