From 29062c51b207f60d51a28998627f3e1edcae210c Mon Sep 17 00:00:00 2001 From: atlante45 Date: Mon, 5 Aug 2013 15:23:40 -0700 Subject: [PATCH] - changed according to review comments - added reset scale option --- .../OpenCV/lib/UNIX/libopencv_highgui.a | Bin 422988 -> 421520 bytes interface/src/Application.cpp | 20 ++++++++------ interface/src/Application.h | 1 + interface/src/Camera.cpp | 4 +-- interface/src/Camera.h | 26 +++++++++--------- interface/src/avatar/Avatar.cpp | 5 ++-- interface/src/avatar/Avatar.h | 9 +++++- 7 files changed, 38 insertions(+), 27 deletions(-) diff --git a/interface/external/OpenCV/lib/UNIX/libopencv_highgui.a b/interface/external/OpenCV/lib/UNIX/libopencv_highgui.a index 4eaf323c3260dd977c193ca5a9db301cd44fe03b..bb0330bec3de2730c1f218a37d6f5642a2ec271e 100644 GIT binary patch delta 2098 zcmX@}LUO`g$qCZa-_K#?tT#{q0c27^!O+ay!~!gyz{SA8_=$nRsf|Xso>m4EX>L7C z;Zi1sfxz`7Tl(`H0~K*SH4Vcsi_t%e0InybfOvT(KLOHlJvo|?^=wbzj%jW%#?fV@W+xI&%weNRi TZr|_7(!Sr3b^Crtwud?Zg{Ch% delta 2681 zcmchZPe>F|9LIle=FK?%TPNLG7uTFFVy@}zI_{#U9W`1!R6-pJVq0w`Q7j@N0(pkj zA{{bT{9V-a&~-=x>ri5J3Oqz~tjHh`O4;g=9io_B|16X?`^SFp`OS~_zVG`R-g}2P z`qsI)>>RCNO@6Q6r+E}bRm@1uisJG4eOhAtYyklI2GBa5TUf3Q)AVD1EVy3^{}GmX zvmfsudsr?^{_R1IUHdz1yNN8uxuc3@SUTbzwR2A(16U@Da=3=2XU3ntnp@a*hTq2^ z8))NkOE9a#v~<%FScF*>TGk0Jdm6BG#2IQQ-oUo7ohGxH`!oSoU{*xCsA0QlZoxZ0 zDG~>!AIj3b=E6{@=Uk-!a;W=!->{)a4V^>{or@YeA2oCuHFV*Tp^G2tnl@$i7aGhL zf~V1MJ|#3&QxuP?swvs0nPZL3UImxtxQ4D80-F&?Q~@Z0d^i~#`4}AjEC)vh*Mipv z*M9K;R|+1Rie)neZy#O@K3f)FJO_XyZEY<|O?#xPH$0$d_5OPAA?;wY0EoSx-CyYf z024E6&7|ApTU=YQ7%9q=@Mo(~MK4AA!x-=2YH^`VEWx5XTmTo`BoAMn5h%7#QWvR3 z&k9$Cfk{g7#42as8xWF~<;f2e006Q^!j*?5_BVCO35!1yzP?lJqN zHqFDOr@R|4mWvWOg)>vskMX{BU3~rL3IRaE@I3G4$^~3JK&r=Qco(V@f;Sewp^kfr z8dGkTI*S3I6t>PKv0nh-#Muh!Xo9WN?uL{r0wMFFgnGig{fUMf+sy$$J}!Ob%Ve`O G*@)i?ueCG) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3c4b531cf0..4edaa74325 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1389,21 +1389,22 @@ void Application::setRenderThirdPerson(bool thirdPerson) { } void Application::increaseAvatarSize() { - if (5.0f < 1.05f * _myAvatar.getNewScale()) { - return; + if ((1.f + SCALING_RATIO) * _myAvatar.getNewScale() < MAX_SCALE) { + _myAvatar.setNewScale((1.f + SCALING_RATIO) * _myAvatar.getNewScale()); + qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); } - - _myAvatar.setNewScale(1.05f * _myAvatar.getNewScale()); - qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); } void Application::decreaseAvatarSize() { - if (.95f * _myAvatar.getNewScale() < 0.15f) { - return; + if (MIN_SCALE < (1.f - SCALING_RATIO) * _myAvatar.getNewScale()) { + _myAvatar.setNewScale((1.f - SCALING_RATIO) * _myAvatar.getNewScale()); + qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); } +} - _myAvatar.setNewScale(.95f * _myAvatar.getNewScale()); - qDebug("Changed scale to %f\n", _myAvatar.getNewScale()); +void Application::resetAvatarSize() { + _myAvatar.setNewScale(1.f); + qDebug("Reseted scale to %f\n", _myAvatar.getNewScale()); } void Application::setFrustumOffset(bool frustumOffset) { @@ -1981,6 +1982,7 @@ void Application::initMenu() { "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true); renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus); renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus); + renderMenu->addAction("Reset Avatar Size", this, SLOT(resetAvatarSize())); QMenu* toolsMenu = menuBar->addMenu("Tools"); diff --git a/interface/src/Application.h b/interface/src/Application.h index 1e84de91e8..5987a13900 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -134,6 +134,7 @@ private slots: void setRenderThirdPerson(bool thirdPerson); void increaseAvatarSize(); void decreaseAvatarSize(); + void resetAvatarSize(); void renderThrustAtVoxel(const glm::vec3& thrust); void renderLineToTouchedVoxel(); diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index f71fcb1e7d..3fdb401751 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -105,7 +105,7 @@ void Camera::updateFollowMode(float deltaTime) { } } -float Camera::getFarClip() { +float Camera::getFarClip() const { return (_scale * _farClip < std::numeric_limits::max()) ? _scale * _farClip : std::numeric_limits::max() - 1; @@ -194,7 +194,7 @@ void Camera::initialize() { } // call to find out if the view frustum needs to be reshaped -bool Camera::getFrustumNeedsReshape() { +bool Camera::getFrustumNeedsReshape() const { return _frustumNeedsReshape; } diff --git a/interface/src/Camera.h b/interface/src/Camera.h index d11b49c88c..de4553b6dc 100644 --- a/interface/src/Camera.h +++ b/interface/src/Camera.h @@ -48,20 +48,20 @@ public: void setEyeOffsetOrientation( const glm::quat& o ); void setScale ( const float s ); - const glm::vec3& getTargetPosition () { return _targetPosition; } - const glm::vec3& getPosition () { return _position; } - const glm::quat& getTargetRotation () { return _targetRotation; } - const glm::quat& getRotation () { return _rotation; } - CameraMode getMode () { return _mode; } - float getFieldOfView () { return _fieldOfView; } - float getAspectRatio () { return _aspectRatio; } - float getNearClip () { return _scale * _nearClip; } - float getFarClip (); - const glm::vec3& getEyeOffsetPosition () { return _eyeOffsetPosition; } - const glm::quat& getEyeOffsetOrientation () { return _eyeOffsetOrientation; } - float getScale () { return _scale; } + const glm::vec3& getTargetPosition () const { return _targetPosition; } + const glm::vec3& getPosition () const { return _position; } + const glm::quat& getTargetRotation () const { return _targetRotation; } + const glm::quat& getRotation () const { return _rotation; } + CameraMode getMode () const { return _mode; } + float getFieldOfView () const { return _fieldOfView; } + float getAspectRatio () const { return _aspectRatio; } + float getNearClip () const { return _scale * _nearClip; } + float getFarClip () const; + const glm::vec3& getEyeOffsetPosition () const { return _eyeOffsetPosition; } + const glm::quat& getEyeOffsetOrientation () const { return _eyeOffsetOrientation; } + float getScale () const { return _scale; } - bool getFrustumNeedsReshape(); // call to find out if the view frustum needs to be reshaped + bool getFrustumNeedsReshape() const; // call to find out if the view frustum needs to be reshaped void setFrustumWasReshaped(); // call this after reshaping the view frustum. private: diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 97dbaac228..26192ffe5a 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -529,7 +529,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) { } if (isMyAvatar() && _scale != _newScale) { - float scale = 0.95f * _scale + 0.05f * _newScale; + float scale = (1.f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _newScale; setScale(scale); Application::getInstance()->getCamera()->setScale(scale); } @@ -1539,7 +1539,8 @@ void Avatar::setNewScale(const float scale) { void Avatar::setScale(const float scale) { _scale = scale; - if (_newScale * .98 < _scale && _scale < _newScale * 1.02) { + if (_newScale * (1.f - RESCALING_TOLERANCE) < _scale && + _scale < _newScale * (1.f + RESCALING_TOLERANCE)) { _scale = _newScale; } diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 1ac2a376bf..b490429ec9 100755 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -26,6 +26,13 @@ #include "Transmitter.h" #include "world.h" + +static const float MAX_SCALE = 5.f; +static const float MIN_SCALE = .5f; +static const float SCALING_RATIO = .05f; +static const float SMOOTHING_RATIO = .05f; // 0 < ratio < 1 +static const float RESCALING_TOLERANCE = .02f; + const float BODY_BALL_RADIUS_PELVIS = 0.07; const float BODY_BALL_RADIUS_TORSO = 0.065; const float BODY_BALL_RADIUS_CHEST = 0.08; @@ -134,7 +141,6 @@ public: void setGravity (glm::vec3 gravity); void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction); void setOrientation (const glm::quat& orientation); - void setScale (const float scale); void setNewScale (const float scale); //getters @@ -283,6 +289,7 @@ private: void updateCollisionSound(const glm::vec3& penetration, float deltaTime, float frequency); void applyCollisionWithOtherAvatar( Avatar * other, float deltaTime ); void checkForMouseRayTouching(); + void setScale (const float scale); }; #endif