From 61d7a82fc6020b79f5916823788a4467e38632fc Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Tue, 23 Apr 2013 20:44:12 -0700 Subject: [PATCH] made lots of changes in the logic of how my avatar encounters other avatars and detects hand state --- interface/src/Head.cpp | 107 +++++++++++++++++++---------------------- interface/src/Head.h | 97 ++++++++++++++++++++----------------- 2 files changed, 102 insertions(+), 102 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index f4269a47bd..f93389511c 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -50,7 +50,7 @@ Head::Head(bool isMine) { _velocity = glm::vec3( 0.0, 0.0, 0.0 ); _thrust = glm::vec3( 0.0, 0.0, 0.0 ); _rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f ); - _closestOtherAvatar = 0; + _nearOtherAvatar = false; _bodyYaw = -90.0; _bodyPitch = 0.0; _bodyRoll = 0.0; @@ -62,7 +62,7 @@ Head::Head(bool isMine) { //_transmitterTimer = 0; _transmitterHz = 0.0; _transmitterPackets = 0; - _numOtherAvatarsInView = 0; + //_numOtherAvatars = 0; initializeSkeleton(); @@ -119,13 +119,11 @@ Head::Head(bool isMine) { _renderPitch = 0.0; _sphere = NULL; - - _collisionElipsoid.colliding = false; - _collisionElipsoid.position = glm::vec3( 0.0, 0.0, 0.0 ); - _collisionElipsoid.upVector = glm::vec3( 0.0, 0.0, 0.0 ); - _collisionElipsoid.girth = 0.0; - _collisionElipsoid.height = 0.0; - + + _handHolding.position = glm::vec3( 0.0, 0.0, 0.0 ); + _handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 ); + _handHolding.force = 10.0f; + if (iris_texture.size() == 0) { switchToResourcesParentIfRequired(); unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file); @@ -133,20 +131,19 @@ Head::Head(bool isMine) { printLog("error %u: %s\n", error, lodepng_error_text(error)); } } - - for (int o=0; o::iterator agent = agentList->getAgents().begin(); agent != agentList->getAgents().end(); @@ -321,7 +318,8 @@ void Head::simulate(float deltaTime) { if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_AVATAR ) )) { Head *otherAvatar = (Head *)agent->getLinkedData(); - if ( _numOtherAvatarsInView < MAX_OTHER_AVATARS ) { + // if ( _numOtherAvatars < MAX_OTHER_AVATARS ) + { //------------------------------------------------------ // check for collisions with other avatars and respond @@ -334,27 +332,20 @@ void Head::simulate(float deltaTime) { otherAvatar->getBodyUpDirection(), deltaTime ); - - //----------------------------------------------------------- - // test other avatar hand position for proximity and state - //----------------------------------------------------------- - _otherAvatarHandPosition[ _numOtherAvatarsInView ] = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ); - _otherAvatarHandState [ _numOtherAvatarsInView ] = (int)otherAvatar->getHandState(); - - glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position ); - v -= _otherAvatarHandPosition[ _numOtherAvatarsInView ]; - //if ( otherAvatar->getHandState() == 1 ) - { - printf( "otherAvatar->getHandState() is %d\n", (int)otherAvatar->getHandState() ); - } + //------------------------------------------------- + // test other avatar hand position for proximity + //------------------------------------------------ + glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position ); + v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ); float distance = glm::length( v ); if ( distance < _maxArmLength ) { if ( distance < closestDistance ) { closestDistance = distance; - _closestOtherAvatar = _numOtherAvatarsInView; - _numOtherAvatarsInView++; + _nearOtherAvatar = true; + _otherAvatar.handPosition = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ); + _otherAvatar.handState = (int)otherAvatar->getHandState(); } } } @@ -398,7 +389,7 @@ void Head::simulate(float deltaTime) { // reset hand and arm positions according to hand movement //------------------------------------------------------------ if (_usingBodySprings) { - updateHandMovement(); + updateHandMovement( deltaTime ); updateBodySprings( deltaTime ); } @@ -652,7 +643,6 @@ void Head::render(bool lookingInMirror) { glutSolidSphere( 1, 10, 10 ); glPopMatrix(); - if ( usingBigSphereCollisionTest ) { //--------------------------------------------------- // show TEST big sphere @@ -681,10 +671,10 @@ void Head::render(bool lookingInMirror) { if ( _isMine ) { if (_usingBodySprings) { - if ( _closestOtherAvatar != -1 ) { + if ( _nearOtherAvatar ) { glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position ); - glm::vec3 v2( _otherAvatarHandPosition[ _closestOtherAvatar ] ); + glm::vec3 v2( _otherAvatar.handPosition ); glLineWidth( 8.0 ); glColor4f( 0.7f, 0.4f, 0.1f, 0.6 ); @@ -987,12 +977,6 @@ void Head::initializeSkeleton() { updateSkeleton(); } -/* -int Head::getHandState() { - return _handState; -} -*/ - void Head::calculateBoneLengths() { for (int b=0; b