diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 99987a7496..d8f65c3e0b 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -319,7 +319,7 @@ void Avatar::simulate(float deltaTime) { // if the avatar being simulated is mine, then loop through // all the other avatars for potential interactions... if ( _isMine ) - { + { float closestDistance = 10000.0f; AgentList* agentList = AgentList::getInstance(); @@ -341,7 +341,7 @@ void Avatar::simulate(float deltaTime) { float distance = glm::length( v ); if ( distance < _maxArmLength + _maxArmLength ) { - + //if ( distance < closestDistance ) { // perhaps I don't need this if we want to allow multi-avatar interactions { closestDistance = distance; @@ -352,7 +352,7 @@ void Avatar::simulate(float deltaTime) { if (( _handState == 1 ) || ( _interactingOther->_handState == 1 )) { glm::vec3 vectorToOtherHand = _interactingOther->_handPosition - _handHolding.position; glm::vec3 vectorToMyHand = _bone[ AVATAR_BONE_RIGHT_HAND ].position - _handHolding.position; - + _handHolding.velocity *= 0.7; _handHolding.velocity += ( vectorToOtherHand + vectorToMyHand ) * _handHolding.force * deltaTime; _handHolding.position += _handHolding.velocity; @@ -360,6 +360,9 @@ void Avatar::simulate(float deltaTime) { _bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHolding.position; } } + + _avatarTouch.setMyHandPosition( _bone[ AVATAR_BONE_RIGHT_HAND ].position ); + _avatarTouch.setYourPosition( otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ) ); } } } @@ -367,7 +370,10 @@ void Avatar::simulate(float deltaTime) { // Set the vector we send for hand position to other people to be our right hand setHandPosition(_bone[ AVATAR_BONE_RIGHT_HAND ].position); - } + //update the effects of touching another avatar + _avatarTouch.simulate(deltaTime); + + }//if ( _isMine ) updateArmIKAndConstraints( deltaTime ); @@ -400,31 +406,15 @@ void Avatar::simulate(float deltaTime) { if ( _isMine ) { _thrust = glm::vec3( 0.0, 0.0, 0.0 ); - - if (_driveKeys[FWD]) { - _thrust += _orientation.getFront() * THRUST_MAG; - } - if (_driveKeys[BACK]) { - _thrust -= _orientation.getFront() * THRUST_MAG; - } - if (_driveKeys[RIGHT]) { - _thrust += _orientation.getRight() * THRUST_MAG; - } - if (_driveKeys[LEFT]) { - _thrust -= _orientation.getRight() * THRUST_MAG; - } - if (_driveKeys[UP]) { - _thrust += _orientation.getUp() * THRUST_MAG; - } - if (_driveKeys[DOWN]) { - _thrust -= _orientation.getUp() * THRUST_MAG; - } - if (_driveKeys[ROT_RIGHT]) { - _bodyYawDelta -= YAW_MAG * deltaTime; - } - if (_driveKeys[ROT_LEFT]) { - _bodyYawDelta += YAW_MAG * deltaTime; - } + + if (_driveKeys[FWD ]) {_thrust += THRUST_MAG * deltaTime * _orientation.getFront();} + if (_driveKeys[BACK ]) {_thrust -= THRUST_MAG * deltaTime * _orientation.getFront();} + if (_driveKeys[RIGHT ]) {_thrust += THRUST_MAG * deltaTime * _orientation.getRight();} + if (_driveKeys[LEFT ]) {_thrust -= THRUST_MAG * deltaTime * _orientation.getRight();} + if (_driveKeys[UP ]) {_thrust += THRUST_MAG * deltaTime * _orientation.getUp();} + if (_driveKeys[DOWN ]) {_thrust -= THRUST_MAG * deltaTime * _orientation.getUp();} + if (_driveKeys[ROT_RIGHT]) {_bodyYawDelta -= YAW_MAG * deltaTime;} + if (_driveKeys[ROT_LEFT ]) {_bodyYawDelta += YAW_MAG * deltaTime;} } // update body yaw by body yaw delta @@ -602,6 +592,7 @@ void Avatar::updateAvatarCollisionDetectionAndResponse(glm::vec3 collisionPositi } void Avatar::render(bool lookingInMirror) { + /* // show avatar position glColor4f( 0.5f, 0.5f, 0.5f, 0.6 ); @@ -632,17 +623,8 @@ void Avatar::render(bool lookingInMirror) { // if this is my avatar, then render my interactions with the other avatar if ( _isMine ) { - if ( _interactingOtherIsNearby ) { - - glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position ); - glm::vec3 v2( _interactingOther->_handPosition ); - - glLineWidth( 8.0 ); - glColor4f( 0.7f, 0.4f, 0.1f, 0.6 ); - glBegin( GL_LINE_STRIP ); - glVertex3f( v1.x, v1.y, v1.z ); - glVertex3f( v2.x, v2.y, v2.z ); - glEnd(); + if ( _interactingOtherIsNearby ) { + _avatarTouch.render(); } } @@ -855,7 +837,8 @@ void Avatar::renderHead(bool lookingInMirror) { glPopMatrix(); -} + } + void Avatar::startHandMovement() { @@ -976,11 +959,11 @@ void Avatar::initializeSkeleton() { calculateBoneLengths(); _pelvisStandingHeight = - _bone[ AVATAR_BONE_PELVIS_SPINE ].length + - _bone[ AVATAR_BONE_LEFT_THIGH ].length + - _bone[ AVATAR_BONE_LEFT_SHIN ].length + - _bone[ AVATAR_BONE_LEFT_FOOT ].length + - _bone[ AVATAR_BONE_RIGHT_FOOT ].radius; + _bone[ AVATAR_BONE_PELVIS_SPINE ].length + + _bone[ AVATAR_BONE_LEFT_THIGH ].length + + _bone[ AVATAR_BONE_LEFT_SHIN ].length + + _bone[ AVATAR_BONE_LEFT_FOOT ].length + + _bone[ AVATAR_BONE_RIGHT_FOOT ].radius; // generate world positions updateSkeleton(); diff --git a/interface/src/Avatar.h b/interface/src/Avatar.h index 201bb8c82f..c473dc9dc6 100644 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -13,6 +13,7 @@ #include #include "world.h" +#include "AvatarTouch.h" #include "InterfaceConfig.h" #include "SerialInterface.h" @@ -25,7 +26,7 @@ const bool AVATAR_GRAVITY = true; const float DECAY = 0.1; -const float THRUST_MAG = 10.0; +const float THRUST_MAG = 1200.0; const float YAW_MAG = 500.0; //JJV - changed from 300.0; const float TEST_YAW_DECAY = 5.0; const float LIN_VEL_DECAY = 5.0; @@ -47,6 +48,8 @@ enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH}; #define MAX_OTHER_AVATARS 10 // temporary - for testing purposes! + + enum AvatarMode { AVATAR_MODE_STANDING = 0, @@ -256,22 +259,25 @@ private: Avatar* _interactingOther; bool _interactingOtherIsNearby; float _pelvisStandingHeight; - Balls* _balls; - - void initializeSkeleton(); - void updateSkeleton(); - void initializeBodySprings(); - void updateBodySprings( float deltaTime ); - void calculateBoneLengths(); - void readSensors(); - void renderBoneAsBlock( AvatarBoneID b ); - void updateAvatarCollisionDetectionAndResponse(glm::vec3 collisionPosition, - float collisionGirth, - float collisionHeight, - glm::vec3 collisionUpVector, - float deltaTime); - + AvatarTouch _avatarTouch; + + // private methods... + void initializeSkeleton(); + void updateSkeleton(); + void initializeBodySprings(); + void updateBodySprings( float deltaTime ); + void calculateBoneLengths(); + void readSensors(); + void renderBoneAsBlock( AvatarBoneID b ); + void updateAvatarCollisionDetectionAndResponse + ( + glm::vec3 collisionPosition, + float collisionGirth, + float collisionHeight, + glm::vec3 collisionUpVector, + float deltaTime + ); }; #endif diff --git a/interface/src/AvatarTouch.cpp b/interface/src/AvatarTouch.cpp new file mode 100644 index 0000000000..bd99cecd2b --- /dev/null +++ b/interface/src/AvatarTouch.cpp @@ -0,0 +1,43 @@ +// +// AvatarTouch.cpp +// interface +// +// Created by Jeffrey Ventrella +// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// + +#include +#include +#include "AvatarTouch.h" +#include "InterfaceConfig.h" + +AvatarTouch::AvatarTouch() { + + _myHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f ); + _yourHandPosition = glm::vec3( 0.0f, 0.0f, 0.0f ); +} + +void AvatarTouch::setMyHandPosition( glm::vec3 position ) { + _myHandPosition = position; +} + +void AvatarTouch::setYourPosition( glm::vec3 position ) { + _yourHandPosition = position; +} + + +void AvatarTouch::render() { + + glm::vec3 v1( _myHandPosition ); + glm::vec3 v2( _yourHandPosition ); + + glLineWidth( 8.0 ); + glColor4f( 0.7f, 0.4f, 0.1f, 0.6 ); + glBegin( GL_LINE_STRIP ); + glVertex3f( v1.x, v1.y, v1.z ); + glVertex3f( v2.x, v2.y, v2.z ); + glEnd(); +} + +void AvatarTouch::simulate (float deltaTime) { + } diff --git a/interface/src/AvatarTouch.h b/interface/src/AvatarTouch.h new file mode 100644 index 0000000000..8371ea3a19 --- /dev/null +++ b/interface/src/AvatarTouch.h @@ -0,0 +1,28 @@ +// +// AvatarTouch.h +// interface +// +// Created by Jeffrey Ventrella +// Copyright (c) 2012 High Fidelity, Inc. All rights reserved. +// + +#ifndef __interface__AvatarTouch__ +#define __interface__AvatarTouch__ + +#include + +class AvatarTouch { +public: + AvatarTouch(); + + void setMyHandPosition( glm::vec3 position ); + void setYourPosition ( glm::vec3 position ); + void simulate(float deltaTime); + void render(); + +private: + glm::vec3 _myHandPosition; + glm::vec3 _yourHandPosition; +}; + +#endif diff --git a/interface/src/Camera.cpp b/interface/src/Camera.cpp index 6118a9ead5..fa7722df88 100644 --- a/interface/src/Camera.cpp +++ b/interface/src/Camera.cpp @@ -65,25 +65,49 @@ void Camera::updateFollowMode( float deltaTime ) { } // update _yaw (before position!) - _yaw += ( _idealYaw - _yaw ) * t; - _orientation.yaw ( _yaw ); + _yaw += (_idealYaw - _yaw) * t; + _orientation.yaw(_yaw); - float radian = ( _yaw / 180.0 ) * PIE; + float radian = (_yaw / 180.0) * PIE; // update _position //these need to be checked to make sure they correspond to the correct coordinate system. - double x = _distance * -sin( radian ); - double z = _distance * cos( radian ); + double x = _distance * -sin(radian); + double z = _distance * cos(radian); double y = _upShift; - _idealPosition = _targetPosition + glm::vec3( x, y, z ); - //_idealPosition += _orientation.getRight() * _rightShift; - //_idealPosition += _orientation.getUp () * _upShift; + _idealPosition = _targetPosition + glm::vec3(x, y, z); // pull position towards ideal position - _position += ( _idealPosition - _position ) * t; + _position += (_idealPosition - _position) * t; } +void Camera::setMode(CameraMode m) { + _mode = m; + _modeShift = 0.0f; +} + +void Camera::setFieldOfView(float f) { + _fieldOfView = f; + _frustumNeedsReshape = true; +} + +void Camera::setAspectRatio(float a) { + _aspectRatio = a; + _frustumNeedsReshape = true; +} + +void Camera::setNearClip (float n) { + _nearClip = n; + _frustumNeedsReshape = true; +} + +void Camera::setFarClip (float f) { + _farClip = f; + _frustumNeedsReshape = true; +} + + // call to find out if the view frustum needs to be reshaped bool Camera::getFrustumNeedsReshape() { diff --git a/interface/src/Camera.h b/interface/src/Camera.h index 51760867c0..8864df3745 100644 --- a/interface/src/Camera.h +++ b/interface/src/Camera.h @@ -29,7 +29,6 @@ public: void update( float deltaTime ); - void setMode ( CameraMode m ) { _mode = m; _modeShift = 0.0f; } void setYaw ( float y ) { _yaw = y; } void setPitch ( float p ) { _pitch = p; } void setRoll ( float r ) { _roll = r; } @@ -41,10 +40,12 @@ public: void setPosition ( glm::vec3 p ) { _position = p; } void setOrientation ( Orientation o ) { _orientation.set(o); } void setTightness ( float t ) { _tightness = t; } - void setFieldOfView ( float f ) { _fieldOfView = f; _frustumNeedsReshape = true; } - void setAspectRatio ( float a ) { _aspectRatio = a; _frustumNeedsReshape = true; } - void setNearClip ( float n ) { _nearClip = n; _frustumNeedsReshape = true; } - void setFarClip ( float f ) { _farClip = f; _frustumNeedsReshape = true; } + + void setMode ( CameraMode m ); + void setFieldOfView ( float f ); + void setAspectRatio ( float a ); + void setNearClip ( float n ); + void setFarClip ( float f ); float getYaw () { return _yaw; } float getPitch () { return _pitch; } diff --git a/interface/src/HandControl.cpp b/interface/src/HandControl.cpp new file mode 100644 index 0000000000..37efc755c2 --- /dev/null +++ b/interface/src/HandControl.cpp @@ -0,0 +1,93 @@ +// +// HandControl.cpp +// interface +// +// Created by Jeffrey Ventrella +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +#include "HandControl.h" + +// this class takes mouse movements normalized within the screen +// dimensions and uses those to determine avatar hand movements, as well +// as states for ramping up and ramping down the amplitude of such movements. +// +// This class might expand to accommodate 3D input devices +// + +HandControl::HandControl() { + + _enabled = false; + _width = 0; + _height = 0; + _startX = 0; + _startY = 0; + _x = 0; + _y = 0; + _lastX = 0; + _lastY = 0; + _velocityX = 0; + _velocityY = 0; + _rampUpRate = 0.05; + _rampDownRate = 0.02; + _envelope = 0.0f; +} + +void HandControl::setScreenDimensions( int width, int height ) { + _width = width; + _height = height; + _startX = _width / 2; + _startY = _height / 2; +} + +void HandControl::update( int x, int y ) { + _lastX = _x; + _lastY = _y; + _x = x; + _y = y; + _velocityX = _x - _lastX; + _velocityY = _y - _lastY; + + // if the mouse is moving, ramp up the envelope to increase amplitude of hand movement... + if (( _velocityX != 0 ) + || ( _velocityY != 0 )) { + _enabled = true; + if ( _envelope < 1.0 ) { + _envelope += _rampUpRate; + if ( _envelope >= 1.0 ) { + _envelope = 1.0; + } + } + } + + // if not enabled ramp down the envelope to decrease amplitude of hand movement... + if ( ! _enabled ) { + if ( _envelope > 0.0 ) { + _envelope -= _rampDownRate; + if ( _envelope <= 0.0 ) { + _startX = _width / 2; + _startY = _height / 2; + _envelope = 0.0; + } + } + } + + _leftRight = 0.0; + _downUp = 0.0; + _backFront = 0.0; + + // if envelope is greater than zero, apply mouse movement to values to be output + if ( _envelope > 0.0 ) { + _leftRight += ( ( _x - _startX ) / (float)_width ) * _envelope; + _downUp += ( ( _y - _startY ) / (float)_height ) * _envelope; + } +} + +glm::vec3 HandControl::getValues() { + return glm::vec3( _leftRight, _downUp, _backFront ); +} + +void HandControl::stop() { + _enabled = false; +} + diff --git a/interface/src/HandControl.h b/interface/src/HandControl.h new file mode 100644 index 0000000000..7663004fbf --- /dev/null +++ b/interface/src/HandControl.h @@ -0,0 +1,42 @@ +// +// HandControl.h +// interface +// +// Created by Jeffrey Ventrella +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. +// + +#ifndef __interface__HandControl__ +#define __interface__HandControl__ + +#include + +class HandControl { +public: + HandControl(); + void setScreenDimensions(int width, int height); + void update( int x, int y ); + glm::vec3 getValues(); + void stop(); + +private: + bool _enabled; + int _width; + int _height; + int _startX; + int _startY; + int _x; + int _y; + int _lastX; + int _lastY; + int _velocityX; + int _velocityY; + float _rampUpRate; + float _rampDownRate; + float _envelope; + float _leftRight; + float _downUp; + float _backFront; +}; + +#endif diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 407d6be9de..08c673e817 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -77,6 +77,7 @@ #include #include "ViewFrustum.h" +#include "HandControl.h" using namespace std; @@ -94,6 +95,8 @@ int HEIGHT = 800; int fullscreen = 0; float aspectRatio = 1.0f; +bool USING_FIRST_PERSON_EFFECT = false; + bool wantColorRandomizer = true; // for addSphere and load file Oscilloscope audioScope(256,200,true); @@ -145,6 +148,8 @@ bool lookingInMirror = 0; // Are we currently rendering one's own hea int displayHeadMouse = 1; // Display sample mouse pointer controlled by head movement int headMouseX, headMouseY; +HandControl handControl; + int mouseX = 0; int mouseY = 0; @@ -157,78 +162,6 @@ int menuOn = 1; // Whether to show onscreen menu ChatEntry chatEntry; // chat entry field bool chatEntryOn = false; // Whether to show the chat entry -struct HandController -{ - bool enabled; - int startX; - int startY; - int x; - int y; - int lastX; - int lastY; - int velocityX; - int velocityY; - float rampUpRate; - float rampDownRate; - float envelope; -}; - -HandController handController; - -void initializeHandController() { - handController.enabled = false; - handController.startX = WIDTH / 2; - handController.startY = HEIGHT / 2; - handController.x = 0; - handController.y = 0; - handController.lastX = 0; - handController.lastY = 0; - handController.velocityX = 0; - handController.velocityY = 0; - handController.rampUpRate = 0.05; - handController.rampDownRate = 0.02; - handController.envelope = 0.0f; -} - -void updateHandController( int x, int y ) { - handController.lastX = handController.x; - handController.lastY = handController.y; - handController.x = x; - handController.y = y; - handController.velocityX = handController.x - handController.lastX; - handController.velocityY = handController.y - handController.lastY; - - if (( handController.velocityX != 0 ) - || ( handController.velocityY != 0 )) { - handController.enabled = true; - myAvatar.startHandMovement(); - if ( handController.envelope < 1.0 ) { - handController.envelope += handController.rampUpRate; - if ( handController.envelope >= 1.0 ) { - handController.envelope = 1.0; - } - } - } - - if ( ! handController.enabled ) { - if ( handController.envelope > 0.0 ) { - handController.envelope -= handController.rampDownRate; - if ( handController.envelope <= 0.0 ) { - handController.startX = WIDTH / 2; - handController.startY = HEIGHT / 2; - handController.envelope = 0.0; - } - } - } - - if ( handController.envelope > 0.0 ) { - float leftRight = ( ( handController.x - handController.startX ) / (float)WIDTH ) * handController.envelope; - float downUp = ( ( handController.y - handController.startY ) / (float)HEIGHT ) * handController.envelope; - float backFront = 0.0; - myAvatar.setHandMovementValues( glm::vec3( leftRight, downUp, backFront ) ); - } -} - // @@ -361,7 +294,7 @@ void init(void) voxels.init(); voxels.setViewerAvatar(&myAvatar); - initializeHandController(); + handControl.setScreenDimensions(WIDTH, HEIGHT); headMouseX = WIDTH/2; headMouseY = HEIGHT/2; @@ -777,47 +710,48 @@ void display(void) myCamera.setTightness ( 100.0f ); } else { -// float firstPersonPitch = 20.0f; -// float firstPersonUpShift = 0.1f; -// float firstPersonDistance = 0.0f; -// float firstPersonT ightness = 100.0f; + float firstPersonPitch = 20.0f; + float firstPersonUpShift = 0.1f; + float firstPersonDistance = 0.0f; + float firstPersonTightness = 100.0f; float thirdPersonPitch = 0.0f; float thirdPersonUpShift = -0.1f; float thirdPersonDistance = 1.f; float thirdPersonTightness = 8.0f; - myCamera.setPitch (thirdPersonPitch ); - myCamera.setUpShift (thirdPersonUpShift ); - myCamera.setDistance (thirdPersonDistance ); - myCamera.setTightness(thirdPersonTightness); - - /* - if ( myAvatar.getSpeed() < 0.02 ) { - if (myCamera.getMode() != CAMERA_MODE_FIRST_PERSON ) { - myCamera.setMode(CAMERA_MODE_FIRST_PERSON); - } + if ( USING_FIRST_PERSON_EFFECT ) { + if ( myAvatar.getSpeed() < 0.02 ) { - printf( "myCamera.getModeShift() = %f\n", myCamera.getModeShift()); + if (myCamera.getMode() != CAMERA_MODE_FIRST_PERSON ) { + myCamera.setMode(CAMERA_MODE_FIRST_PERSON); + } + + printf( "myCamera.getModeShift() = %f\n", myCamera.getModeShift()); - myCamera.setPitch ( thirdPersonPitch + myCamera.getModeShift() * ( firstPersonPitch - thirdPersonPitch )); - myCamera.setUpShift ( thirdPersonUpShift + myCamera.getModeShift() * ( firstPersonUpShift - thirdPersonUpShift )); - myCamera.setDistance ( thirdPersonDistance + myCamera.getModeShift() * ( firstPersonDistance - thirdPersonDistance )); - myCamera.setTightness ( thirdPersonTightness + myCamera.getModeShift() * ( firstPersonTightness - thirdPersonTightness )); - } else { - if (myCamera.getMode() != CAMERA_MODE_THIRD_PERSON ) { - myCamera.setMode(CAMERA_MODE_THIRD_PERSON); + myCamera.setPitch ( thirdPersonPitch + myCamera.getModeShift() * ( firstPersonPitch - thirdPersonPitch )); + myCamera.setUpShift ( thirdPersonUpShift + myCamera.getModeShift() * ( firstPersonUpShift - thirdPersonUpShift )); + myCamera.setDistance ( thirdPersonDistance + myCamera.getModeShift() * ( firstPersonDistance - thirdPersonDistance )); + myCamera.setTightness ( thirdPersonTightness + myCamera.getModeShift() * ( firstPersonTightness - thirdPersonTightness )); + } else { + if (myCamera.getMode() != CAMERA_MODE_THIRD_PERSON ) { + myCamera.setMode(CAMERA_MODE_THIRD_PERSON); + } + + printf( "myCamera.getModeShift() = %f\n", myCamera.getModeShift()); + + myCamera.setPitch ( firstPersonPitch + myCamera.getModeShift() * ( thirdPersonPitch - firstPersonPitch )); + myCamera.setUpShift ( firstPersonUpShift + myCamera.getModeShift() * ( thirdPersonUpShift - firstPersonUpShift )); + myCamera.setDistance ( firstPersonDistance + myCamera.getModeShift() * ( thirdPersonDistance - firstPersonDistance )); + myCamera.setTightness ( firstPersonTightness + myCamera.getModeShift() * ( thirdPersonTightness - firstPersonTightness )); } - - printf( "myCamera.getModeShift() = %f\n", myCamera.getModeShift()); - - myCamera.setPitch ( firstPersonPitch + myCamera.getModeShift() * ( thirdPersonPitch - firstPersonPitch )); - myCamera.setUpShift ( firstPersonUpShift + myCamera.getModeShift() * ( thirdPersonUpShift - firstPersonUpShift )); - myCamera.setDistance ( firstPersonDistance + myCamera.getModeShift() * ( thirdPersonDistance - firstPersonDistance )); - myCamera.setTightness ( firstPersonTightness + myCamera.getModeShift() * ( thirdPersonTightness - firstPersonTightness )); + } else { + myCamera.setPitch (thirdPersonPitch ); + myCamera.setUpShift (thirdPersonUpShift ); + myCamera.setDistance (thirdPersonDistance ); + myCamera.setTightness(thirdPersonTightness); } - */ - + myCamera.setTargetPosition( myAvatar.getHeadPosition() ); myCamera.setTargetYaw ( 180.0 - myAvatar.getBodyYaw() ); myCamera.setRoll ( 0.0 ); @@ -1466,8 +1400,10 @@ void idle(void) { float deltaTime = 1.f/FPS; - // update behaviors for avatar hand movement - updateHandController( mouseX, mouseY ); + // 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() ); // tell my avatar if the mouse is being pressed... if ( mousePressed == 1 ) { @@ -1477,9 +1413,9 @@ void idle(void) { myAvatar.setMousePressed( false ); } - // walking triggers the handController to stop + // walking triggers the handControl to stop if ( myAvatar.getMode() == AVATAR_MODE_WALKING ) { - handController.enabled = false; + handControl.stop(); } //