From ce1ceb849fac9a73b0cbf1547f7c6c6fcef77853 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Thu, 25 Apr 2013 23:32:04 -0700 Subject: [PATCH 1/4] Added HandControl class and also Avatar Touch class --- interface/src/Avatar.cpp | 61 +++++---------- interface/src/Avatar.h | 16 +++- interface/src/AvatarTouch.cpp | 43 ++++++++++ interface/src/AvatarTouch.h | 28 +++++++ interface/src/HandControl.cpp | 93 ++++++++++++++++++++++ interface/src/HandControl.h | 42 ++++++++++ interface/src/main.cpp | 143 +++++++++------------------------- 7 files changed, 280 insertions(+), 146 deletions(-) create mode 100644 interface/src/AvatarTouch.cpp create mode 100644 interface/src/AvatarTouch.h create mode 100644 interface/src/HandControl.cpp create mode 100644 interface/src/HandControl.h diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index dc09953459..4f6502c24c 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -303,7 +303,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(); @@ -330,7 +330,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; @@ -341,14 +341,18 @@ 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; _bone[ AVATAR_BONE_RIGHT_HAND ].position = _handHolding.position; + } } + + _avatarTouch.setMyHandPosition( _bone[ AVATAR_BONE_RIGHT_HAND ].position ); + _avatarTouch.setYourPosition( otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND ) ); } } } @@ -356,9 +360,11 @@ 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 ); if (!_interactingOtherIsNearby) { @@ -413,30 +419,14 @@ void Avatar::simulate(float deltaTime) { _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 @@ -658,21 +648,12 @@ 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(); + _avatarTouch.render(); } } } - void Avatar::renderHead(bool lookingInMirror) { int side = 0; @@ -835,7 +816,7 @@ void Avatar::renderHead(bool lookingInMirror) { glPopMatrix(); } - + void Avatar::startHandMovement() { if (!_usingBodySprings) { diff --git a/interface/src/Avatar.h b/interface/src/Avatar.h index ea19565d39..ccc3f34026 100644 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -14,6 +14,7 @@ #include "Field.h" #include "world.h" +#include "AvatarTouch.h" #include "InterfaceConfig.h" #include "SerialInterface.h" @@ -24,7 +25,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; @@ -46,6 +47,8 @@ enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH}; #define MAX_OTHER_AVATARS 10 // temporary - for testing purposes! + + enum AvatarMode { AVATAR_MODE_STANDING = 0, @@ -84,6 +87,16 @@ enum AvatarBoneID NUM_AVATAR_BONES }; + +/* +static glm::vec3 avatarDefaultPose[NUM_AVATAR_BONES] = +{ + glm::vec3( 0.0f, 0.0f, 0.0f ), + glm::vec3( 0.0f, 0.0f, 0.0f ) +}; +*/ + + struct AvatarCollisionElipsoid { bool colliding; @@ -252,6 +265,7 @@ class Avatar : public AvatarData { Avatar* _interactingOther; bool _interactingOtherIsNearby; float _pelvisStandingHeight; + AvatarTouch _avatarTouch; // private methods... void initializeSkeleton(); 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/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 fcaff494c1..629715fe09 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -81,6 +81,7 @@ #include #include "ViewFrustum.h" +#include "HandControl.h" using namespace std; @@ -101,6 +102,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); @@ -171,6 +174,8 @@ int displayField = 0; int displayHeadMouse = 1; // Display sample mouse pointer controlled by head movement int headMouseX, headMouseY; +HandControl handControl; + int mouseX = 0; int mouseY = 0; @@ -180,80 +185,6 @@ int mousePressed = 0; // true if mouse has been pressed (clear when finished) Menu menu; // main menu int menuOn = 1; // Whether to show onscreen menu -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 ) ); - } -} - - - // // Serial USB Variables // @@ -385,7 +316,7 @@ void init(void) voxels.setViewerAvatar(&myAvatar); myAvatar.setRenderYaw(startYaw); - initializeHandController(); + handControl.setScreenDimensions(WIDTH, HEIGHT); headMouseX = WIDTH/2; headMouseY = HEIGHT/2; @@ -820,37 +751,38 @@ void display(void) 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 ); @@ -1503,7 +1435,8 @@ void idle(void) { float deltaTime = 1.f/FPS; // update behaviors for avatar hand movement - updateHandController( mouseX, mouseY ); + handControl.update( mouseX, mouseY ); + myAvatar.setHandMovementValues( handControl.getValues() ); // tell my avatar if the mouse is being pressed... if ( mousePressed == 1 ) { @@ -1513,9 +1446,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(); } // From e9592f9360684a430a3f29ecfdd9b9761387b608 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Fri, 26 Apr 2013 12:55:13 -0700 Subject: [PATCH 2/4] moved handController --- interface/src/main.cpp | 77 ++---------------------------------------- 1 file changed, 2 insertions(+), 75 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 43651377cf..404f3bbfa9 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -180,80 +180,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 ) ); - } -} - -*/ // @@ -1536,7 +1462,8 @@ void idle(void) { float deltaTime = 1.f/FPS; - // update behaviors for avatar hand movement + // 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() ); From 59ef9e5d7ef6583bc23ca6036a2882c788a610dc Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Fri, 26 Apr 2013 13:21:49 -0700 Subject: [PATCH 3/4] removed incomplete code snippet in Avatar.h --- interface/src/Avatar.cpp | 11 ++++++----- interface/src/Avatar.h | 10 ---------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index d2e53c3fbf..3de87186f2 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -592,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 ); @@ -958,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 20c02eee84..6afb65c904 100644 --- a/interface/src/Avatar.h +++ b/interface/src/Avatar.h @@ -89,16 +89,6 @@ enum AvatarBoneID NUM_AVATAR_BONES }; - -/* -static glm::vec3 avatarDefaultPose[NUM_AVATAR_BONES] = -{ - glm::vec3( 0.0f, 0.0f, 0.0f ), - glm::vec3( 0.0f, 0.0f, 0.0f ) -}; -*/ - - struct AvatarCollisionElipsoid { bool colliding; From 2486b6e15c0380a54cddd887ff5441746095f19e Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Fri, 26 Apr 2013 13:33:36 -0700 Subject: [PATCH 4/4] moved inline functions from Camera.h to Camera.cpp as per Stephen's request --- interface/src/Camera.cpp | 42 +++++++++++++++++++++++++++++++--------- interface/src/Camera.h | 11 ++++++----- 2 files changed, 39 insertions(+), 14 deletions(-) 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; }