mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-13 20:43:45 +02:00
working on hand holding algo
This commit is contained in:
parent
474423e33f
commit
619c1a843f
2 changed files with 25 additions and 25 deletions
|
@ -529,21 +529,25 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
//if holding hands, apply the appropriate forces
|
||||
if (_avatarTouch.getHoldingHands()) {
|
||||
|
||||
/*
|
||||
glm::vec3 vectorToOtherHand = _interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition - _handHoldingPosition;
|
||||
glm::vec3 vectorToMyHand = _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position - _handHoldingPosition;
|
||||
glm::vec3 vectorToMyHand = _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition - _handHoldingPosition;
|
||||
|
||||
float myInfluence = 30.0f;
|
||||
float yourInfluence = 30.0f;
|
||||
float force = 200.0 * deltaTime;
|
||||
|
||||
glm::vec3 myForce = vectorToMyHand * myInfluence * deltaTime;
|
||||
glm::vec3 yourForce = vectorToOtherHand * yourInfluence * deltaTime;
|
||||
|
||||
if (_handState == HAND_STATE_GRASPING) {myForce *= 2.0f; }
|
||||
if (_interactingOther->_handState == HAND_STATE_GRASPING) {yourForce *= 2.0f; }
|
||||
force = 1.0f;
|
||||
|
||||
if (force > 0.9f) { force = 0.9f; }
|
||||
|
||||
_handHoldingPosition += myForce + yourForce;
|
||||
_handHoldingPosition += vectorToMyHand * force + vectorToOtherHand * force;
|
||||
|
||||
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = _handHoldingPosition;
|
||||
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = _handHoldingPosition;
|
||||
*/
|
||||
|
||||
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position =
|
||||
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position +
|
||||
( _interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position - _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position) * 0.5f;
|
||||
|
||||
} else {
|
||||
_handHoldingPosition = _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position;
|
||||
}
|
||||
|
|
|
@ -13,20 +13,19 @@
|
|||
#include "Util.h"
|
||||
|
||||
const float THREAD_RADIUS = 0.012;
|
||||
const float HANDS_CLOSE_ENOUGH_TO_GRASP = 0.1;
|
||||
const float HANDS_CLOSE_ENOUGH_TO_GRASP = 0.2;
|
||||
|
||||
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);
|
||||
_vectorBetweenHands = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
_myHandState = HAND_STATE_NULL;
|
||||
_yourHandState = HAND_STATE_NULL;
|
||||
_reachableRadius = 0.0f;
|
||||
_weAreHoldingHands = false;
|
||||
|
||||
_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 = HAND_STATE_NULL;
|
||||
_yourHandState = HAND_STATE_NULL;
|
||||
_reachableRadius = 0.0f;
|
||||
_weAreHoldingHands = false;
|
||||
_canReachToOtherAvatar = false;
|
||||
_handsCloseEnoughToGrasp = false;
|
||||
|
||||
|
@ -63,7 +62,6 @@ void AvatarTouch::setReachableRadius(float r) {
|
|||
_reachableRadius = r;
|
||||
}
|
||||
|
||||
|
||||
void AvatarTouch::simulate (float deltaTime) {
|
||||
|
||||
glm::vec3 vectorBetweenBodies = _yourBodyPosition - _myBodyPosition;
|
||||
|
@ -83,9 +81,7 @@ void AvatarTouch::simulate (float deltaTime) {
|
|||
} else {
|
||||
_canReachToOtherAvatar = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AvatarTouch::render(glm::vec3 cameraPosition) {
|
||||
|
||||
|
|
Loading…
Reference in a new issue