From 3ba93397bdcf9b84060af0cdb45a02645838c692 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Thu, 9 May 2013 14:37:13 -0700 Subject: [PATCH] fixed a bug in menu clicking --- interface/src/Avatar.cpp | 14 ++---- interface/src/AvatarTouch.cpp | 90 ++++++++++++++++++++--------------- interface/src/AvatarTouch.h | 4 ++ interface/src/main.cpp | 6 ++- 4 files changed, 65 insertions(+), 49 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 2679815573..4d821f8184 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -488,11 +488,10 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { _avatarTouch.setYourHandPosition(_interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition); _avatarTouch.setYourHandState (_interactingOther->_handState); - _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = - _interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition; - - //_handHoldingPosition - + if ( _avatarTouch.getAbleToReachOtherAvatar()) { + _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = + _interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition; + } } }//if (_isMine) @@ -512,10 +511,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { } _avatarTouch.setMyHandState(_handState); - - if (_handState == 1) { - _avatarTouch.setMyHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition); - } + _avatarTouch.setMyHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition); } } diff --git a/interface/src/AvatarTouch.cpp b/interface/src/AvatarTouch.cpp index d77c7a0a91..1c8374b9a4 100644 --- a/interface/src/AvatarTouch.cpp +++ b/interface/src/AvatarTouch.cpp @@ -16,13 +16,14 @@ const float THREAD_RADIUS = 0.012; AvatarTouch::AvatarTouch() { - _myHandPosition = glm::vec3(0.0f, 0.0f, 0.0f); - _yourHandPosition = glm::vec3(0.0f, 0.0f, 0.0f); - _myBodyPosition = glm::vec3(0.0f, 0.0f, 0.0f); - _yourBodyPosition = glm::vec3(0.0f, 0.0f, 0.0f); - _myHandState = 0; - _yourHandState = 0; - _reachableRadius = 0.0f; + _myHandPosition = glm::vec3(0.0f, 0.0f, 0.0f); + _yourHandPosition = glm::vec3(0.0f, 0.0f, 0.0f); + _myBodyPosition = glm::vec3(0.0f, 0.0f, 0.0f); + _yourBodyPosition = glm::vec3(0.0f, 0.0f, 0.0f); + _vectorBetweenHands = glm::vec3(0.0f, 0.0f, 0.0f); + _myHandState = 0; + _yourHandState = 0; + _reachableRadius = 0.0f; _canReachToOtherAvatar = false; _handsCloseEnoughToGrasp = false; @@ -60,15 +61,17 @@ void AvatarTouch::setReachableRadius(float r) { _reachableRadius = r; } - void AvatarTouch::render(glm::vec3 cameraPosition) { if (_canReachToOtherAvatar) { + glColor4f(0.3, 0.4, 0.5, 0.5); glm::vec3 p(_yourBodyPosition); p.y = 0.0005f; renderCircle(p, _reachableRadius, glm::vec3(0.0f, 1.0f, 0.0f), 30); + renderBeamBetweenHands(); + // if your hand is grasping, show it... if (_yourHandState == 1) { glPushMatrix(); @@ -78,28 +81,7 @@ if (_canReachToOtherAvatar) { glColor4f(1.0, 1.0, 0.2, 0.1); glutSolidSphere(0.030f, 10.0f, 10.0f); glPopMatrix(); } - - //show beam - glm::vec3 v1(_myHandPosition); - glm::vec3 v2(_yourHandPosition); - - if (_handsCloseEnoughToGrasp) { - glLineWidth(2.0); - glColor4f(0.7f, 0.4f, 0.1f, 0.3); - glBegin(GL_LINE_STRIP); - glVertex3f(v1.x, v1.y, v1.z); - glVertex3f(v2.x, v2.y, v2.z); - glEnd(); - - glColor4f(1.0f, 1.0f, 0.0f, 0.8); - - for (int p=0; p