diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index f39c62e1aa..e68a957c2d 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -16,9 +16,6 @@ #include #include #include -//#include -//#include -//#include //looks like we might not need this using namespace std; @@ -68,40 +65,45 @@ Head::Head(bool isMine) { _TEST_bigSphereRadius = 0.3f; _TEST_bigSpherePosition = glm::vec3( 0.0f, _TEST_bigSphereRadius, 2.0f ); - 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; - interPupilDistance = 0.6; - interBrowDistance = 0.75; - NominalPupilSize = 0.10; - _headYaw = 0.0; - EyebrowPitch[0] = EyebrowPitch[1] = -30; - EyebrowRoll[0] = 20; - EyebrowRoll[1] = -20; - MouthPitch = 0; - MouthYaw = 0; - MouthWidth = 1.0; - MouthHeight = 0.2; - EyeballPitch[0] = EyeballPitch[1] = 0; - EyeballScaleX = 1.2; EyeballScaleY = 1.5; EyeballScaleZ = 1.0; - EyeballYaw[0] = EyeballYaw[1] = 0; - PitchTarget = YawTarget = 0; - NoiseEnvelope = 1.0; - PupilConverge = 10.0; - leanForward = 0.0; - leanSideways = 0.0; - eyeContact = 1; - eyeContactTarget = LEFT_EYE; - scale = 1.0; - renderYaw = 0.0; - renderPitch = 0.0; - audioAttack = 0.0; - loudness = 0.0; - averageLoudness = 0.0; - lastLoudness = 0.0; - browAudioLift = 0.0; - noise = 0; - + _pupilSize = 0.10; + _interPupilDistance = 0.6; + _interBrowDistance = 0.75; + _nominalPupilSize = 0.10; + _headYaw = 0.0; + _eyebrowPitch[0] = -30; + _eyebrowPitch[1] = -30; + _eyebrowRoll [0] = 20; + _eyebrowRoll [1] = -20; + _mouthPitch = 0; + _mouthYaw = 0; + _mouthWidth = 1.0; + _mouthHeight = 0.2; + _eyeballPitch[0] = 0; + _eyeballPitch[1] = 0; + _eyeballScaleX = 1.2; + _eyeballScaleY = 1.5; + _eyeballScaleZ = 1.0; + _eyeballYaw[0] = 0; + _eyeballYaw[1] = 0; + _pitchTarget = 0; + _yawTarget = 0; + _noiseEnvelope = 1.0; + _pupilConverge = 10.0; + _leanForward = 0.0; + _leanSideways = 0.0; + _eyeContact = 1; + _eyeContactTarget = LEFT_EYE; + _scale = 1.0; + _renderYaw = 0.0; + _renderPitch = 0.0; + _audioAttack = 0.0; + _loudness = 0.0; + _averageLoudness = 0.0; + _lastLoudness = 0.0; + _browAudioLift = 0.0; + _noise = 0; _handBeingMoved = false; _previousHandBeingMoved = false; _movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 ); @@ -109,7 +111,7 @@ Head::Head(bool isMine) { _springForce = 6.0f; _springVelocityDecay = 16.0f; - sphere = NULL; + _sphere = NULL; if (iris_texture.size() == 0) { switchToResourcesParentIfRequired(); @@ -120,18 +122,18 @@ Head::Head(bool isMine) { } for (int o=0; o BROW_LIFT_THRESHOLD) - browAudioLift += sqrt(audioAttack)/1000.0; + if (_audioAttack > BROW_LIFT_THRESHOLD) + _browAudioLift += sqrt(_audioAttack)/1000.0; - browAudioLift *= .90; + _browAudioLift *= .90; glPushMatrix(); - glTranslatef(-interBrowDistance/2.0,0.4,0.45); + glTranslatef(-_interBrowDistance/2.0,0.4,0.45); for(side = 0; side < 2; side++) { glColor3fv(browColor); glPushMatrix(); - glTranslatef(0, 0.35 + browAudioLift, 0); - glRotatef(EyebrowPitch[side]/2.0, 1, 0, 0); - glRotatef(EyebrowRoll[side]/2.0, 0, 0, 1); + glTranslatef(0, 0.35 + _browAudioLift, 0); + glRotatef(_eyebrowPitch[side]/2.0, 1, 0, 0); + glRotatef(_eyebrowRoll[side]/2.0, 0, 0, 1); glScalef(browWidth, browThickness, 1); glutSolidCube(0.5); glPopMatrix(); - glTranslatef(interBrowDistance, 0, 0); + glTranslatef(_interBrowDistance, 0, 0); } glPopMatrix(); @@ -785,73 +787,73 @@ void Head::renderHead(int faceToFace) { glPushMatrix(); glTranslatef(0,-0.35,0.75); glColor3f(0,0,0); - glRotatef(MouthPitch, 1, 0, 0); - glRotatef(MouthYaw, 0, 0, 1); - glScalef(MouthWidth*(.7 + sqrt(averageLoudness)/60.0), MouthHeight*(1.0 + sqrt(averageLoudness)/30.0), 1); + glRotatef(_mouthPitch, 1, 0, 0); + glRotatef(_mouthYaw, 0, 0, 1); + glScalef(_mouthWidth*(.7 + sqrt(_averageLoudness)/60.0), _mouthHeight*(1.0 + sqrt(_averageLoudness)/30.0), 1); glutSolidCube(0.5); glPopMatrix(); glTranslatef(0, 1.0, 0); - glTranslatef(-interPupilDistance/2.0,-0.68,0.7); + glTranslatef(-_interPupilDistance/2.0,-0.68,0.7); // Right Eye glRotatef(-10, 1, 0, 0); glColor3fv(eyeColor); glPushMatrix(); { - glTranslatef(interPupilDistance/10.0, 0, 0.05); + glTranslatef(_interPupilDistance/10.0, 0, 0.05); glRotatef(20, 0, 0, 1); - glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ); + glScalef(_eyeballScaleX, _eyeballScaleY, _eyeballScaleZ); glutSolidSphere(0.25, 30, 30); } glPopMatrix(); // Right Pupil - if (sphere == NULL) { - sphere = gluNewQuadric(); - gluQuadricTexture(sphere, GL_TRUE); + if (_sphere == NULL) { + _sphere = gluNewQuadric(); + gluQuadricTexture(_sphere, GL_TRUE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - gluQuadricOrientation(sphere, GLU_OUTSIDE); + gluQuadricOrientation(_sphere, GLU_OUTSIDE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iris_texture_width, iris_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &iris_texture[0]); } glPushMatrix(); { - glRotatef(EyeballPitch[1], 1, 0, 0); - glRotatef(EyeballYaw[1] + PupilConverge, 0, 1, 0); + glRotatef(_eyeballPitch[1], 1, 0, 0); + glRotatef(_eyeballYaw[1] + _pupilConverge, 0, 1, 0); glTranslatef(0,0,.35); glRotatef(-75,1,0,0); glScalef(1.0, 0.4, 1.0); glEnable(GL_TEXTURE_2D); - gluSphere(sphere, PupilSize, 15, 15); + gluSphere(_sphere, _pupilSize, 15, 15); glDisable(GL_TEXTURE_2D); } glPopMatrix(); // Left Eye glColor3fv(eyeColor); - glTranslatef(interPupilDistance, 0, 0); + glTranslatef(_interPupilDistance, 0, 0); glPushMatrix(); { - glTranslatef(-interPupilDistance/10.0, 0, .05); + glTranslatef(-_interPupilDistance/10.0, 0, .05); glRotatef(-20, 0, 0, 1); - glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ); + glScalef(_eyeballScaleX, _eyeballScaleY, _eyeballScaleZ); glutSolidSphere(0.25, 30, 30); } glPopMatrix(); // Left Pupil glPushMatrix(); { - glRotatef(EyeballPitch[0], 1, 0, 0); - glRotatef(EyeballYaw[0] - PupilConverge, 0, 1, 0); + glRotatef(_eyeballPitch[0], 1, 0, 0); + glRotatef(_eyeballYaw[0] - _pupilConverge, 0, 1, 0); glTranslatef(0, 0, .35); glRotatef(-75, 1, 0, 0); glScalef(1.0, 0.4, 1.0); glEnable(GL_TEXTURE_2D); - gluSphere(sphere, PupilSize, 15, 15); + gluSphere(_sphere, _pupilSize, 15, 15); glDisable(GL_TEXTURE_2D); } @@ -939,7 +941,6 @@ void Head::initializeSkeleton() { _bone[ AVATAR_BONE_RIGHT_SHIN ].parent = AVATAR_BONE_RIGHT_THIGH; _bone[ AVATAR_BONE_RIGHT_FOOT ].parent = AVATAR_BONE_RIGHT_SHIN; - //---------------------------------------------------------- // specify the default pose position //---------------------------------------------------------- @@ -1143,11 +1144,10 @@ void Head::updateHandMovement() { transformedHandMovement += handShakePull; */ - _bone[ AVATAR_BONE_RIGHT_HAND ].position = DEBUG_otherAvatarListPosition[ _closestOtherAvatar ]; + _bone[ AVATAR_BONE_RIGHT_HAND ].position = _DEBUG_otherAvatarListPosition[ _closestOtherAvatar ]; } } } - //------------------------------------------------------------------------------- // determine the arm vector @@ -1282,8 +1282,8 @@ void Head::renderBody() { } void Head::SetNewHeadTarget(float pitch, float yaw) { - PitchTarget = pitch; - YawTarget = yaw; + _pitchTarget = pitch; + _yawTarget = yaw; } // getting data from Android transmitte app @@ -1301,17 +1301,17 @@ void Head::processTransmitterData(unsigned char* packetData, int numBytes) { &linX, &linY, &linZ, &rot1, &rot2, &rot3, &rot4); - if (transmitterPackets++ == 0) { - gettimeofday(&transmitterTimer, NULL); + if (_transmitterPackets++ == 0) { + gettimeofday(&_transmitterTimer, NULL); } const int TRANSMITTER_COUNT = 100; - if (transmitterPackets % TRANSMITTER_COUNT == 0) { + if (_transmitterPackets % TRANSMITTER_COUNT == 0) { // Every 100 packets, record the observed Hz of the transmitter data timeval now; gettimeofday(&now, NULL); - double msecsElapsed = diffclock(&transmitterTimer, &now); - transmitterHz = static_cast( (double)TRANSMITTER_COUNT/(msecsElapsed/1000.0) ); - transmitterTimer = now; + double msecsElapsed = diffclock(&_transmitterTimer, &now); + _transmitterHz = static_cast( (double)TRANSMITTER_COUNT/(msecsElapsed/1000.0) ); + _transmitterTimer = now; } /* NOTE: PR: Will add back in when ready to animate avatar hand diff --git a/interface/src/Head.h b/interface/src/Head.h index cedc242ea5..c3150f53b9 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -108,15 +108,15 @@ class Head : public AvatarData { void reset(); void UpdateGyros(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity); - void setNoise (float mag) { noise = mag; } + void setNoise (float mag) { _noise = mag; } void setPitch(float p) {_headPitch = p; } void setYaw(float y) {_headYaw = y; } void setRoll(float r) {_headRoll = r; }; - void setScale(float s) {scale = s; }; - void setRenderYaw(float y) {renderYaw = y;} - void setRenderPitch(float p) {renderPitch = p;} - float getRenderYaw() {return renderYaw;} - float getRenderPitch() {return renderPitch;} + void setScale(float s) {_scale = s; }; + void setRenderYaw(float y) {_renderYaw = y;} + void setRenderPitch(float p) {_renderPitch = p;} + float getRenderYaw() {return _renderYaw;} + float getRenderPitch() {return _renderPitch;} void setLeanForward(float dist); void setLeanSideways(float dist); void addPitch(float p) {_headPitch -= p; } @@ -152,16 +152,16 @@ class Head : public AvatarData { void setHandMovement( glm::vec3 movement ); void updateHandMovement(); - float getLoudness() {return loudness;}; - float getAverageLoudness() {return averageLoudness;}; - void setAverageLoudness(float al) {averageLoudness = al;}; - void setLoudness(float l) {loudness = l;}; + float getLoudness() {return _loudness;}; + float getAverageLoudness() {return _averageLoudness;}; + void setAverageLoudness(float al) {_averageLoudness = al;}; + void setLoudness(float l) {_loudness = l;}; void SetNewHeadTarget(float, float); // Set what driving keys are being pressed to control thrust levels - void setDriveKeys(int key, bool val) { driveKeys[key] = val; }; - bool getDriveKeys(int key) { return driveKeys[key]; }; + void setDriveKeys(int key, bool val) { _driveKeys[key] = val; }; + bool getDriveKeys(int key) { return _driveKeys[key]; }; // Set/Get update the thrust that will move the avatar around void setThrust(glm::vec3 newThrust) { _avatar.thrust = newThrust; }; @@ -173,51 +173,48 @@ class Head : public AvatarData { // void processTransmitterData(unsigned char * packetData, int numBytes); - float getTransmitterHz() { return transmitterHz; }; + float getTransmitterHz() { return _transmitterHz; }; private: - bool _isMine; - float noise; + bool _isMine; + float _noise; float _headPitch; float _headYaw; float _headRoll; float _headPitchRate; float _headYawRate; float _headRollRate; - float EyeballPitch[2]; - float EyeballYaw[2]; - float EyebrowPitch[2]; - float EyebrowRoll[2]; - float EyeballScaleX, EyeballScaleY, EyeballScaleZ; - float interPupilDistance; - float interBrowDistance; - float NominalPupilSize; - float PupilSize; - float MouthPitch; - float MouthYaw; - float MouthWidth; - float MouthHeight; - float leanForward; - float leanSideways; - float PitchTarget; - float YawTarget; - float NoiseEnvelope; - float PupilConverge; - float scale; + float _eyeballPitch[2]; + float _eyeballYaw[2]; + float _eyebrowPitch[2]; + float _eyebrowRoll[2]; + float _eyeballScaleX, _eyeballScaleY, _eyeballScaleZ; + float _interPupilDistance; + float _interBrowDistance; + float _nominalPupilSize; + float _pupilSize; + float _mouthPitch; + float _mouthYaw; + float _mouthWidth; + float _mouthHeight; + float _leanForward; + float _leanSideways; + float _pitchTarget; + float _yawTarget; + float _noiseEnvelope; + float _pupilConverge; + float _scale; // Sound loudness information - float loudness, lastLoudness; - float averageLoudness; - float audioAttack; - float browAudioLift; + float _loudness, _lastLoudness; + float _averageLoudness; + float _audioAttack; + float _browAudioLift; - glm::vec3 _TEST_bigSpherePosition; - float _TEST_bigSphereRadius; - - //temporary - placeholder for real other avs - glm::vec3 DEBUG_otherAvatarListPosition [ NUM_OTHER_AVATARS ]; - float DEBUG_otherAvatarListTimer [ NUM_OTHER_AVATARS ]; - + glm::vec3 _TEST_bigSpherePosition; + float _TEST_bigSphereRadius; + glm::vec3 _DEBUG_otherAvatarListPosition[ NUM_OTHER_AVATARS ]; + float _DEBUG_otherAvatarListTimer [ NUM_OTHER_AVATARS ]; bool _triggeringAction; float _bodyYawDelta; float _closeEnoughToInteract; @@ -232,23 +229,21 @@ class Head : public AvatarData { AvatarBone _bone[ NUM_AVATAR_BONES ]; AvatarMode _mode; Avatar _avatar; + int _driveKeys[MAX_DRIVE_KEYS]; + int _eyeContact; + eyeContactTargets _eyeContactTarget; - int driveKeys[MAX_DRIVE_KEYS]; - - - int eyeContact; - eyeContactTargets eyeContactTarget; - - GLUquadric *sphere; + GLUquadric *_sphere; - float renderYaw, renderPitch; // Pitch from view frustum when this is own head. + float _renderYaw; + float _renderPitch; // Pitch from view frustum when this is own head. // // Related to getting transmitter UDP data used to animate the avatar hand // - timeval transmitterTimer; - float transmitterHz; - int transmitterPackets; + timeval _transmitterTimer; + float _transmitterHz; + int _transmitterPackets; //----------------------------- // private methods... diff --git a/libraries/avatars/src/Orientation.cpp b/libraries/avatars/src/Orientation.cpp index 08a4467f35..1cedb7305e 100755 --- a/libraries/avatars/src/Orientation.cpp +++ b/libraries/avatars/src/Orientation.cpp @@ -20,6 +20,8 @@ using avatars_lib::printLog; // // tosh - yep, I noticed... :-) // +// JJV - I noticed too :-) +// static bool testingForNormalizationAndOrthogonality = false; Orientation::Orientation() {