From 4f0ca2f33eff3cc167a0d873fc59ca76c62b43ed Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 17 Apr 2013 12:31:03 -0700 Subject: [PATCH] added quaternions to avatar body and bone structure (but not using them yet) --- interface/src/Head.cpp | 76 ++++++++++++--------------- interface/src/Head.h | 10 +++- libraries/avatars/src/Orientation.cpp | 3 +- 3 files changed, 43 insertions(+), 46 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 4f77e6fafe..18fa5c9181 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -48,26 +48,20 @@ unsigned int iris_texture_height = 256; Head::Head() { initializeAvatar(); - + avatar.orientation.setToIdentity(); 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; + rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f ); + 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; @@ -102,17 +96,15 @@ Head::Head() { browAudioLift = 0.0; noise = 0; - handBeingMoved = false; - previousHandBeingMoved = false; - movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 ); + handBeingMoved = false; + previousHandBeingMoved = false; + movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 ); + usingSprings = false; + springForce = 6.0f; + springVelocityDecay = 16.0f; sphere = NULL; - usingSprings = false; - - springForce = 6.0f; - springVelocityDecay = 16.0f; - if (iris_texture.size() == 0) { switchToResourcesIfRequired(); unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file); @@ -137,30 +129,23 @@ Head::Head() { } - - Head::Head(const Head &otherHead) { initializeAvatar(); + avatar.orientation.set( otherHead.avatar.orientation ); 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; + rotation = otherHead.rotation; + 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]; PupilSize = otherHead.PupilSize; @@ -833,14 +818,19 @@ void Head::initializeAvatar() { } - - void Head::initializeSkeleton() { for (int b=0; b + +#include and + + enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH}; #define FWD 0 @@ -80,6 +85,7 @@ struct AvatarBone glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position) glm::dvec3 springyVelocity; // used for special effects ( the velocity of the springy position) float springBodyTightness; // how tightly the springy position tries to stay on the position + glm::quat rotation; // this will eventually replace yaw, pitch and roll (and maybe orienttion) float yaw; // the yaw Euler angle of the bone rotation off the parent float pitch; // the pitch Euler angle of the bone rotation off the parent float roll; // the roll Euler angle of the bone rotation off the parent @@ -231,7 +237,9 @@ class Head : public AvatarData { GLUquadric *sphere; Avatar avatar; - + + glm::quat rotation; // the rotation of the avatar body as a whole + AvatarBone bone[ NUM_AVATAR_BONES ]; AvatarMode mode; diff --git a/libraries/avatars/src/Orientation.cpp b/libraries/avatars/src/Orientation.cpp index 8eeb3dd0ff..f11f820c89 100755 --- a/libraries/avatars/src/Orientation.cpp +++ b/libraries/avatars/src/Orientation.cpp @@ -22,7 +22,6 @@ void Orientation::setToIdentity() { front = glm::vec3( 0.0, 0.0, 1.0 ); } - void Orientation::set( Orientation o ) { right = o.right; up = o.up; @@ -125,7 +124,7 @@ void Orientation::testForOrthogonalAndNormalizedVectors( float epsilon ) { //---------------------------------------------------------------- - // make sure vectors are orthoginal (or close enough) + // make sure vectors are orthogonal (or close enough) //---------------------------------------------------------------- glm::vec3 rightCross = glm::cross( up, front ); glm::vec3 upCross = glm::cross( front, right );