From 6273594f51f44e59f91e82ce2a7adb53acbaad90 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 6 May 2013 12:56:31 -0700 Subject: [PATCH 1/8] made a call to initializeBodySprings at the end of initializeSkeleton --- interface/src/Avatar.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index a1a93fbfe3..f7cf543f14 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -381,7 +381,7 @@ void Avatar::simulate(float deltaTime) { // decay body rotation momentum float bodySpinMomentum = 1.0 - BODY_SPIN_FRICTION * deltaTime; - if ( bodySpinMomentum < 0.0f ) { bodySpinMomentum = 0.0f; } + if (bodySpinMomentum < 0.0f) { bodySpinMomentum = 0.0f; } _bodyPitchDelta *= bodySpinMomentum; _bodyYawDelta *= bodySpinMomentum; _bodyRollDelta *= bodySpinMomentum; @@ -1193,6 +1193,9 @@ void Avatar::initializeSkeleton() { // generate world positions updateSkeleton(); + + //set spring positions to be in the skeleton bone positions + initializeBodySprings(); } void Avatar::calculateBoneLengths() { From 40771e4c4778547738dd72fd25706c38e61c3870 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 6 May 2013 14:18:14 -0700 Subject: [PATCH 2/8] thingy --- interface/src/Avatar.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index f7cf543f14..fdf8e326ce 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -446,6 +446,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { _handState = _mousePressed; } + /* //reset these for the next go-round _avatarTouch.setAbleToReachOtherAvatar (false); _avatarTouch.setHandsCloseEnoughToGrasp(false); @@ -516,12 +517,14 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { // Set the vector we send for hand position to other people to be our right hand setHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); - }//if (_isMine) + */ + //constrain right arm length and re-adjust elbow position as it bends updateArmIKAndConstraints(deltaTime); - + + /* // set hand positions for _avatarTouch.setMyHandPosition AFTER calling updateArmIKAndConstraints if (_interactingOther) { if (_isMine) { @@ -536,9 +539,15 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { if (!_avatarTouch.getAbleToReachOtherAvatar() ) { _interactingOther = NULL; } + + */ } + + + + void Avatar::updateHead(float deltaTime) { //apply the head lean values to the springy position... From 114dfeacf66707e73ef416fe975b2a69e34fa5e8 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 6 May 2013 14:22:01 -0700 Subject: [PATCH 3/8] thingy --- interface/src/Avatar.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index fdf8e326ce..f41fe344b1 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -515,8 +515,6 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { } } - // Set the vector we send for hand position to other people to be our right hand - setHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); }//if (_isMine) */ @@ -524,6 +522,11 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { //constrain right arm length and re-adjust elbow position as it bends updateArmIKAndConstraints(deltaTime); + if (_isMine) { + // Set the vector we send for hand position to other people to be our right hand + setHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); + } + /* // set hand positions for _avatarTouch.setMyHandPosition AFTER calling updateArmIKAndConstraints if (_interactingOther) { From c1ac3eb320dba8f5664993e546b8429b9b1ac9cb Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 6 May 2013 15:14:13 -0700 Subject: [PATCH 4/8] improving the code for detecting collisions, hand movement and handholding --- interface/src/Avatar.cpp | 229 +++++++++++++++++---------------------- interface/src/Avatar.h | 5 +- 2 files changed, 101 insertions(+), 133 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index f41fe344b1..c103d93e37 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -144,7 +144,7 @@ Avatar::Avatar(bool isMine) { _renderYaw = 0.0; _renderPitch = 0.0; _sphere = NULL; - _interactingOther = NULL; + //_interactingOther = NULL; _handHoldingPosition = glm::vec3(0.0f, 0.0f, 0.0f); _distanceToNearestAvatar = std::numeric_limits::max(); _gravity = glm::vec3(0.0f, -1.0f, 0.0f); // default @@ -335,6 +335,11 @@ void Avatar::simulate(float deltaTime) { // update avatar skeleton updateSkeleton(); + //detect and respond to collisions with other avatars... + if (_isMine) { + updateAvatarCollisions(deltaTime); + } + //update the movement of the hand and process handshaking with other avatars... updateHandMovementAndTouching(deltaTime); @@ -431,7 +436,6 @@ void Avatar::simulate(float deltaTime) { -//update the movement of the hand and process handshaking with other avatars... void Avatar::updateHandMovementAndTouching(float deltaTime) { // reset hand and arm positions according to hand movement @@ -441,110 +445,43 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { + _orientation.getFront() * -_movedHandOffset.y * 1.0f; _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position += transformedHandMovement; - - if (_isMine) { - _handState = _mousePressed; - } - - /* - //reset these for the next go-round - _avatarTouch.setAbleToReachOtherAvatar (false); - _avatarTouch.setHandsCloseEnoughToGrasp(false); - - // if the avatar being simulated is mine, then loop through - // all the other avatars for potential interactions... + if (_isMine) { // Reset detector for nearest avatar _distanceToNearestAvatar = std::numeric_limits::max(); + //loop through all the other avatars for potential interactions... AgentList* agentList = AgentList::getInstance(); for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) { if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) { Avatar *otherAvatar = (Avatar *)agent->getLinkedData(); // check for collisions with other avatars and respond - updateCollisionWithOtherAvatar(otherAvatar, deltaTime ); - + //applyCollisionWithOtherAvatar(otherAvatar, deltaTime ); + // test other avatar hand position for proximity glm::vec3 v(_joint[ AVATAR_JOINT_RIGHT_SHOULDER ].position); v -= otherAvatar->getJointPosition(AVATAR_JOINT_RIGHT_SHOULDER); - float distance = glm::length(v); - if (distance < _distanceToNearestAvatar) {_distanceToNearestAvatar = distance;} - - if (distance < _maxArmLength + _maxArmLength) { - - _interactingOther = otherAvatar; - - if (! _avatarTouch.getAbleToReachOtherAvatar()) { - //initialize _handHolding - _handHoldingPosition = _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position; - _avatarTouch.setAbleToReachOtherAvatar(true); - } - - glm::vec3 vectorBetweenHands(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); - vectorBetweenHands -= otherAvatar->getJointPosition(AVATAR_JOINT_RIGHT_FINGERTIPS); - float distanceBetweenHands = glm::length(vectorBetweenHands); - - if (distanceBetweenHands < HANDS_CLOSE_ENOUGH_TO_GRASP) { - _avatarTouch.setHandsCloseEnoughToGrasp(true); - } - - // if I am holding hands with another avatar, a force is applied - if ((_handState == 1) || (_interactingOther->_handState == 1)) { - - // if the hands are close enough to grasp... - if (distanceBetweenHands < HANDS_CLOSE_ENOUGH_TO_GRASP) - { - // apply the forces... - glm::vec3 vectorToOtherHand = _interactingOther->_handPosition - _handHoldingPosition; - glm::vec3 vectorToMyHand = _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position - _handHoldingPosition; - - _handHoldingPosition += vectorToOtherHand * YOUR_HAND_HOLDING_PULL; - _handHoldingPosition += vectorToMyHand * MY_HAND_HOLDING_PULL; - _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position = _handHoldingPosition; - - // apply a force to the avatar body - if (glm::length(vectorToOtherHand) > _maxArmLength * 0.9) { - _velocity += vectorToOtherHand; - } - } - } - } + //float distance = glm::length(v); + //if (distance < _distanceToNearestAvatar) { + // _distanceToNearestAvatar = distance; + //} } } }//if (_isMine) - */ - //constrain right arm length and re-adjust elbow position as it bends updateArmIKAndConstraints(deltaTime); if (_isMine) { - // Set the vector we send for hand position to other people to be our right hand + //Set the vector we send for hand position to other people to be our right hand setHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); + _handState = _mousePressed; } - - /* - // set hand positions for _avatarTouch.setMyHandPosition AFTER calling updateArmIKAndConstraints - if (_interactingOther) { - if (_isMine) { - _avatarTouch.setMyHandPosition (_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); - _avatarTouch.setYourHandPosition(_interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); - _avatarTouch.setMyHandState (_handState); - _avatarTouch.setYourHandState (_interactingOther->_handState); - _avatarTouch.simulate(deltaTime); - } - } - - if (!_avatarTouch.getAbleToReachOtherAvatar() ) { - _interactingOther = NULL; - } - - */ -} + } @@ -702,66 +639,96 @@ void Avatar::updateCollisionWithSphere(glm::vec3 position, float radius, float d } -//detect collisions with other avatars and respond -void Avatar::updateCollisionWithOtherAvatar(Avatar * otherAvatar, float deltaTime) { - // check if the bounding spheres of the two avatars are colliding - glm::vec3 vectorBetweenBoundingSpheres(_position - otherAvatar->_position); - if (glm::length(vectorBetweenBoundingSpheres) < _height * ONE_HALF + otherAvatar->_height * ONE_HALF) { + +void Avatar::updateAvatarCollisions(float deltaTime) { + + // Reset detector for nearest avatar + _distanceToNearestAvatar = std::numeric_limits::max(); + + //loop through all the other avatars for potential interactions... + AgentList* agentList = AgentList::getInstance(); + for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) { + if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) { + Avatar *otherAvatar = (Avatar *)agent->getLinkedData(); + + // check if the bounding spheres of the two avatars are colliding + glm::vec3 vectorBetweenBoundingSpheres(_position - otherAvatar->_position); + if (glm::length(vectorBetweenBoundingSpheres) < _height * ONE_HALF + otherAvatar->_height * ONE_HALF) { + //apply forces from collision + applyCollisionWithOtherAvatar(otherAvatar, deltaTime ); + } + + // test other avatar hand position for proximity + glm::vec3 v(_joint[ AVATAR_JOINT_RIGHT_SHOULDER ].position); + v -= otherAvatar->getPosition(); + + float distance = glm::length(v); + if (distance < _distanceToNearestAvatar) { + _distanceToNearestAvatar = distance; + } + } + } +} + + + + +//detect collisions with other avatars and respond +void Avatar::applyCollisionWithOtherAvatar(Avatar * otherAvatar, float deltaTime) { float bodyMomentum = 1.0f; glm::vec3 bodyPushForce = glm::vec3(0.0f, 0.0f, 0.0f); - // loop through the joints of each avatar to check for every possible collision - for (int b=1; b_joint[o].isCollidable) { + for (int o=b+1; o_joint[o].isCollidable) { + + glm::vec3 vectorBetweenJoints(_joint[b].springyPosition - otherAvatar->_joint[o].springyPosition); + float distanceBetweenJoints = glm::length(vectorBetweenJoints); - glm::vec3 vectorBetweenJoints(_joint[b].springyPosition - otherAvatar->_joint[o].springyPosition); - float distanceBetweenJoints = glm::length(vectorBetweenJoints); - - if (distanceBetweenJoints > 0.0 ) { // to avoid divide by zero - float combinedRadius = _joint[b].radius + otherAvatar->_joint[o].radius; + if (distanceBetweenJoints > 0.0 ) { // to avoid divide by zero + float combinedRadius = _joint[b].radius + otherAvatar->_joint[o].radius; - // check for collision - if (distanceBetweenJoints < combinedRadius * COLLISION_RADIUS_SCALAR) { - glm::vec3 directionVector = vectorBetweenJoints / distanceBetweenJoints; + // check for collision + if (distanceBetweenJoints < combinedRadius * COLLISION_RADIUS_SCALAR) { + glm::vec3 directionVector = vectorBetweenJoints / distanceBetweenJoints; + + // push balls away from each other and apply friction + glm::vec3 ballPushForce = directionVector * COLLISION_BALL_FORCE * deltaTime; + + float ballMomentum = 1.0 - COLLISION_BALL_FRICTION * deltaTime; + if (ballMomentum < 0.0 ) { ballMomentum = 0.0;} + + _joint[b].springyVelocity += ballPushForce; + otherAvatar->_joint[o].springyVelocity -= ballPushForce; + + _joint[b].springyVelocity *= ballMomentum; + otherAvatar->_joint[o].springyVelocity *= ballMomentum; + + // accumulate forces and frictions to apply to the velocities of avatar bodies + bodyPushForce += directionVector * COLLISION_BODY_FORCE * deltaTime; + bodyMomentum -= COLLISION_BODY_FRICTION * deltaTime; + if (bodyMomentum < 0.0 ) { bodyMomentum = 0.0;} + + }// check for collision + } // to avoid divide by zero + } // o loop + } // collidable + } // b loop + } // collidable + + + //apply forces and frictions on the bodies of both avatars + _velocity += bodyPushForce; + otherAvatar->_velocity -= bodyPushForce; + _velocity *= bodyMomentum; + otherAvatar->_velocity *= bodyMomentum; +} - // push balls away from each other and apply friction - glm::vec3 ballPushForce = directionVector * COLLISION_BALL_FORCE * deltaTime; - - float ballMomentum = 1.0 - COLLISION_BALL_FRICTION * deltaTime; - if (ballMomentum < 0.0 ) { ballMomentum = 0.0;} - - _joint[b].springyVelocity += ballPushForce; - otherAvatar->_joint[o].springyVelocity -= ballPushForce; - - _joint[b].springyVelocity *= ballMomentum; - otherAvatar->_joint[o].springyVelocity *= ballMomentum; - - // accumulate forces and frictions to apply to the velocities of avatar bodies - bodyPushForce += directionVector * COLLISION_BODY_FORCE * deltaTime; - bodyMomentum -= COLLISION_BODY_FRICTION * deltaTime; - if (bodyMomentum < 0.0 ) { bodyMomentum = 0.0;} - - }// check for collision - } // to avoid divide by zero - } // o loop - } // collidable - } // b loop - } // collidable - - - //apply forces and frictions on the bodies of both avatars - _velocity += bodyPushForce; - otherAvatar->_velocity -= bodyPushForce; - _velocity *= bodyMomentum; - otherAvatar->_velocity *= bodyMomentum; - - } // bounding sphere collision -} //method void Avatar::setDisplayingHead(bool displayingHead ) { diff --git a/interface/src/Avatar.h b/interface/src/Avatar.h index 6fb8ee01ee..8bb98aadf3 100644 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -241,7 +241,7 @@ private: float _transmitterHz; int _transmitterPackets; glm::vec3 _transmitterInitialReading; - Avatar* _interactingOther; + //Avatar* _interactingOther; float _pelvisStandingHeight; float _height; Balls* _balls; @@ -260,8 +260,9 @@ private: void readSensors(); void updateHead( float deltaTime ); void updateHandMovementAndTouching(float deltaTime); + void updateAvatarCollisions(float deltaTime); void updateCollisionWithSphere( glm::vec3 position, float radius, float deltaTime ); - void updateCollisionWithOtherAvatar( Avatar * other, float deltaTime ); + void applyCollisionWithOtherAvatar( Avatar * other, float deltaTime ); void setHeadFromGyros(glm::vec3 * eulerAngles, glm::vec3 * angularVelocity, float deltaTime, float smoothingTime); void setHeadSpringScale(float s) { _head.returnSpringScale = s; } }; From fd4a0c9acd42985b8318822284dda478c9a8bd90 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 6 May 2013 16:17:16 -0700 Subject: [PATCH 5/8] working on detection of avatars entering into each other's peripersonal space --- interface/src/Avatar.cpp | 38 +++++++++++++++------------ interface/src/AvatarTouch.cpp | 49 +++++++++++++++++++++++++++++++---- interface/src/AvatarTouch.h | 22 ++++++++++------ 3 files changed, 79 insertions(+), 30 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index c103d93e37..58ec217e06 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -151,6 +151,8 @@ Avatar::Avatar(bool isMine) { initializeSkeleton(); + _avatarTouch.setReachableRadius(0.4); + if (iris_texture.size() == 0) { switchToResourcesParentIfRequired(); unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file); @@ -342,7 +344,8 @@ void Avatar::simulate(float deltaTime) { //update the movement of the hand and process handshaking with other avatars... updateHandMovementAndTouching(deltaTime); - + + _avatarTouch.simulate(deltaTime); // apply gravity and collision with the ground/floor if (USING_AVATAR_GRAVITY) { @@ -448,32 +451,35 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { if (_isMine) { - // Reset detector for nearest avatar - _distanceToNearestAvatar = std::numeric_limits::max(); + _avatarTouch.setMyBodyPosition(_position); + + Avatar * _interactingOther = NULL; + float closestDistance = 10000.0f; //loop through all the other avatars for potential interactions... AgentList* agentList = AgentList::getInstance(); for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) { if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) { Avatar *otherAvatar = (Avatar *)agent->getLinkedData(); - - // check for collisions with other avatars and respond - //applyCollisionWithOtherAvatar(otherAvatar, deltaTime ); - - // test other avatar hand position for proximity - glm::vec3 v(_joint[ AVATAR_JOINT_RIGHT_SHOULDER ].position); - v -= otherAvatar->getJointPosition(AVATAR_JOINT_RIGHT_SHOULDER); - - //float distance = glm::length(v); - //if (distance < _distanceToNearestAvatar) { - // _distanceToNearestAvatar = distance; - //} + + // test whether shoulders are close enough to allow for reaching to touch hands + glm::vec3 v(_position - otherAvatar->_position); + float distance = glm::length(v); + if (distance < closestDistance) { + closestDistance = distance; + _interactingOther = otherAvatar; + } } } + + if (_interactingOther) { + _avatarTouch.setYourHandPosition(_interactingOther->_position); + } }//if (_isMine) //constrain right arm length and re-adjust elbow position as it bends + // NOTE - the following must be called on all avatars - not just _isMine updateArmIKAndConstraints(deltaTime); if (_isMine) { @@ -483,8 +489,6 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { } } - - diff --git a/interface/src/AvatarTouch.cpp b/interface/src/AvatarTouch.cpp index 37c4c7fb2f..5dd44d46cc 100644 --- a/interface/src/AvatarTouch.cpp +++ b/interface/src/AvatarTouch.cpp @@ -17,8 +17,11 @@ 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; + _yourHandState = 0; + _reachableRadius = 0.0f; _canReachToOtherAvatar = false; _handsCloseEnoughToGrasp = false; @@ -36,6 +39,14 @@ void AvatarTouch::setYourHandPosition( glm::vec3 position ) { _yourHandPosition = position; } +void AvatarTouch::setMyBodyPosition( glm::vec3 position ) { + _myBodyPosition = position; +} + +void AvatarTouch::setYourBodyPosition( glm::vec3 position ) { + _yourBodyPosition = position; +} + void AvatarTouch::setMyHandState( int state ) { _myHandState = state; } @@ -44,12 +55,19 @@ void AvatarTouch::setYourHandState( int state ) { _yourHandState = state; } +void AvatarTouch::setReachableRadius( float r ) { + _reachableRadius = r; +} + void AvatarTouch::render() { - glm::vec3 v1( _myHandPosition ); - glm::vec3 v2( _yourHandPosition ); +if (_canReachToOtherAvatar) { + glPushMatrix(); + glTranslatef(_myBodyPosition.x, _myBodyPosition.y, _myBodyPosition.z); + glColor4f( 0.3, 0.4, 0.5, 0.3 ); glutSolidSphere( _reachableRadius, 30.0f, 30.0f ); + glPopMatrix(); - if (_canReachToOtherAvatar) { + /* // if my hand is grasping, show it... if ( _myHandState == 1 ) { glPushMatrix(); @@ -69,9 +87,15 @@ void AvatarTouch::render() { 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 ); @@ -88,16 +112,31 @@ void AvatarTouch::render() { glEnd(); } } + */ + } void AvatarTouch::simulate (float deltaTime) { - glm::vec3 v = _yourHandPosition - _myHandPosition; + glm::vec3 v = _yourBodyPosition - _myBodyPosition; + + float distance = glm::length(v); + + if (distance < _reachableRadius * 2.0f ) { + _canReachToOtherAvatar = true; + } else { + _canReachToOtherAvatar = false; + } + +/* + for (int p=0; p Date: Mon, 6 May 2013 16:59:43 -0700 Subject: [PATCH 6/8] working out avatar touch stuff --- interface/src/Avatar.cpp | 18 ++++++++++-------- interface/src/AvatarTouch.cpp | 32 +++++++++++++++----------------- interface/src/AvatarTouch.h | 9 ++++----- interface/src/main.cpp | 7 +++++-- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 58ec217e06..41cc3ee04d 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -297,7 +297,6 @@ void Avatar::UpdateGyros(float frametime, SerialInterface* serialInterface, glm: if ((_headYaw < MAX_YAW) && (_headYaw > MIN_YAW)) { addHeadYaw(_head.yawRate * HEAD_ROTATION_SCALE * frametime); } - } float Avatar::getAbsoluteHeadYaw() const { @@ -322,12 +321,10 @@ void Avatar::setMousePressed(bool d) { _mousePressed = d; } - bool Avatar::getIsNearInteractingOther() { return _avatarTouch.getAbleToReachOtherAvatar(); } - void Avatar::simulate(float deltaTime) { @@ -454,7 +451,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { _avatarTouch.setMyBodyPosition(_position); Avatar * _interactingOther = NULL; - float closestDistance = 10000.0f; + float closestDistance = std::numeric_limits::max();; //loop through all the other avatars for potential interactions... AgentList* agentList = AgentList::getInstance(); @@ -473,7 +470,8 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { } if (_interactingOther) { - _avatarTouch.setYourHandPosition(_interactingOther->_position); + _avatarTouch.setYourBodyPosition(_interactingOther->_position); + _avatarTouch.setYourHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition); } }//if (_isMine) @@ -486,12 +484,16 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { //Set the vector we send for hand position to other people to be our right hand setHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); _handState = _mousePressed; + + _avatarTouch.setMyHandState(_handState); + + if (_handState == 1) { + _avatarTouch.setMyHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition); + } } - } +} - - void Avatar::updateHead(float deltaTime) { //apply the head lean values to the springy position... diff --git a/interface/src/AvatarTouch.cpp b/interface/src/AvatarTouch.cpp index 5dd44d46cc..712a7af030 100644 --- a/interface/src/AvatarTouch.cpp +++ b/interface/src/AvatarTouch.cpp @@ -61,23 +61,12 @@ void AvatarTouch::setReachableRadius( float r ) { void AvatarTouch::render() { -if (_canReachToOtherAvatar) { + if (_canReachToOtherAvatar) { glPushMatrix(); - glTranslatef(_myBodyPosition.x, _myBodyPosition.y, _myBodyPosition.z); + glTranslatef(_yourBodyPosition.x, _yourBodyPosition.y, _yourBodyPosition.z); glColor4f( 0.3, 0.4, 0.5, 0.3 ); glutSolidSphere( _reachableRadius, 30.0f, 30.0f ); glPopMatrix(); - - /* - // if my hand is grasping, show it... - if ( _myHandState == 1 ) { - glPushMatrix(); - glTranslatef(_myHandPosition.x, _myHandPosition.y, _myHandPosition.z); - glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f ); - glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f ); - glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f ); - glPopMatrix(); - } - + // if your hand is grasping, show it... if ( _yourHandState == 1 ) { glPushMatrix(); @@ -87,7 +76,16 @@ if (_canReachToOtherAvatar) { glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f ); glPopMatrix(); } - */ + } + + // if my hand is grasping, show it... + if ( _myHandState == 1 ) { + glPushMatrix(); + glTranslatef(_myHandPosition.x, _myHandPosition.y, _myHandPosition.z); + glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f ); + glColor4f( 1.0, 1.0, 0.4, 0.2 ); glutSolidSphere( 0.025f, 10.0f, 10.0f ); + glColor4f( 1.0, 1.0, 0.2, 0.1 ); glutSolidSphere( 0.030f, 10.0f, 10.0f ); + glPopMatrix(); } /* @@ -123,12 +121,12 @@ void AvatarTouch::simulate (float deltaTime) { float distance = glm::length(v); - if (distance < _reachableRadius * 2.0f ) { + if (distance < _reachableRadius * 2.3f ) { _canReachToOtherAvatar = true; } else { _canReachToOtherAvatar = false; } - + /* for (int p=0; p Date: Mon, 6 May 2013 18:29:20 -0700 Subject: [PATCH 7/8] more work on avatar touch, reachable radius, and hand states --- interface/src/Avatar.cpp | 25 ++++++------- interface/src/Avatar.h | 12 +----- interface/src/AvatarRenderer.cpp | 13 +++++++ interface/src/AvatarTouch.cpp | 63 ++++++++++++++++---------------- interface/src/AvatarTouch.h | 2 +- interface/src/Util.cpp | 57 ++++++++++++++++++++++++----- interface/src/Util.h | 3 ++ interface/src/main.cpp | 17 +++------ 8 files changed, 116 insertions(+), 76 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 41cc3ee04d..fc2177c1d3 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -34,10 +34,6 @@ const float BODY_ROLL_WHILE_TURNING = 0.1; const float LIN_VEL_DECAY = 5.0; const float MY_HAND_HOLDING_PULL = 0.2; const float YOUR_HAND_HOLDING_PULL = 1.0; - -//const float BODY_SPRING_DEFAULT_TIGHTNESS = 20.0f; -//const float BODY_SPRING_FORCE = 6.0f; - const float BODY_SPRING_DEFAULT_TIGHTNESS = 1500.0f; const float BODY_SPRING_FORCE = 300.0f; @@ -144,14 +140,13 @@ Avatar::Avatar(bool isMine) { _renderYaw = 0.0; _renderPitch = 0.0; _sphere = NULL; - //_interactingOther = NULL; _handHoldingPosition = glm::vec3(0.0f, 0.0f, 0.0f); _distanceToNearestAvatar = std::numeric_limits::max(); _gravity = glm::vec3(0.0f, -1.0f, 0.0f); // default initializeSkeleton(); - _avatarTouch.setReachableRadius(0.4); + _avatarTouch.setReachableRadius(0.6); if (iris_texture.size() == 0) { switchToResourcesParentIfRequired(); @@ -317,8 +312,8 @@ void Avatar::setLeanSideways(float dist){ _head.leanSideways = dist; } -void Avatar::setMousePressed(bool d) { - _mousePressed = d; +void Avatar::setMousePressed( bool mousePressed ) { + _mousePressed = mousePressed; } bool Avatar::getIsNearInteractingOther() { @@ -435,7 +430,6 @@ void Avatar::simulate(float deltaTime) { } - void Avatar::updateHandMovementAndTouching(float deltaTime) { // reset hand and arm positions according to hand movement @@ -472,6 +466,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { if (_interactingOther) { _avatarTouch.setYourBodyPosition(_interactingOther->_position); _avatarTouch.setYourHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition); + _avatarTouch.setYourHandState (_interactingOther->_handState); } }//if (_isMine) @@ -483,7 +478,12 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { if (_isMine) { //Set the vector we send for hand position to other people to be our right hand setHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); - _handState = _mousePressed; + + if ( _mousePressed ) { + _handState = 1; + } else { + _handState = 0; + } _avatarTouch.setMyHandState(_handState); @@ -493,7 +493,6 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { } } - void Avatar::updateHead(float deltaTime) { //apply the head lean values to the springy position... @@ -753,7 +752,7 @@ void Avatar::setGravity(glm::vec3 gravity) { } -void Avatar::render(bool lookingInMirror) { +void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) { // render a simple round on the ground projected down from the avatar's position renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f ), 0.1f, 0.2f ); @@ -788,7 +787,7 @@ void Avatar::render(bool lookingInMirror) { // if this is my avatar, then render my interactions with the other avatar if (_isMine ) { - _avatarTouch.render(); + _avatarTouch.render(cameraPosition); } // Render the balls diff --git a/interface/src/Avatar.h b/interface/src/Avatar.h index 8bb98aadf3..29896556a5 100644 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -101,13 +101,6 @@ public: void setLeanForward(float dist); void setLeanSideways(float dist); void addLean(float x, float z); - - /* - const glm::vec3& getHeadRightDirection() const { return _orientation.getRight(); }; - const glm::vec3& getHeadUpDirection () const { return _orientation.getUp (); }; - const glm::vec3& getHeadFrontDirection() const { return _orientation.getFront(); }; - */ - const glm::vec3& getHeadPosition() const ; const glm::vec3& getJointPosition(AvatarJointID j) const { return _joint[j].position; }; const glm::vec3& getBodyUpDirection() const { return _orientation.getUp(); }; @@ -117,8 +110,8 @@ public: AvatarMode getMode(); - void setMousePressed( bool pressed ); - void render(bool lookingInMirror); + void setMousePressed(bool pressed); + void render(bool lookingInMirrorm, glm::vec3 cameraPosition); void renderBody(); void renderHead(bool lookingInMirror); void simulate(float); @@ -241,7 +234,6 @@ private: float _transmitterHz; int _transmitterPackets; glm::vec3 _transmitterInitialReading; - //Avatar* _interactingOther; float _pelvisStandingHeight; float _height; Balls* _balls; diff --git a/interface/src/AvatarRenderer.cpp b/interface/src/AvatarRenderer.cpp index b1ed54d083..52d3fc0026 100644 --- a/interface/src/AvatarRenderer.cpp +++ b/interface/src/AvatarRenderer.cpp @@ -11,6 +11,19 @@ #include "AvatarRenderer.h" #include "InterfaceConfig.h" + +#include +#include +#include +#include +#include "Avatar.h" +#include "Log.h" +#include "ui/TextRenderer.h" +#include +#include +#include + + AvatarRenderer::AvatarRenderer() { } diff --git a/interface/src/AvatarTouch.cpp b/interface/src/AvatarTouch.cpp index 712a7af030..b56a8ac7e8 100644 --- a/interface/src/AvatarTouch.cpp +++ b/interface/src/AvatarTouch.cpp @@ -10,6 +10,7 @@ #include #include "AvatarTouch.h" #include "InterfaceConfig.h" +#include "Util.h" const float THREAD_RADIUS = 0.012; @@ -59,14 +60,16 @@ void AvatarTouch::setReachableRadius( float r ) { _reachableRadius = r; } -void AvatarTouch::render() { + +void AvatarTouch::render(glm::vec3 cameraPosition) { if (_canReachToOtherAvatar) { - glPushMatrix(); - glTranslatef(_yourBodyPosition.x, _yourBodyPosition.y, _yourBodyPosition.z); - glColor4f( 0.3, 0.4, 0.5, 0.3 ); glutSolidSphere( _reachableRadius, 30.0f, 30.0f ); - glPopMatrix(); - + + 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); + // if your hand is grasping, show it... if ( _yourHandState == 1 ) { glPushMatrix(); @@ -76,6 +79,27 @@ void AvatarTouch::render() { 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; pbegin(); agent != agentList->end(); agent++) { if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) { Avatar *avatar = (Avatar *)agent->getLinkedData(); - avatar->render(0); + avatar->render(0, ::myCamera.getPosition()); } } agentList->unlock(); @@ -723,7 +723,7 @@ void displaySide(Camera& whichCamera) { if (::frustumOn) renderViewFrustum(::viewFrustum); //Render my own avatar - myAvatar.render(::lookingInMirror); + myAvatar.render(::lookingInMirror, ::myCamera.getPosition()); glPopMatrix(); } @@ -1671,15 +1671,10 @@ void idle(void) { myAvatar.setHandMovementValues( handControl.getValues() ); // tell my avatar if the mouse is being pressed... - myAvatar.setMousePressed(mousePressed); - /* - if ( mousePressed == 1 ) { - myAvatar.setMousePressed( true ); - } else { - myAvatar.setMousePressed( false ); - } - */ - + if ( mousePressed) { + myAvatar.setMousePressed(mousePressed); + } + // walking triggers the handControl to stop if ( myAvatar.getMode() == AVATAR_MODE_WALKING ) { handControl.stop(); From 65181cb4e01a636002956a4af963ff074e183d28 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Mon, 6 May 2013 22:23:16 -0700 Subject: [PATCH 8/8] changed some spacing formatting things --- interface/src/Avatar.cpp | 6 +-- interface/src/AvatarRenderer.cpp | 22 --------- interface/src/AvatarTouch.cpp | 26 +++++----- interface/src/AvatarTouch.h | 6 +-- interface/src/main.cpp | 82 ++++++++++++++------------------ 5 files changed, 54 insertions(+), 88 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index fc2177c1d3..9a4a1b16c8 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -312,7 +312,7 @@ void Avatar::setLeanSideways(float dist){ _head.leanSideways = dist; } -void Avatar::setMousePressed( bool mousePressed ) { +void Avatar::setMousePressed(bool mousePressed) { _mousePressed = mousePressed; } @@ -445,7 +445,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { _avatarTouch.setMyBodyPosition(_position); Avatar * _interactingOther = NULL; - float closestDistance = std::numeric_limits::max();; + float closestDistance = std::numeric_limits::max(); //loop through all the other avatars for potential interactions... AgentList* agentList = AgentList::getInstance(); @@ -479,7 +479,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) { //Set the vector we send for hand position to other people to be our right hand setHandPosition(_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position); - if ( _mousePressed ) { + if (_mousePressed) { _handState = 1; } else { _handState = 0; diff --git a/interface/src/AvatarRenderer.cpp b/interface/src/AvatarRenderer.cpp index 52d3fc0026..02a2f1db83 100644 --- a/interface/src/AvatarRenderer.cpp +++ b/interface/src/AvatarRenderer.cpp @@ -11,31 +11,9 @@ #include "AvatarRenderer.h" #include "InterfaceConfig.h" - -#include -#include -#include -#include -#include "Avatar.h" -#include "Log.h" -#include "ui/TextRenderer.h" -#include -#include -#include - - AvatarRenderer::AvatarRenderer() { } // this method renders the avatar void AvatarRenderer::render(Avatar *avatar, bool lookingInMirror) { -/* - // show avatar position - glColor4f( 0.5f, 0.5f, 0.5f, 0.6 ); - glPushMatrix(); - glTranslatef(avatar->_position.x, avatar->_position.y, avatar->_position.z); - glScalef( 0.03, 0.03, 0.03 ); - glutSolidSphere( 1, 10, 10 ); - glPopMatrix(); - */ } \ No newline at end of file diff --git a/interface/src/AvatarTouch.cpp b/interface/src/AvatarTouch.cpp index b56a8ac7e8..45d1eac1ed 100644 --- a/interface/src/AvatarTouch.cpp +++ b/interface/src/AvatarTouch.cpp @@ -32,31 +32,31 @@ AvatarTouch::AvatarTouch() { } } -void AvatarTouch::setMyHandPosition( glm::vec3 position ) { +void AvatarTouch::setMyHandPosition(glm::vec3 position) { _myHandPosition = position; } -void AvatarTouch::setYourHandPosition( glm::vec3 position ) { +void AvatarTouch::setYourHandPosition(glm::vec3 position) { _yourHandPosition = position; } -void AvatarTouch::setMyBodyPosition( glm::vec3 position ) { +void AvatarTouch::setMyBodyPosition(glm::vec3 position) { _myBodyPosition = position; } -void AvatarTouch::setYourBodyPosition( glm::vec3 position ) { +void AvatarTouch::setYourBodyPosition(glm::vec3 position) { _yourBodyPosition = position; } -void AvatarTouch::setMyHandState( int state ) { +void AvatarTouch::setMyHandState(int state) { _myHandState = state; } -void AvatarTouch::setYourHandState( int state ) { +void AvatarTouch::setYourHandState(int state) { _yourHandState = state; } -void AvatarTouch::setReachableRadius( float r ) { +void AvatarTouch::setReachableRadius(float r) { _reachableRadius = r; } @@ -71,7 +71,7 @@ void AvatarTouch::render(glm::vec3 cameraPosition) { renderCircle(p, _reachableRadius, glm::vec3(0.0f, 1.0f, 0.0f), 30); // if your hand is grasping, show it... - if ( _yourHandState == 1 ) { + if (_yourHandState == 1) { glPushMatrix(); glTranslatef(_yourHandPosition.x, _yourHandPosition.y, _yourHandPosition.z); glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f ); @@ -81,13 +81,13 @@ void AvatarTouch::render(glm::vec3 cameraPosition) { } //show beam - glm::vec3 v1( _myHandPosition ); - glm::vec3 v2( _yourHandPosition ); + glm::vec3 v1(_myHandPosition); + glm::vec3 v2(_yourHandPosition); if (_handsCloseEnoughToGrasp) { - glLineWidth( 2.0 ); + glLineWidth(2.0); glColor4f( 0.7f, 0.4f, 0.1f, 0.3 ); - glBegin( GL_LINE_STRIP ); + glBegin(GL_LINE_STRIP); glVertex3f( v1.x, v1.y, v1.z ); glVertex3f( v2.x, v2.y, v2.z ); glEnd(); @@ -103,7 +103,7 @@ void AvatarTouch::render(glm::vec3 cameraPosition) { } // if my hand is grasping, show it... - if ( _myHandState == 1 ) { + if (_myHandState == 1) { glPushMatrix(); glTranslatef(_myHandPosition.x, _myHandPosition.y, _myHandPosition.z); glColor4f( 1.0, 1.0, 0.8, 0.3 ); glutSolidSphere( 0.020f, 10.0f, 10.0f ); diff --git a/interface/src/AvatarTouch.h b/interface/src/AvatarTouch.h index 81803bd051..7da3df5adc 100644 --- a/interface/src/AvatarTouch.h +++ b/interface/src/AvatarTouch.h @@ -30,9 +30,9 @@ public: void setReachableRadius (float r); void setAbleToReachOtherAvatar (bool a) {_canReachToOtherAvatar = a;} void setHandsCloseEnoughToGrasp(bool h) {_handsCloseEnoughToGrasp = h;} - - bool getAbleToReachOtherAvatar () {return _canReachToOtherAvatar;} - bool getHandsCloseEnoughToGrasp() {return _handsCloseEnoughToGrasp;} + + bool getAbleToReachOtherAvatar () const {return _canReachToOtherAvatar;} + bool getHandsCloseEnoughToGrasp() const {return _handsCloseEnoughToGrasp;} private: diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 2c4c886171..78aa3ebf33 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -692,14 +692,14 @@ void displaySide(Camera& whichCamera) { float sphereRadius = 0.25f; glColor3f(1,0,0); glPushMatrix(); - glutSolidSphere( sphereRadius, 15, 15 ); + glutSolidSphere(sphereRadius, 15, 15); glPopMatrix(); //draw a grid ground plane.... drawGroundPlaneGrid(10.f); // Draw voxels - if ( showingVoxels ) + if (showingVoxels) { voxels.render(); } @@ -984,15 +984,15 @@ void display(void) glMateriali(GL_FRONT, GL_SHININESS, 96); // camera settings - if ( ::lookingInMirror ) { + if (::lookingInMirror) { // set the camera to looking at my own face - myCamera.setTargetPosition ( myAvatar.getHeadPosition() ); - myCamera.setTargetYaw ( myAvatar.getBodyYaw() - 180.0f ); // 180 degrees from body yaw - myCamera.setPitch ( 0.0 ); - myCamera.setRoll ( 0.0 ); - myCamera.setUpShift ( 0.0 ); - myCamera.setDistance ( 0.2 ); - myCamera.setTightness ( 100.0f ); + myCamera.setTargetPosition (myAvatar.getHeadPosition()); + myCamera.setTargetYaw (myAvatar.getBodyYaw() - 180.0f); // 180 degrees from body yaw + myCamera.setPitch (0.0); + myCamera.setRoll (0.0); + myCamera.setUpShift (0.0); + myCamera.setDistance (0.2); + myCamera.setTightness (100.0f); } else { //float firstPersonPitch = 20.0f; @@ -1010,36 +1010,24 @@ void display(void) float thirdPersonDistance = 1.2f; float thirdPersonTightness = 8.0f; - if ( USING_FIRST_PERSON_EFFECT ) { + if (USING_FIRST_PERSON_EFFECT) { float ff = 0.0; float min = 0.1; float max = 0.5; - if ( myAvatar.getIsNearInteractingOther()){ - if ( myAvatar.getSpeed() < max ) { + if (myAvatar.getIsNearInteractingOther()){ + if (myAvatar.getSpeed() < max) { float s = (myAvatar.getSpeed()- min)/max ; ff = 1.0 - s; } } - - /* - if ( ff < 0.8 ) { - myAvatar.setDisplayingHead( true ); - } else { - myAvatar.setDisplayingHead( false ); - } - */ - - //printf( "ff = %f\n", ff ); - myCamera.setPitch ( thirdPersonPitch + ff * ( firstPersonPitch - thirdPersonPitch )); - myCamera.setUpShift ( thirdPersonUpShift + ff * ( firstPersonUpShift - thirdPersonUpShift )); - myCamera.setDistance ( thirdPersonDistance + ff * ( firstPersonDistance - thirdPersonDistance )); - myCamera.setTightness ( thirdPersonTightness + ff * ( firstPersonTightness - thirdPersonTightness )); + myCamera.setPitch (thirdPersonPitch + ff * (firstPersonPitch - thirdPersonPitch )); + myCamera.setUpShift (thirdPersonUpShift + ff * (firstPersonUpShift - thirdPersonUpShift )); + myCamera.setDistance (thirdPersonDistance + ff * (firstPersonDistance - thirdPersonDistance )); + myCamera.setTightness (thirdPersonTightness + ff * (firstPersonTightness - thirdPersonTightness)); - - // this version uses a ramp-up/ramp-down timer in the camera to determine shift between first and thirs-person view /* if ( myAvatar.getSpeed() < 0.02 ) { @@ -1073,13 +1061,13 @@ void display(void) myCamera.setTightness(thirdPersonTightness); } - myCamera.setTargetPosition( myAvatar.getHeadPosition() ); - myCamera.setTargetYaw ( myAvatar.getBodyYaw() ); - myCamera.setRoll ( 0.0 ); + myCamera.setTargetPosition(myAvatar.getHeadPosition()); + myCamera.setTargetYaw (myAvatar.getBodyYaw()); + myCamera.setRoll (0.0); } // important... - myCamera.update( 1.f/FPS ); + myCamera.update(1.f/FPS); // Note: whichCamera is used to pick between the normal camera myCamera for our // main camera, vs, an alternate camera. The alternate camera we support right now @@ -1095,11 +1083,11 @@ void display(void) if (::viewFrustumFromOffset && ::frustumOn) { // set the camera to third-person view but offset so we can see the frustum - viewFrustumOffsetCamera.setTargetYaw( ::viewFrustumOffsetYaw + myAvatar.getBodyYaw() ); - viewFrustumOffsetCamera.setPitch ( ::viewFrustumOffsetPitch ); - viewFrustumOffsetCamera.setRoll ( ::viewFrustumOffsetRoll ); - viewFrustumOffsetCamera.setUpShift ( ::viewFrustumOffsetUp ); - viewFrustumOffsetCamera.setDistance ( ::viewFrustumOffsetDistance ); + viewFrustumOffsetCamera.setTargetYaw(::viewFrustumOffsetYaw + myAvatar.getBodyYaw() ); + viewFrustumOffsetCamera.setPitch (::viewFrustumOffsetPitch ); + viewFrustumOffsetCamera.setRoll (::viewFrustumOffsetRoll ); + viewFrustumOffsetCamera.setUpShift (::viewFrustumOffsetUp ); + viewFrustumOffsetCamera.setDistance (::viewFrustumOffsetDistance); viewFrustumOffsetCamera.update(1.f/FPS); whichCamera = viewFrustumOffsetCamera; } @@ -1109,11 +1097,11 @@ void display(void) // or could be viewFrustumOffsetCamera if in offset mode // I changed the ordering here - roll is FIRST (JJV) - glRotatef ( whichCamera.getRoll(), IDENTITY_FRONT.x, IDENTITY_FRONT.y, IDENTITY_FRONT.z ); - glRotatef ( whichCamera.getPitch(), IDENTITY_RIGHT.x, IDENTITY_RIGHT.y, IDENTITY_RIGHT.z ); - glRotatef ( 180.0 - whichCamera.getYaw(), IDENTITY_UP.x, IDENTITY_UP.y, IDENTITY_UP.z ); + glRotatef ( whichCamera.getRoll(), IDENTITY_FRONT.x, IDENTITY_FRONT.y, IDENTITY_FRONT.z); + glRotatef ( whichCamera.getPitch(), IDENTITY_RIGHT.x, IDENTITY_RIGHT.y, IDENTITY_RIGHT.z); + glRotatef (180.0 - whichCamera.getYaw(), IDENTITY_UP.x, IDENTITY_UP.y, IDENTITY_UP.z ); - glTranslatef( -whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z ); + glTranslatef(-whichCamera.getPosition().x, -whichCamera.getPosition().y, -whichCamera.getPosition().z); if (::oculusOn) { displayOculus(whichCamera); @@ -1666,16 +1654,16 @@ void idle(void) { // update behaviors for avatar hand movement: handControl takes mouse values as input, // and gives back 3D values modulated for smooth transitioning between interaction modes. - handControl.update( mouseX, mouseY ); - myAvatar.setHandMovementValues( handControl.getValues() ); + handControl.update(mouseX, mouseY); + myAvatar.setHandMovementValues(handControl.getValues()); // tell my avatar if the mouse is being pressed... - if ( mousePressed) { + if (mousePressed) { myAvatar.setMousePressed(mousePressed); } // walking triggers the handControl to stop - if ( myAvatar.getMode() == AVATAR_MODE_WALKING ) { + if (myAvatar.getMode() == AVATAR_MODE_WALKING) { handControl.stop(); } @@ -1868,7 +1856,7 @@ int main(int argc, const char * argv[]) #ifdef _WIN32 WSADATA WsaData; - int wsaresult = WSAStartup( MAKEWORD(2,2), &WsaData ); + int wsaresult = WSAStartup(MAKEWORD(2,2), &WsaData); #endif // start the agentList threads