added "_" to all of Philip's old private members and tidied up the formatting in Head.h some

This commit is contained in:
Jeffrey Ventrella 2013-04-18 13:16:36 -07:00
parent 042bb7c332
commit de6f33efa6
3 changed files with 227 additions and 230 deletions

View file

@ -16,9 +16,6 @@
#include <AgentList.h> #include <AgentList.h>
#include <AgentTypes.h> #include <AgentTypes.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
//#include <glm/glm.hpp>
//#include <glm/gtc/quaternion.hpp>
//#include <glm/gtx/quaternion.hpp> //looks like we might not need this
using namespace std; using namespace std;
@ -68,40 +65,45 @@ Head::Head(bool isMine) {
_TEST_bigSphereRadius = 0.3f; _TEST_bigSphereRadius = 0.3f;
_TEST_bigSpherePosition = glm::vec3( 0.0f, _TEST_bigSphereRadius, 2.0f ); _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; _pupilSize = 0.10;
interPupilDistance = 0.6; _interPupilDistance = 0.6;
interBrowDistance = 0.75; _interBrowDistance = 0.75;
NominalPupilSize = 0.10; _nominalPupilSize = 0.10;
_headYaw = 0.0; _headYaw = 0.0;
EyebrowPitch[0] = EyebrowPitch[1] = -30; _eyebrowPitch[0] = -30;
EyebrowRoll[0] = 20; _eyebrowPitch[1] = -30;
EyebrowRoll[1] = -20; _eyebrowRoll [0] = 20;
MouthPitch = 0; _eyebrowRoll [1] = -20;
MouthYaw = 0; _mouthPitch = 0;
MouthWidth = 1.0; _mouthYaw = 0;
MouthHeight = 0.2; _mouthWidth = 1.0;
EyeballPitch[0] = EyeballPitch[1] = 0; _mouthHeight = 0.2;
EyeballScaleX = 1.2; EyeballScaleY = 1.5; EyeballScaleZ = 1.0; _eyeballPitch[0] = 0;
EyeballYaw[0] = EyeballYaw[1] = 0; _eyeballPitch[1] = 0;
PitchTarget = YawTarget = 0; _eyeballScaleX = 1.2;
NoiseEnvelope = 1.0; _eyeballScaleY = 1.5;
PupilConverge = 10.0; _eyeballScaleZ = 1.0;
leanForward = 0.0; _eyeballYaw[0] = 0;
leanSideways = 0.0; _eyeballYaw[1] = 0;
eyeContact = 1; _pitchTarget = 0;
eyeContactTarget = LEFT_EYE; _yawTarget = 0;
scale = 1.0; _noiseEnvelope = 1.0;
renderYaw = 0.0; _pupilConverge = 10.0;
renderPitch = 0.0; _leanForward = 0.0;
audioAttack = 0.0; _leanSideways = 0.0;
loudness = 0.0; _eyeContact = 1;
averageLoudness = 0.0; _eyeContactTarget = LEFT_EYE;
lastLoudness = 0.0; _scale = 1.0;
browAudioLift = 0.0; _renderYaw = 0.0;
noise = 0; _renderPitch = 0.0;
_audioAttack = 0.0;
_loudness = 0.0;
_averageLoudness = 0.0;
_lastLoudness = 0.0;
_browAudioLift = 0.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 );
@ -109,7 +111,7 @@ Head::Head(bool isMine) {
_springForce = 6.0f; _springForce = 6.0f;
_springVelocityDecay = 16.0f; _springVelocityDecay = 16.0f;
sphere = NULL; _sphere = NULL;
if (iris_texture.size() == 0) { if (iris_texture.size() == 0) {
switchToResourcesParentIfRequired(); switchToResourcesParentIfRequired();
@ -120,18 +122,18 @@ Head::Head(bool isMine) {
} }
for (int o=0; o<NUM_OTHER_AVATARS; o++) { for (int o=0; o<NUM_OTHER_AVATARS; o++) {
DEBUG_otherAvatarListTimer[o] = 0.0f; _DEBUG_otherAvatarListTimer[o] = 0.0f;
DEBUG_otherAvatarListPosition[o] = glm::vec3( 0.0f, 0.0f, 0.0f ); _DEBUG_otherAvatarListPosition[o] = glm::vec3( 0.0f, 0.0f, 0.0f );
} }
//-------------------------------------------------- //--------------------------------------------------
// test... just slam them into random positions... // test... just slam them into random positions...
//-------------------------------------------------- //--------------------------------------------------
DEBUG_otherAvatarListPosition[ 0 ] = glm::vec3( 0.0, 0.3, 2.0 ); _DEBUG_otherAvatarListPosition[ 0 ] = glm::vec3( 0.0, 0.3, 2.0 );
DEBUG_otherAvatarListPosition[ 1 ] = glm::vec3( 4.0, 0.3, 2.0 ); _DEBUG_otherAvatarListPosition[ 1 ] = glm::vec3( 4.0, 0.3, 2.0 );
DEBUG_otherAvatarListPosition[ 2 ] = glm::vec3( 2.0, 0.3, 2.0 ); _DEBUG_otherAvatarListPosition[ 2 ] = glm::vec3( 2.0, 0.3, 2.0 );
DEBUG_otherAvatarListPosition[ 3 ] = glm::vec3( 1.0, 0.3, -4.0 ); _DEBUG_otherAvatarListPosition[ 3 ] = glm::vec3( 1.0, 0.3, -4.0 );
DEBUG_otherAvatarListPosition[ 4 ] = glm::vec3( -2.0, 0.3, -2.0 ); _DEBUG_otherAvatarListPosition[ 4 ] = glm::vec3( -2.0, 0.3, -2.0 );
} }
Head::Head(const Head &otherHead) { Head::Head(const Head &otherHead) {
@ -150,53 +152,53 @@ Head::Head(const Head &otherHead) {
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;
interPupilDistance = otherHead.interPupilDistance; _interPupilDistance = otherHead._interPupilDistance;
interBrowDistance = otherHead.interBrowDistance; _interBrowDistance = otherHead._interBrowDistance;
NominalPupilSize = otherHead.NominalPupilSize; _nominalPupilSize = otherHead._nominalPupilSize;
_headYaw = otherHead._headYaw; _headYaw = otherHead._headYaw;
EyebrowPitch[0] = otherHead.EyebrowPitch[0]; _eyebrowPitch[0] = otherHead._eyebrowPitch[0];
EyebrowPitch[1] = otherHead.EyebrowPitch[1]; _eyebrowPitch[1] = otherHead._eyebrowPitch[1];
EyebrowRoll[0] = otherHead.EyebrowRoll[0]; _eyebrowRoll [0] = otherHead._eyebrowRoll [0];
EyebrowRoll[1] = otherHead.EyebrowRoll[1]; _eyebrowRoll [1] = otherHead._eyebrowRoll [1];
MouthPitch = otherHead.MouthPitch; _mouthPitch = otherHead._mouthPitch;
MouthYaw = otherHead.MouthYaw; _mouthYaw = otherHead._mouthYaw;
MouthWidth = otherHead.MouthWidth; _mouthWidth = otherHead._mouthWidth;
MouthHeight = otherHead.MouthHeight; _mouthHeight = otherHead._mouthHeight;
EyeballPitch[0] = otherHead.EyeballPitch[0]; _eyeballPitch[0] = otherHead._eyeballPitch[0];
EyeballPitch[1] = otherHead.EyeballPitch[1]; _eyeballPitch[1] = otherHead._eyeballPitch[1];
EyeballScaleX = otherHead.EyeballScaleX; _eyeballScaleX = otherHead._eyeballScaleX;
EyeballScaleY = otherHead.EyeballScaleY; _eyeballScaleY = otherHead._eyeballScaleY;
EyeballScaleZ = otherHead.EyeballScaleZ; _eyeballScaleZ = otherHead._eyeballScaleZ;
EyeballYaw[0] = otherHead.EyeballYaw[0]; _eyeballYaw[0] = otherHead._eyeballYaw[0];
EyeballYaw[1] = otherHead.EyeballYaw[1]; _eyeballYaw[1] = otherHead._eyeballYaw[1];
PitchTarget = otherHead.PitchTarget; _pitchTarget = otherHead._pitchTarget;
YawTarget = otherHead.YawTarget; _yawTarget = otherHead._yawTarget;
NoiseEnvelope = otherHead.NoiseEnvelope; _noiseEnvelope = otherHead._noiseEnvelope;
PupilConverge = otherHead.PupilConverge; _pupilConverge = otherHead._pupilConverge;
leanForward = otherHead.leanForward; _leanForward = otherHead._leanForward;
leanSideways = otherHead.leanSideways; _leanSideways = otherHead._leanSideways;
eyeContact = otherHead.eyeContact; _eyeContact = otherHead._eyeContact;
eyeContactTarget = otherHead.eyeContactTarget; _eyeContactTarget = otherHead._eyeContactTarget;
scale = otherHead.scale; _scale = otherHead._scale;
renderYaw = otherHead.renderYaw; _renderYaw = otherHead._renderYaw;
renderPitch = otherHead.renderPitch; _renderPitch = otherHead._renderPitch;
audioAttack = otherHead.audioAttack; _audioAttack = otherHead._audioAttack;
loudness = otherHead.loudness; _loudness = otherHead._loudness;
averageLoudness = otherHead.averageLoudness; _averageLoudness = otherHead._averageLoudness;
lastLoudness = otherHead.lastLoudness; _lastLoudness = otherHead._lastLoudness;
browAudioLift = otherHead.browAudioLift; _browAudioLift = otherHead._browAudioLift;
noise = otherHead.noise; _noise = otherHead._noise;
sphere = NULL; _sphere = NULL;
} }
Head::~Head() { Head::~Head() {
if (sphere != NULL) { if (_sphere != NULL) {
gluDeleteQuadric(sphere); gluDeleteQuadric(_sphere);
} }
} }
@ -206,7 +208,7 @@ Head* Head::clone() const {
void Head::reset() { void Head::reset() {
_headPitch = _headYaw = _headRoll = 0; _headPitch = _headYaw = _headRoll = 0;
leanForward = leanSideways = 0; _leanForward = _leanSideways = 0;
} }
@ -258,17 +260,17 @@ void Head::UpdateGyros(float frametime, SerialInterface * serialInterface, int h
void Head::addLean(float x, float z) { void Head::addLean(float x, float z) {
// Add Body lean as impulse // Add Body lean as impulse
leanSideways += x; _leanSideways += x;
leanForward += z; _leanForward += z;
} }
void Head::setLeanForward(float dist){ void Head::setLeanForward(float dist){
leanForward = dist; _leanForward = dist;
} }
void Head::setLeanSideways(float dist){ void Head::setLeanSideways(float dist){
leanSideways = dist; _leanSideways = dist;
} }
void Head::setTriggeringAction( bool d ) { void Head::setTriggeringAction( bool d ) {
@ -312,7 +314,7 @@ void Head::simulate(float deltaTime) {
// test other avs for proximity... // test other avs for proximity...
//------------------------------------- //-------------------------------------
glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position ); glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position );
v -= DEBUG_otherAvatarListPosition[o]; v -= _DEBUG_otherAvatarListPosition[o];
float distance = glm::length( v ); float distance = glm::length( v );
@ -369,34 +371,34 @@ void Head::simulate(float deltaTime) {
//------------------------------------------------- //-------------------------------------------------
_avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 ); _avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
if (driveKeys[FWD]) { if (_driveKeys[FWD]) {
glm::vec3 front( _avatar.orientation.getFront().x, _avatar.orientation.getFront().y, _avatar.orientation.getFront().z ); glm::vec3 front( _avatar.orientation.getFront().x, _avatar.orientation.getFront().y, _avatar.orientation.getFront().z );
_avatar.thrust += front * THRUST_MAG; _avatar.thrust += front * THRUST_MAG;
} }
if (driveKeys[BACK]) { if (_driveKeys[BACK]) {
glm::vec3 front( _avatar.orientation.getFront().x, _avatar.orientation.getFront().y, _avatar.orientation.getFront().z ); glm::vec3 front( _avatar.orientation.getFront().x, _avatar.orientation.getFront().y, _avatar.orientation.getFront().z );
_avatar.thrust -= front * THRUST_MAG; _avatar.thrust -= front * THRUST_MAG;
} }
if (driveKeys[RIGHT]) { if (_driveKeys[RIGHT]) {
glm::vec3 right( _avatar.orientation.getRight().x, _avatar.orientation.getRight().y, _avatar.orientation.getRight().z ); glm::vec3 right( _avatar.orientation.getRight().x, _avatar.orientation.getRight().y, _avatar.orientation.getRight().z );
_avatar.thrust -= right * THRUST_MAG; _avatar.thrust -= right * THRUST_MAG;
} }
if (driveKeys[LEFT]) { if (_driveKeys[LEFT]) {
glm::vec3 right( _avatar.orientation.getRight().x, _avatar.orientation.getRight().y, _avatar.orientation.getRight().z ); glm::vec3 right( _avatar.orientation.getRight().x, _avatar.orientation.getRight().y, _avatar.orientation.getRight().z );
_avatar.thrust += right * THRUST_MAG; _avatar.thrust += right * THRUST_MAG;
} }
if (driveKeys[UP]) { if (_driveKeys[UP]) {
glm::vec3 up( _avatar.orientation.getUp().x, _avatar.orientation.getUp().y, _avatar.orientation.getUp().z ); glm::vec3 up( _avatar.orientation.getUp().x, _avatar.orientation.getUp().y, _avatar.orientation.getUp().z );
_avatar.thrust += up * THRUST_MAG; _avatar.thrust += up * THRUST_MAG;
} }
if (driveKeys[DOWN]) { if (_driveKeys[DOWN]) {
glm::vec3 up( _avatar.orientation.getUp().x, _avatar.orientation.getUp().y, _avatar.orientation.getUp().z ); glm::vec3 up( _avatar.orientation.getUp().x, _avatar.orientation.getUp().y, _avatar.orientation.getUp().z );
_avatar.thrust -= up * THRUST_MAG; _avatar.thrust -= up * THRUST_MAG;
} }
if (driveKeys[ROT_RIGHT]) { if (_driveKeys[ROT_RIGHT]) {
_bodyYawDelta -= YAW_MAG * deltaTime; _bodyYawDelta -= YAW_MAG * deltaTime;
} }
if (driveKeys[ROT_LEFT]) { if (_driveKeys[ROT_LEFT]) {
_bodyYawDelta += YAW_MAG * deltaTime; _bodyYawDelta += YAW_MAG * deltaTime;
} }
} }
@ -448,7 +450,7 @@ void Head::simulate(float deltaTime) {
const float LIN_VEL_DECAY = 5.0; const float LIN_VEL_DECAY = 5.0;
_avatar.velocity *= ( 1.0 - LIN_VEL_DECAY * deltaTime ); _avatar.velocity *= ( 1.0 - LIN_VEL_DECAY * deltaTime );
if (!noise) { if (!_noise) {
// Decay back toward center // Decay back toward center
_headPitch *= (1.0f - DECAY*2*deltaTime); _headPitch *= (1.0f - DECAY*2*deltaTime);
_headYaw *= (1.0f - DECAY*2*deltaTime); _headYaw *= (1.0f - DECAY*2*deltaTime);
@ -456,24 +458,24 @@ void Head::simulate(float deltaTime) {
} }
else { else {
// Move toward new target // Move toward new target
_headPitch += (PitchTarget - _headPitch)*10*deltaTime; // (1.f - DECAY*deltaTime)*Pitch + ; _headPitch += (_pitchTarget - _headPitch)*10*deltaTime; // (1.f - DECAY*deltaTime)*Pitch + ;
_headYaw += (YawTarget - _headYaw)*10*deltaTime; // (1.f - DECAY*deltaTime); _headYaw += (_yawTarget - _headYaw)*10*deltaTime; // (1.f - DECAY*deltaTime);
_headRoll *= (1.f - DECAY*deltaTime); _headRoll *= (1.f - DECAY*deltaTime);
} }
leanForward *= (1.f - DECAY*30.f*deltaTime); _leanForward *= (1.f - DECAY*30.f*deltaTime);
leanSideways *= (1.f - DECAY*30.f*deltaTime); _leanSideways *= (1.f - DECAY*30.f*deltaTime);
// Update where the avatar's eyes are // Update where the avatar's eyes are
// //
// First, decide if we are making eye contact or not // First, decide if we are making eye contact or not
if (randFloat() < 0.005) { if (randFloat() < 0.005) {
eyeContact = !eyeContact; _eyeContact = !_eyeContact;
eyeContact = 1; _eyeContact = 1;
if (!eyeContact) { if (!_eyeContact) {
// If we just stopped making eye contact,move the eyes markedly away // If we just stopped making eye contact,move the eyes markedly away
EyeballPitch[0] = EyeballPitch[1] = EyeballPitch[0] + 5.0 + (randFloat() - 0.5)*10; _eyeballPitch[0] = _eyeballPitch[1] = _eyeballPitch[0] + 5.0 + (randFloat() - 0.5)*10;
EyeballYaw[0] = EyeballYaw[1] = EyeballYaw[0] + 5.0 + (randFloat()- 0.5)*5; _eyeballYaw[0] = _eyeballYaw[1] = _eyeballYaw[0] + 5.0 + (randFloat()- 0.5)*5;
} else { } else {
// If now making eye contact, turn head to look right at viewer // If now making eye contact, turn head to look right at viewer
SetNewHeadTarget(0,0); SetNewHeadTarget(0,0);
@ -483,56 +485,56 @@ void Head::simulate(float deltaTime) {
const float DEGREES_BETWEEN_VIEWER_EYES = 3; const float DEGREES_BETWEEN_VIEWER_EYES = 3;
const float DEGREES_TO_VIEWER_MOUTH = 7; const float DEGREES_TO_VIEWER_MOUTH = 7;
if (eyeContact) { if (_eyeContact) {
// Should we pick a new eye contact target? // Should we pick a new eye contact target?
if (randFloat() < 0.01) { if (randFloat() < 0.01) {
// Choose where to look next // Choose where to look next
if (randFloat() < 0.1) { if (randFloat() < 0.1) {
eyeContactTarget = MOUTH; _eyeContactTarget = MOUTH;
} else { } else {
if (randFloat() < 0.5) eyeContactTarget = LEFT_EYE; else eyeContactTarget = RIGHT_EYE; if (randFloat() < 0.5) _eyeContactTarget = LEFT_EYE; else _eyeContactTarget = RIGHT_EYE;
} }
} }
// Set eyeball pitch and yaw to make contact // Set eyeball pitch and yaw to make contact
float eye_target_yaw_adjust = 0; float eye_target_yaw_adjust = 0;
float eye_target_pitch_adjust = 0; float eye_target_pitch_adjust = 0;
if (eyeContactTarget == LEFT_EYE) eye_target_yaw_adjust = DEGREES_BETWEEN_VIEWER_EYES; if (_eyeContactTarget == LEFT_EYE) eye_target_yaw_adjust = DEGREES_BETWEEN_VIEWER_EYES;
if (eyeContactTarget == RIGHT_EYE) eye_target_yaw_adjust = -DEGREES_BETWEEN_VIEWER_EYES; if (_eyeContactTarget == RIGHT_EYE) eye_target_yaw_adjust = -DEGREES_BETWEEN_VIEWER_EYES;
if (eyeContactTarget == MOUTH) eye_target_pitch_adjust = DEGREES_TO_VIEWER_MOUTH; if (_eyeContactTarget == MOUTH) eye_target_pitch_adjust = DEGREES_TO_VIEWER_MOUTH;
EyeballPitch[0] = EyeballPitch[1] = -_headPitch + eye_target_pitch_adjust; _eyeballPitch[0] = _eyeballPitch[1] = -_headPitch + eye_target_pitch_adjust;
EyeballYaw[0] = EyeballYaw[1] = -_headYaw + eye_target_yaw_adjust; _eyeballYaw[0] = _eyeballYaw[1] = -_headYaw + eye_target_yaw_adjust;
} }
if (noise) if (_noise)
{ {
_headPitch += (randFloat() - 0.5)*0.2*NoiseEnvelope; _headPitch += (randFloat() - 0.5)*0.2*_noiseEnvelope;
_headYaw += (randFloat() - 0.5)*0.3*NoiseEnvelope; _headYaw += (randFloat() - 0.5)*0.3*_noiseEnvelope;
//PupilSize += (randFloat() - 0.5)*0.001*NoiseEnvelope; //PupilSize += (randFloat() - 0.5)*0.001*NoiseEnvelope;
if (randFloat() < 0.005) MouthWidth = MouthWidthChoices[rand()%3]; if (randFloat() < 0.005) _mouthWidth = MouthWidthChoices[rand()%3];
if (!eyeContact) { if (!_eyeContact) {
if (randFloat() < 0.01) EyeballPitch[0] = EyeballPitch[1] = (randFloat() - 0.5)*20; if (randFloat() < 0.01) _eyeballPitch[0] = _eyeballPitch[1] = (randFloat() - 0.5)*20;
if (randFloat() < 0.01) EyeballYaw[0] = EyeballYaw[1] = (randFloat()- 0.5)*10; if (randFloat() < 0.01) _eyeballYaw[0] = _eyeballYaw[1] = (randFloat()- 0.5)*10;
} }
if ((randFloat() < 0.005) && (fabs(PitchTarget - _headPitch) < 1.0) && (fabs(YawTarget - _headYaw) < 1.0)) { if ((randFloat() < 0.005) && (fabs(_pitchTarget - _headPitch) < 1.0) && (fabs(_yawTarget - _headYaw) < 1.0)) {
SetNewHeadTarget((randFloat()-0.5)*20.0, (randFloat()-0.5)*45.0); SetNewHeadTarget((randFloat()-0.5)*20.0, (randFloat()-0.5)*45.0);
} }
if (0) { if (0) {
// Pick new target // Pick new target
PitchTarget = (randFloat() - 0.5)*45; _pitchTarget = (randFloat() - 0.5)*45;
YawTarget = (randFloat() - 0.5)*22; _yawTarget = (randFloat() - 0.5)*22;
} }
if (randFloat() < 0.01) if (randFloat() < 0.01)
{ {
EyebrowPitch[0] = EyebrowPitch[1] = BrowPitchAngle[rand()%3]; _eyebrowPitch[0] = _eyebrowPitch[1] = BrowPitchAngle[rand()%3];
EyebrowRoll[0] = EyebrowRoll[1] = BrowRollAngle[rand()%5]; _eyebrowRoll[0] = _eyebrowRoll[1] = BrowRollAngle[rand()%5];
EyebrowRoll[1]*=-1; _eyebrowRoll[1]*=-1;
} }
} }
} }
@ -642,7 +644,7 @@ void Head::render(int faceToFace) {
//--------------------------------------------------- //---------------------------------------------------
for (int o=0; o<NUM_OTHER_AVATARS; o++) { for (int o=0; o<NUM_OTHER_AVATARS; o++) {
glPushMatrix(); glPushMatrix();
glTranslatef( DEBUG_otherAvatarListPosition[o].x, DEBUG_otherAvatarListPosition[o].y, DEBUG_otherAvatarListPosition[o].z ); glTranslatef( _DEBUG_otherAvatarListPosition[o].x, _DEBUG_otherAvatarListPosition[o].y, _DEBUG_otherAvatarListPosition[o].z );
glScalef( 0.03, 0.03, 0.03 ); glScalef( 0.03, 0.03, 0.03 );
glutSolidSphere( 1, 10, 10 ); glutSolidSphere( 1, 10, 10 );
glPopMatrix(); glPopMatrix();
@ -652,7 +654,7 @@ void Head::render(int faceToFace) {
if ( _closestOtherAvatar != -1 ) { if ( _closestOtherAvatar != -1 ) {
glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position ); glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
glm::vec3 v2( DEBUG_otherAvatarListPosition[ _closestOtherAvatar ] ); glm::vec3 v2( _DEBUG_otherAvatarListPosition[ _closestOtherAvatar ] );
glLineWidth( 5.0 ); glLineWidth( 5.0 );
glColor4f( 0.9f, 0.5f, 0.2f, 0.6 ); glColor4f( 0.9f, 0.5f, 0.2f, 0.6 );
@ -754,28 +756,28 @@ void Head::renderHead(int faceToFace) {
} }
glPopMatrix(); glPopMatrix();
// Eyebrows // _eyebrows
audioAttack = 0.9*audioAttack + 0.1*fabs(loudness - lastLoudness); _audioAttack = 0.9*_audioAttack + 0.1*fabs(_loudness - _lastLoudness);
lastLoudness = loudness; _lastLoudness = _loudness;
const float BROW_LIFT_THRESHOLD = 100; const float BROW_LIFT_THRESHOLD = 100;
if (audioAttack > BROW_LIFT_THRESHOLD) if (_audioAttack > BROW_LIFT_THRESHOLD)
browAudioLift += sqrt(audioAttack)/1000.0; _browAudioLift += sqrt(_audioAttack)/1000.0;
browAudioLift *= .90; _browAudioLift *= .90;
glPushMatrix(); glPushMatrix();
glTranslatef(-interBrowDistance/2.0,0.4,0.45); glTranslatef(-_interBrowDistance/2.0,0.4,0.45);
for(side = 0; side < 2; side++) { for(side = 0; side < 2; side++) {
glColor3fv(browColor); glColor3fv(browColor);
glPushMatrix(); glPushMatrix();
glTranslatef(0, 0.35 + browAudioLift, 0); glTranslatef(0, 0.35 + _browAudioLift, 0);
glRotatef(EyebrowPitch[side]/2.0, 1, 0, 0); glRotatef(_eyebrowPitch[side]/2.0, 1, 0, 0);
glRotatef(EyebrowRoll[side]/2.0, 0, 0, 1); glRotatef(_eyebrowRoll[side]/2.0, 0, 0, 1);
glScalef(browWidth, browThickness, 1); glScalef(browWidth, browThickness, 1);
glutSolidCube(0.5); glutSolidCube(0.5);
glPopMatrix(); glPopMatrix();
glTranslatef(interBrowDistance, 0, 0); glTranslatef(_interBrowDistance, 0, 0);
} }
glPopMatrix(); glPopMatrix();
@ -785,73 +787,73 @@ void Head::renderHead(int faceToFace) {
glPushMatrix(); glPushMatrix();
glTranslatef(0,-0.35,0.75); glTranslatef(0,-0.35,0.75);
glColor3f(0,0,0); glColor3f(0,0,0);
glRotatef(MouthPitch, 1, 0, 0); glRotatef(_mouthPitch, 1, 0, 0);
glRotatef(MouthYaw, 0, 0, 1); glRotatef(_mouthYaw, 0, 0, 1);
glScalef(MouthWidth*(.7 + sqrt(averageLoudness)/60.0), MouthHeight*(1.0 + sqrt(averageLoudness)/30.0), 1); glScalef(_mouthWidth*(.7 + sqrt(_averageLoudness)/60.0), _mouthHeight*(1.0 + sqrt(_averageLoudness)/30.0), 1);
glutSolidCube(0.5); glutSolidCube(0.5);
glPopMatrix(); glPopMatrix();
glTranslatef(0, 1.0, 0); glTranslatef(0, 1.0, 0);
glTranslatef(-interPupilDistance/2.0,-0.68,0.7); glTranslatef(-_interPupilDistance/2.0,-0.68,0.7);
// Right Eye // Right Eye
glRotatef(-10, 1, 0, 0); glRotatef(-10, 1, 0, 0);
glColor3fv(eyeColor); glColor3fv(eyeColor);
glPushMatrix(); glPushMatrix();
{ {
glTranslatef(interPupilDistance/10.0, 0, 0.05); glTranslatef(_interPupilDistance/10.0, 0, 0.05);
glRotatef(20, 0, 0, 1); glRotatef(20, 0, 0, 1);
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ); glScalef(_eyeballScaleX, _eyeballScaleY, _eyeballScaleZ);
glutSolidSphere(0.25, 30, 30); glutSolidSphere(0.25, 30, 30);
} }
glPopMatrix(); glPopMatrix();
// Right Pupil // Right Pupil
if (sphere == NULL) { if (_sphere == NULL) {
sphere = gluNewQuadric(); _sphere = gluNewQuadric();
gluQuadricTexture(sphere, GL_TRUE); gluQuadricTexture(_sphere, GL_TRUE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_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]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iris_texture_width, iris_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &iris_texture[0]);
} }
glPushMatrix(); glPushMatrix();
{ {
glRotatef(EyeballPitch[1], 1, 0, 0); glRotatef(_eyeballPitch[1], 1, 0, 0);
glRotatef(EyeballYaw[1] + PupilConverge, 0, 1, 0); glRotatef(_eyeballYaw[1] + _pupilConverge, 0, 1, 0);
glTranslatef(0,0,.35); glTranslatef(0,0,.35);
glRotatef(-75,1,0,0); glRotatef(-75,1,0,0);
glScalef(1.0, 0.4, 1.0); glScalef(1.0, 0.4, 1.0);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
gluSphere(sphere, PupilSize, 15, 15); gluSphere(_sphere, _pupilSize, 15, 15);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
} }
glPopMatrix(); glPopMatrix();
// Left Eye // Left Eye
glColor3fv(eyeColor); glColor3fv(eyeColor);
glTranslatef(interPupilDistance, 0, 0); glTranslatef(_interPupilDistance, 0, 0);
glPushMatrix(); glPushMatrix();
{ {
glTranslatef(-interPupilDistance/10.0, 0, .05); glTranslatef(-_interPupilDistance/10.0, 0, .05);
glRotatef(-20, 0, 0, 1); glRotatef(-20, 0, 0, 1);
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ); glScalef(_eyeballScaleX, _eyeballScaleY, _eyeballScaleZ);
glutSolidSphere(0.25, 30, 30); glutSolidSphere(0.25, 30, 30);
} }
glPopMatrix(); glPopMatrix();
// Left Pupil // Left Pupil
glPushMatrix(); glPushMatrix();
{ {
glRotatef(EyeballPitch[0], 1, 0, 0); glRotatef(_eyeballPitch[0], 1, 0, 0);
glRotatef(EyeballYaw[0] - PupilConverge, 0, 1, 0); glRotatef(_eyeballYaw[0] - _pupilConverge, 0, 1, 0);
glTranslatef(0, 0, .35); glTranslatef(0, 0, .35);
glRotatef(-75, 1, 0, 0); glRotatef(-75, 1, 0, 0);
glScalef(1.0, 0.4, 1.0); glScalef(1.0, 0.4, 1.0);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
gluSphere(sphere, PupilSize, 15, 15); gluSphere(_sphere, _pupilSize, 15, 15);
glDisable(GL_TEXTURE_2D); 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_SHIN ].parent = AVATAR_BONE_RIGHT_THIGH;
_bone[ AVATAR_BONE_RIGHT_FOOT ].parent = AVATAR_BONE_RIGHT_SHIN; _bone[ AVATAR_BONE_RIGHT_FOOT ].parent = AVATAR_BONE_RIGHT_SHIN;
//---------------------------------------------------------- //----------------------------------------------------------
// specify the default pose position // specify the default pose position
//---------------------------------------------------------- //----------------------------------------------------------
@ -1143,11 +1144,10 @@ void Head::updateHandMovement() {
transformedHandMovement += handShakePull; transformedHandMovement += handShakePull;
*/ */
_bone[ AVATAR_BONE_RIGHT_HAND ].position = DEBUG_otherAvatarListPosition[ _closestOtherAvatar ]; _bone[ AVATAR_BONE_RIGHT_HAND ].position = _DEBUG_otherAvatarListPosition[ _closestOtherAvatar ];
} }
} }
} }
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
// determine the arm vector // determine the arm vector
@ -1282,8 +1282,8 @@ void Head::renderBody() {
} }
void Head::SetNewHeadTarget(float pitch, float yaw) { void Head::SetNewHeadTarget(float pitch, float yaw) {
PitchTarget = pitch; _pitchTarget = pitch;
YawTarget = yaw; _yawTarget = yaw;
} }
// getting data from Android transmitte app // getting data from Android transmitte app
@ -1301,17 +1301,17 @@ void Head::processTransmitterData(unsigned char* packetData, int numBytes) {
&linX, &linY, &linZ, &linX, &linY, &linZ,
&rot1, &rot2, &rot3, &rot4); &rot1, &rot2, &rot3, &rot4);
if (transmitterPackets++ == 0) { if (_transmitterPackets++ == 0) {
gettimeofday(&transmitterTimer, NULL); gettimeofday(&_transmitterTimer, NULL);
} }
const int TRANSMITTER_COUNT = 100; 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 // Every 100 packets, record the observed Hz of the transmitter data
timeval now; timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
double msecsElapsed = diffclock(&transmitterTimer, &now); double msecsElapsed = diffclock(&_transmitterTimer, &now);
transmitterHz = static_cast<float>( (double)TRANSMITTER_COUNT/(msecsElapsed/1000.0) ); _transmitterHz = static_cast<float>( (double)TRANSMITTER_COUNT/(msecsElapsed/1000.0) );
transmitterTimer = now; _transmitterTimer = now;
} }
/* NOTE: PR: Will add back in when ready to animate avatar hand /* NOTE: PR: Will add back in when ready to animate avatar hand

View file

@ -108,15 +108,15 @@ class Head : public AvatarData {
void reset(); void reset();
void UpdateGyros(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity); 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 setPitch(float p) {_headPitch = p; }
void setYaw(float y) {_headYaw = y; } void setYaw(float y) {_headYaw = y; }
void setRoll(float r) {_headRoll = r; }; void setRoll(float r) {_headRoll = r; };
void setScale(float s) {scale = s; }; void setScale(float s) {_scale = s; };
void setRenderYaw(float y) {renderYaw = y;} void setRenderYaw(float y) {_renderYaw = y;}
void setRenderPitch(float p) {renderPitch = p;} void setRenderPitch(float p) {_renderPitch = p;}
float getRenderYaw() {return renderYaw;} float getRenderYaw() {return _renderYaw;}
float getRenderPitch() {return renderPitch;} float getRenderPitch() {return _renderPitch;}
void setLeanForward(float dist); void setLeanForward(float dist);
void setLeanSideways(float dist); void setLeanSideways(float dist);
void addPitch(float p) {_headPitch -= p; } void addPitch(float p) {_headPitch -= p; }
@ -152,16 +152,16 @@ class Head : public AvatarData {
void setHandMovement( glm::vec3 movement ); void setHandMovement( glm::vec3 movement );
void updateHandMovement(); void updateHandMovement();
float getLoudness() {return loudness;}; float getLoudness() {return _loudness;};
float getAverageLoudness() {return averageLoudness;}; float getAverageLoudness() {return _averageLoudness;};
void setAverageLoudness(float al) {averageLoudness = al;}; void setAverageLoudness(float al) {_averageLoudness = al;};
void setLoudness(float l) {loudness = l;}; void setLoudness(float l) {_loudness = l;};
void SetNewHeadTarget(float, float); void SetNewHeadTarget(float, float);
// Set what driving keys are being pressed to control thrust levels // Set what driving keys are being pressed to control thrust levels
void setDriveKeys(int key, bool val) { driveKeys[key] = val; }; void setDriveKeys(int key, bool val) { _driveKeys[key] = val; };
bool getDriveKeys(int key) { return driveKeys[key]; }; bool getDriveKeys(int key) { return _driveKeys[key]; };
// Set/Get update the thrust that will move the avatar around // Set/Get update the thrust that will move the avatar around
void setThrust(glm::vec3 newThrust) { _avatar.thrust = newThrust; }; void setThrust(glm::vec3 newThrust) { _avatar.thrust = newThrust; };
@ -173,51 +173,48 @@ class Head : public AvatarData {
// //
void processTransmitterData(unsigned char * packetData, int numBytes); void processTransmitterData(unsigned char * packetData, int numBytes);
float getTransmitterHz() { return transmitterHz; }; float getTransmitterHz() { return _transmitterHz; };
private: private:
bool _isMine; bool _isMine;
float noise; float _noise;
float _headPitch; float _headPitch;
float _headYaw; float _headYaw;
float _headRoll; float _headRoll;
float _headPitchRate; float _headPitchRate;
float _headYawRate; float _headYawRate;
float _headRollRate; float _headRollRate;
float EyeballPitch[2]; float _eyeballPitch[2];
float EyeballYaw[2]; float _eyeballYaw[2];
float EyebrowPitch[2]; float _eyebrowPitch[2];
float EyebrowRoll[2]; float _eyebrowRoll[2];
float EyeballScaleX, EyeballScaleY, EyeballScaleZ; float _eyeballScaleX, _eyeballScaleY, _eyeballScaleZ;
float interPupilDistance; float _interPupilDistance;
float interBrowDistance; float _interBrowDistance;
float NominalPupilSize; float _nominalPupilSize;
float PupilSize; float _pupilSize;
float MouthPitch; float _mouthPitch;
float MouthYaw; float _mouthYaw;
float MouthWidth; float _mouthWidth;
float MouthHeight; float _mouthHeight;
float leanForward; float _leanForward;
float leanSideways; float _leanSideways;
float PitchTarget; float _pitchTarget;
float YawTarget; float _yawTarget;
float NoiseEnvelope; float _noiseEnvelope;
float PupilConverge; float _pupilConverge;
float scale; float _scale;
// Sound loudness information // Sound loudness information
float loudness, lastLoudness; float _loudness, _lastLoudness;
float averageLoudness; float _averageLoudness;
float audioAttack; float _audioAttack;
float browAudioLift; float _browAudioLift;
glm::vec3 _TEST_bigSpherePosition; glm::vec3 _TEST_bigSpherePosition;
float _TEST_bigSphereRadius; float _TEST_bigSphereRadius;
glm::vec3 _DEBUG_otherAvatarListPosition[ NUM_OTHER_AVATARS ];
//temporary - placeholder for real other avs float _DEBUG_otherAvatarListTimer [ NUM_OTHER_AVATARS ];
glm::vec3 DEBUG_otherAvatarListPosition [ NUM_OTHER_AVATARS ];
float DEBUG_otherAvatarListTimer [ NUM_OTHER_AVATARS ];
bool _triggeringAction; bool _triggeringAction;
float _bodyYawDelta; float _bodyYawDelta;
float _closeEnoughToInteract; float _closeEnoughToInteract;
@ -232,23 +229,21 @@ class Head : public AvatarData {
AvatarBone _bone[ NUM_AVATAR_BONES ]; AvatarBone _bone[ NUM_AVATAR_BONES ];
AvatarMode _mode; AvatarMode _mode;
Avatar _avatar; Avatar _avatar;
int _driveKeys[MAX_DRIVE_KEYS];
int _eyeContact;
eyeContactTargets _eyeContactTarget;
int driveKeys[MAX_DRIVE_KEYS]; GLUquadric *_sphere;
int eyeContact;
eyeContactTargets eyeContactTarget;
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 // Related to getting transmitter UDP data used to animate the avatar hand
// //
timeval transmitterTimer; timeval _transmitterTimer;
float transmitterHz; float _transmitterHz;
int transmitterPackets; int _transmitterPackets;
//----------------------------- //-----------------------------
// private methods... // private methods...

View file

@ -20,6 +20,8 @@ using avatars_lib::printLog;
// //
// tosh - yep, I noticed... :-) // tosh - yep, I noticed... :-)
// //
// JJV - I noticed too :-)
//
static bool testingForNormalizationAndOrthogonality = false; static bool testingForNormalizationAndOrthogonality = false;
Orientation::Orientation() { Orientation::Orientation() {