From b1e975e96b8929c368c4f61e717ebab1336bf642 Mon Sep 17 00:00:00 2001 From: atlante45 Date: Thu, 8 Aug 2013 15:48:33 -0700 Subject: [PATCH 1/3] Don't show pie menu when on voxel --- 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 b9ac953767..0998011e11 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -943,7 +943,7 @@ void Application::mousePressEvent(QMouseEvent* event) { maybeEditVoxelUnderCursor(); - if (!_palette.isActive()) { + if (!_palette.isActive() && (!_isHoverVoxel || _isLookingAtOtherAvatar)) { _pieMenu.mousePressEvent(_mouseX, _mouseY); } From f5fe965093b1ee25f5724d2619505f02682da97d Mon Sep 17 00:00:00 2001 From: atlante45 Date: Thu, 8 Aug 2013 15:49:35 -0700 Subject: [PATCH 2/3] Position based follow mode whith head movement --- interface/src/avatar/Avatar.cpp | 49 +++++++++++++++++++++------------ interface/src/avatar/Head.h | 5 ++-- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index ead86085a0..ddc7b9926d 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -297,7 +297,6 @@ void Avatar::reset() { // Update avatar head rotation with sensor data void Avatar::updateFromGyrosAndOrWebcam(bool gyroLook, float pitchFromTouch) { - _head.setMousePitch(pitchFromTouch); SerialInterface* gyros = Application::getInstance()->getSerialHeadSensor(); Webcam* webcam = Application::getInstance()->getWebcam(); glm::vec3 estimatedPosition, estimatedRotation; @@ -307,11 +306,17 @@ void Avatar::updateFromGyrosAndOrWebcam(bool gyroLook, } else if (webcam->isActive()) { estimatedRotation = webcam->getEstimatedRotation(); + } else if (_leadingAvatar) { + _head.getFace().clearFrame(); + return; } else { + _head.setMousePitch(pitchFromTouch); _head.setPitch(pitchFromTouch); _head.getFace().clearFrame(); return; } + _head.setMousePitch(pitchFromTouch); + if (webcam->isActive()) { estimatedPosition = webcam->getEstimatedPosition(); @@ -426,33 +431,43 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) { _shouldJump = false; } + // Add thrusts from leading avatar + const float FOLLOWING_RATE = .02f; + if (_leadingAvatar != NULL) { glm::vec3 toTarget = _leadingAvatar->getPosition() - _position; - if (.5f < up.x * toTarget.x + up.y * toTarget.y + up.z * toTarget.z) { - _thrust += _scale * THRUST_MAG_UP * deltaTime * up; - } else if (up.x * toTarget.x + up.y * toTarget.y + up.z * toTarget.z < -.5f) { - _thrust -= _scale * THRUST_MAG_UP * deltaTime * up; - } - if (glm::length(_position - _leadingAvatar->getPosition()) > _scale * _stringLength) { - _thrust += _scale * THRUST_MAG_FWD * deltaTime * front; + _position += toTarget * FOLLOWING_RATE; } else { - toTarget = _leadingAvatar->getHead().getLookAtPosition() - _position; - getHead().setLookAtPosition(_leadingAvatar->getHead().getLookAtPosition()); + toTarget = _leadingAvatar->getHead().getLookAtPosition() - _head.getPosition(); } + toTarget = glm::vec3(glm::dot(right, toTarget), + glm::dot(up , toTarget), + glm::dot(front, toTarget)); - float yawAngle = angleBetween(front, glm::vec3(toTarget.x, 0.f, toTarget.z)); - if (yawAngle < -10.f || 10.f < yawAngle){ - if (right.x * toTarget.x + right.y * toTarget.y + right.z * toTarget.z > 0) { - _bodyYawDelta -= YAW_MAG * deltaTime; + float yawAngle = angleBetween(-IDENTITY_FRONT, glm::vec3(toTarget.x, 0.f, toTarget.z)); + if (5.f < glm::abs(yawAngle)){ + if (IDENTITY_RIGHT.x * toTarget.x + IDENTITY_RIGHT.y * toTarget.y + IDENTITY_RIGHT.z * toTarget.z > 0) { + _bodyYawDelta -= yawAngle; } else { - _bodyYawDelta += YAW_MAG * deltaTime; + _bodyYawDelta += yawAngle; } } + + float pitchAngle = glm::abs(90.f - angleBetween(IDENTITY_UP, toTarget)); + if (1.f < glm::abs(pitchAngle) && yawAngle < 30.f){ + if (IDENTITY_UP.x * toTarget.x + IDENTITY_UP.y * toTarget.y + IDENTITY_UP.z * toTarget.z > 0) { + _head.setMousePitch(_head.getMousePitch() + .10f * pitchAngle); + } else { + _head.setMousePitch(_head.getMousePitch() - .10f * pitchAngle); + } + _head.setPitch(_head.getMousePitch()); + } } - + + // Add thrusts from Transmitter if (transmitter) { transmitter->checkForLostTransmitter(); @@ -533,7 +548,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter, float gyroCamer follow(NULL); } - // Ajust, scale, thrust and lookAt position when following an other avatar + // Ajust, scale, position and lookAt position when following an other avatar if (isMyAvatar() && _leadingAvatar && _newScale != _leadingAvatar->getScale()) { _newScale = _leadingAvatar->getScale(); } diff --git a/interface/src/avatar/Head.h b/interface/src/avatar/Head.h index 60fc2864ed..31efc21d48 100644 --- a/interface/src/avatar/Head.h +++ b/interface/src/avatar/Head.h @@ -57,8 +57,9 @@ public: void setCameraFollowsHead(bool cameraFollowsHead) { _cameraFollowsHead = cameraFollowsHead; } - void setMousePitch(float mousePitch) { _mousePitch = mousePitch; } - + float getMousePitch() { return _mousePitch; } + void setMousePitch(float mousePitch) { _mousePitch = mousePitch; } + glm::quat getOrientation() const; glm::quat getCameraOrientation () const; From 521eb196255cefc848d194e2aabcd9a47d1d5a52 Mon Sep 17 00:00:00 2001 From: atlante45 Date: Thu, 8 Aug 2013 16:22:26 -0700 Subject: [PATCH 3/3] PR comments + Changed MIN and MAX scale --- interface/src/avatar/Avatar.cpp | 16 ++++++++++------ interface/src/avatar/Avatar.h | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index ddc7b9926d..e561720eaf 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -433,7 +433,11 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) { // Add thrusts from leading avatar - const float FOLLOWING_RATE = .02f; + const float FOLLOWING_RATE = 0.02f; + const float MIN_YAW = 5.0f; + const float MIN_PITCH = 1.0f; + const float PITCH_RATE = 0.1f; + const float MIN_YAW_BEFORE_PITCH = 30.0f; if (_leadingAvatar != NULL) { glm::vec3 toTarget = _leadingAvatar->getPosition() - _position; @@ -448,7 +452,7 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) { glm::dot(front, toTarget)); float yawAngle = angleBetween(-IDENTITY_FRONT, glm::vec3(toTarget.x, 0.f, toTarget.z)); - if (5.f < glm::abs(yawAngle)){ + if (glm::abs(yawAngle) > MIN_YAW){ if (IDENTITY_RIGHT.x * toTarget.x + IDENTITY_RIGHT.y * toTarget.y + IDENTITY_RIGHT.z * toTarget.z > 0) { _bodyYawDelta -= yawAngle; } else { @@ -456,12 +460,12 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) { } } - float pitchAngle = glm::abs(90.f - angleBetween(IDENTITY_UP, toTarget)); - if (1.f < glm::abs(pitchAngle) && yawAngle < 30.f){ + float pitchAngle = glm::abs(90.0f - angleBetween(IDENTITY_UP, toTarget)); + if (glm::abs(pitchAngle) > MIN_PITCH && yawAngle < MIN_YAW_BEFORE_PITCH){ if (IDENTITY_UP.x * toTarget.x + IDENTITY_UP.y * toTarget.y + IDENTITY_UP.z * toTarget.z > 0) { - _head.setMousePitch(_head.getMousePitch() + .10f * pitchAngle); + _head.setMousePitch(_head.getMousePitch() + PITCH_RATE * pitchAngle); } else { - _head.setMousePitch(_head.getMousePitch() - .10f * pitchAngle); + _head.setMousePitch(_head.getMousePitch() - PITCH_RATE * pitchAngle); } _head.setPitch(_head.getMousePitch()); } diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 155028c43f..29a79047ed 100755 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -27,8 +27,8 @@ #include "world.h" -static const float MAX_SCALE = 10.f; -static const float MIN_SCALE = .5f; +static const float MAX_SCALE = 1000.f; +static const float MIN_SCALE = .005f; static const float SCALING_RATIO = .05f; static const float SMOOTHING_RATIO = .05f; // 0 < ratio < 1 static const float RESCALING_TOLERANCE = .02f;