From eca6999c2c6d040cd971d7e56d1046ee5688b4c6 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 24 Apr 2013 11:02:23 -0700 Subject: [PATCH] added behavior in Eve for alternating between grasping and ungrasping hand (tho unable to test transmission). Also, improved readability of hand grasping logic in Head.cpp --- eve/src/main.cpp | 15 ++++++++++++++- injector/src/main.cpp | 2 +- interface/src/Head.cpp | 32 ++++++++++++++++++++++++-------- interface/src/Head.h | 4 +--- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/eve/src/main.cpp b/eve/src/main.cpp index 3e075f7ba0..0166f8e615 100644 --- a/eve/src/main.cpp +++ b/eve/src/main.cpp @@ -27,6 +27,7 @@ const float MAX_ITERATIONS_BETWEEN_AUDIO_SENDS = (MAX_AUDIO_SEND_INTERVAL_SECS * bool stopReceiveAgentDataThread; bool injectAudioThreadRunning = false; +int handStateTimer = 0; int TEMP_AUDIO_LISTEN_PORT = 55439; // UDPSocket audioSocket(TEMP_AUDIO_LISTEN_PORT); @@ -124,7 +125,19 @@ int main(int argc, const char* argv[]) { eve.setHandPosition(glm::vec3(eve.getPosition()[0] - 0.2, 0.25, eve.getPosition()[2] + 0.1)); - + + // simulate the effect of pressing and un-pressing the mouse button/pad + handStateTimer ++; + if ( handStateTimer == 100 ) { + eve.setHandState(1); + } + if ( handStateTimer == 150 ) { + eve.setHandState(0); + } + if ( handStateTimer >= 200 ) { + handStateTimer = 0; + } + // read eve's audio data AudioInjector eveAudioInjector("eve.raw"); diff --git a/injector/src/main.cpp b/injector/src/main.cpp index 61327ec41b..b110f7553c 100644 --- a/injector/src/main.cpp +++ b/injector/src/main.cpp @@ -91,7 +91,7 @@ bool processParameters(int parameterCount, char* parameterData[]) } } return true; -};_Position +}; int main(int argc, const char* argv[]) { diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 9770bcbce1..a34d061ab5 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -48,7 +48,6 @@ 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 ); - _nearOtherAvatar = false; _bodyYaw = -90.0; _bodyPitch = 0.0; _bodyRoll = 0.0; @@ -130,6 +129,7 @@ Head::Head(bool isMine) { } } + _otherAvatar.nearby = false; _otherAvatar.handPosition = glm::vec3( 0.0f, 0.0f, 0.0f ); _otherAvatar.handState = 0; } @@ -141,7 +141,7 @@ Head::Head(const Head &otherAvatar) { _velocity = otherAvatar._velocity; _thrust = otherAvatar._thrust; _rotation = otherAvatar._rotation; - _nearOtherAvatar = otherAvatar._nearOtherAvatar; + _otherAvatar.nearby = otherAvatar._otherAvatar.nearby; _bodyYaw = otherAvatar._bodyYaw; _bodyPitch = otherAvatar._bodyPitch; _bodyRoll = otherAvatar._bodyRoll; @@ -303,7 +303,7 @@ void Head::simulate(float deltaTime) { //------------------------------------------------------------- if ( _isMine ) { - _nearOtherAvatar = false; + _otherAvatar.nearby = false; float closestDistance = 10000.0f; AgentList * agentList = AgentList::getInstance(); @@ -341,7 +341,7 @@ void Head::simulate(float deltaTime) { if ( distance < _maxArmLength ) { if ( distance < closestDistance ) { closestDistance = distance; - _nearOtherAvatar = true; + _otherAvatar.nearby = true; _otherAvatar.handPosition = otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ); _otherAvatar.handState = (int)otherAvatar->getHandState(); } @@ -669,7 +669,7 @@ void Head::render(bool lookingInMirror) { if ( _isMine ) { if (_usingBodySprings) { - if ( _nearOtherAvatar ) { + if ( _otherAvatar.nearby ) { glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position ); glm::vec3 v2( _otherAvatar.handPosition ); @@ -1130,12 +1130,28 @@ void Head::updateHandMovement( float deltaTime ) { setHandState(_mousePressed); + if ( _otherAvatar.nearby ) { + if ( _otherAvatar.handState == 1 ) { + printf( "(1)" ); + } + //else { + // printf( "(0)" ); + //} + + if ( _handState == 1 ) { + printf( "1" ); + } + else { + printf( "0" ); + } + } + //--------------------------------------------------------------------- // if holding hands with another avatar, add a force to the hand... //--------------------------------------------------------------------- - if (( getHandState() == 1 ) + if (( _handState == 1 ) || ( _otherAvatar.handState == 1 )) { - if ( _nearOtherAvatar ) { + if ( _otherAvatar.nearby ) { glm::vec3 vectorToOtherHand = _otherAvatar.handPosition - _handHolding.position; glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHolding.position; @@ -1151,7 +1167,7 @@ void Head::updateHandMovement( float deltaTime ) { _handHolding.position = _bone[ AVATAR_BONE_RIGHT_HAND ].position; _handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 ); } - + //------------------------------------------------------------------------------- // determine the arm vector //------------------------------------------------------------------------------- diff --git a/interface/src/Head.h b/interface/src/Head.h index 428ba2228a..1e0a346a35 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -102,11 +102,11 @@ struct AvatarHandHolding struct OtherAvatar { + bool nearby; glm::vec3 handPosition; int handState; }; - struct AvatarBone { AvatarBoneID parent; // which bone is this bone connected to? @@ -191,7 +191,6 @@ class Head : public AvatarData { glm::vec3 getHeadPosition(); glm::vec3 getBonePosition( AvatarBoneID b ); glm::vec3 getBodyUpDirection(); - //int getHandState(); float getGirth(); float getHeight(); @@ -233,7 +232,6 @@ class Head : public AvatarData { OtherAvatar _otherAvatar; bool _mousePressed; float _bodyYawDelta; - bool _nearOtherAvatar; bool _usingBodySprings; glm::vec3 _movedHandOffset; float _springVelocityDecay;