added quaternions to avatar body and bone structure (but not using them yet)

This commit is contained in:
Jeffrey Ventrella 2013-04-17 12:31:03 -07:00
parent 851b833d35
commit 4f0ca2f33e
3 changed files with 43 additions and 46 deletions

View file

@ -48,26 +48,20 @@ unsigned int iris_texture_height = 256;
Head::Head() { Head::Head() {
initializeAvatar(); initializeAvatar();
avatar.orientation.setToIdentity();
avatar.velocity = glm::vec3( 0.0, 0.0, 0.0 ); avatar.velocity = glm::vec3( 0.0, 0.0, 0.0 );
avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 ); avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
avatar.orientation.setToIdentity(); rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
closestOtherAvatar = 0;
closestOtherAvatar = 0; _bodyYaw = -90.0;
_bodyPitch = 0.0;
_bodyYaw = -90.0; _bodyRoll = 0.0;
_bodyPitch = 0.0; bodyYawDelta = 0.0;
_bodyRoll = 0.0; triggeringAction = false;
mode = AVATAR_MODE_STANDING;
bodyYawDelta = 0.0;
triggeringAction = false;
mode = AVATAR_MODE_STANDING;
initializeSkeleton(); initializeSkeleton();
for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = false; for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = false;
PupilSize = 0.10; PupilSize = 0.10;
@ -102,17 +96,15 @@ Head::Head() {
browAudioLift = 0.0; browAudioLift = 0.0;
noise = 0; noise = 0;
handBeingMoved = false; handBeingMoved = false;
previousHandBeingMoved = false; previousHandBeingMoved = false;
movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 ); movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
usingSprings = false;
springForce = 6.0f;
springVelocityDecay = 16.0f;
sphere = NULL; sphere = NULL;
usingSprings = false;
springForce = 6.0f;
springVelocityDecay = 16.0f;
if (iris_texture.size() == 0) { if (iris_texture.size() == 0) {
switchToResourcesIfRequired(); switchToResourcesIfRequired();
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file); 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) { Head::Head(const Head &otherHead) {
initializeAvatar(); initializeAvatar();
avatar.orientation.set( otherHead.avatar.orientation );
avatar.velocity = otherHead.avatar.velocity; avatar.velocity = otherHead.avatar.velocity;
avatar.thrust = otherHead.avatar.thrust; avatar.thrust = otherHead.avatar.thrust;
avatar.orientation.set( otherHead.avatar.orientation ); rotation = otherHead.rotation;
closestOtherAvatar = otherHead.closestOtherAvatar;
closestOtherAvatar = otherHead.closestOtherAvatar; _bodyYaw = otherHead._bodyYaw;
_bodyPitch = otherHead._bodyPitch;
_bodyYaw = otherHead._bodyYaw; _bodyRoll = otherHead._bodyRoll;
_bodyPitch = otherHead._bodyPitch; bodyYawDelta = otherHead.bodyYawDelta;
_bodyRoll = otherHead._bodyRoll; triggeringAction = otherHead.triggeringAction;
mode = otherHead.mode;
bodyYawDelta = otherHead.bodyYawDelta;
triggeringAction = otherHead.triggeringAction;
mode = otherHead.mode;
initializeSkeleton(); initializeSkeleton();
for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = otherHead.driveKeys[i]; for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = otherHead.driveKeys[i];
PupilSize = otherHead.PupilSize; PupilSize = otherHead.PupilSize;
@ -833,14 +818,19 @@ void Head::initializeAvatar() {
} }
void Head::initializeSkeleton() { void Head::initializeSkeleton() {
for (int b=0; b<NUM_AVATAR_BONES; b++) { for (int b=0; b<NUM_AVATAR_BONES; b++) {
bone[b].parent = AVATAR_BONE_NULL;
bone[b].position = glm::vec3( 0.0, 0.0, 0.0 ); bone[b].position = glm::vec3( 0.0, 0.0, 0.0 );
bone[b].springyPosition = glm::vec3( 0.0, 0.0, 0.0 ); bone[b].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.0 );
bone[b].springyVelocity = glm::vec3( 0.0, 0.0, 0.0 ); bone[b].springyPosition = glm::vec3( 0.0, 0.0, 0.0 );
bone[b].springyVelocity = glm::vec3( 0.0, 0.0, 0.0 );
bone[b].rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
bone[b].yaw = 0.0;
bone[b].pitch = 0.0;
bone[b].roll = 0.0;
bone[b].length = 0.0;
bone[b].springBodyTightness = 4.0; bone[b].springBodyTightness = 4.0;
bone[b].orientation.setToIdentity(); bone[b].orientation.setToIdentity();
} }

View file

@ -20,6 +20,11 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "SerialInterface.h" #include "SerialInterface.h"
//#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp> and <glm/gtx/quaternion.hpp>
enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH}; enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
#define FWD 0 #define FWD 0
@ -80,6 +85,7 @@ struct AvatarBone
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position) 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) 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 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 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 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 float roll; // the roll Euler angle of the bone rotation off the parent
@ -231,7 +237,9 @@ class Head : public AvatarData {
GLUquadric *sphere; GLUquadric *sphere;
Avatar avatar; Avatar avatar;
glm::quat rotation; // the rotation of the avatar body as a whole
AvatarBone bone[ NUM_AVATAR_BONES ]; AvatarBone bone[ NUM_AVATAR_BONES ];
AvatarMode mode; AvatarMode mode;

View file

@ -22,7 +22,6 @@ void Orientation::setToIdentity() {
front = glm::vec3( 0.0, 0.0, 1.0 ); front = glm::vec3( 0.0, 0.0, 1.0 );
} }
void Orientation::set( Orientation o ) { void Orientation::set( Orientation o ) {
right = o.right; right = o.right;
up = o.up; 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 rightCross = glm::cross( up, front );
glm::vec3 upCross = glm::cross( front, right ); glm::vec3 upCross = glm::cross( front, right );