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

This commit is contained in:
Jeffrey Ventrella 2013-04-24 11:02:23 -07:00
parent ee9ae3f220
commit eca6999c2c
4 changed files with 40 additions and 13 deletions

View file

@ -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");

View file

@ -91,7 +91,7 @@ bool processParameters(int parameterCount, char* parameterData[])
}
}
return true;
};_Position
};
int main(int argc, const char* argv[]) {

View file

@ -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
//-------------------------------------------------------------------------------

View file

@ -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;