From 1fb8d0b26841d538678ff406c40fdbd4fad86c5c Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Tue, 16 Apr 2013 20:35:50 -0700 Subject: [PATCH] consolidated some code in Head.cpp --- interface/src/Head.cpp | 72 +++++++++++++++++++++++---- interface/src/Head.h | 23 ++++++--- libraries/avatars/src/Orientation.cpp | 8 +-- 3 files changed, 82 insertions(+), 21 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 97b50bfc3e..6869cd659d 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -48,6 +48,26 @@ unsigned int iris_texture_height = 256; Head::Head() { initializeAvatar(); + + avatar.velocity = glm::vec3( 0.0, 0.0, 0.0 ); + avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 ); + avatar.orientation.setToIdentity(); + + closestOtherAvatar = 0; + + _bodyYaw = -90.0; + _bodyPitch = 0.0; + _bodyRoll = 0.0; + + bodyYawDelta = 0.0; + + triggeringAction = false; + + mode = AVATAR_MODE_STANDING; + + initializeSkeleton(); + + for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = false; PupilSize = 0.10; @@ -121,6 +141,25 @@ Head::Head() { Head::Head(const Head &otherHead) { initializeAvatar(); + + avatar.velocity = otherHead.avatar.velocity; + avatar.thrust = otherHead.avatar.thrust; + avatar.orientation.set( otherHead.avatar.orientation ); + + closestOtherAvatar = otherHead.closestOtherAvatar; + + _bodyYaw = otherHead._bodyYaw; + _bodyPitch = otherHead._bodyPitch; + _bodyRoll = otherHead._bodyRoll; + + bodyYawDelta = otherHead.bodyYawDelta; + + triggeringAction = otherHead.triggeringAction; + + mode = otherHead.mode; + + initializeSkeleton(); + for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = otherHead.driveKeys[i]; @@ -298,14 +337,14 @@ void Head::simulate(float deltaTime) { //------------------------ // update avatar skeleton //------------------------ - updateAvatarSkeleton(); + updateSkeleton(); //------------------------------------------------------------------------ // reset hand and elbow position according to hand movement //------------------------------------------------------------------------ if ( handBeingMoved ){ if (! previousHandBeingMoved ){ - initializeAvatarSprings(); + initializeBodySprings(); usingSprings = true; //printf( "just started moving hand\n" ); } @@ -319,7 +358,7 @@ void Head::simulate(float deltaTime) { if ( handBeingMoved ) { updateHandMovement(); - updateAvatarSprings( deltaTime ); + updateBodySprings( deltaTime ); } previousHandBeingMoved = handBeingMoved; @@ -508,6 +547,8 @@ void Head::simulate(float deltaTime) { void Head::render(int faceToFace, int isMine) { + +/* //--------------------------------------------------- // show avatar position //--------------------------------------------------- @@ -516,7 +557,8 @@ void Head::render(int faceToFace, int isMine) { glScalef( 0.03, 0.03, 0.03 ); glutSolidSphere( 1, 10, 10 ); glPopMatrix(); - +*/ + //--------------------------------------------------- // show avatar orientation //--------------------------------------------------- @@ -768,6 +810,7 @@ AvatarMode Head::getMode() { void Head::initializeAvatar() { +/* avatar.velocity = glm::vec3( 0.0, 0.0, 0.0 ); avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 ); avatar.orientation.setToIdentity(); @@ -783,7 +826,16 @@ void Head::initializeAvatar() { triggeringAction = false; mode = AVATAR_MODE_STANDING; - + + initializeSkeleton(); + */ +} + + + + +void Head::initializeSkeleton() { + for (int b=0; b -static bool testingForNormalizationAndOrthogonality = false; +static bool testingForNormalizationAndOrthogonality = true; Orientation::Orientation() { right = glm::vec3( 1.0, 0.0, 0.0 ); @@ -94,9 +94,9 @@ void Orientation::setRightUpFront( const glm::vec3 &r, const glm::vec3 &u, const //---------------------------------------------------------------------- void Orientation::testForOrthogonalAndNormalizedVectors( float epsilon ) { - //---------------------------------------------------------------- - // make sure vectors are normalized (or close to length 1) - //---------------------------------------------------------------- + //------------------------------------------------------------------ + // make sure vectors are normalized (or close enough to length 1.0) + //------------------------------------------------------------------ float rightLength = glm::length( right ); float upLength = glm::length( up ); float frontLength = glm::length( front );