Merge branch 'master' of github.com:worklist/hifi

This commit is contained in:
Stephen Birarda 2013-03-19 15:58:19 -07:00
commit f8f098cf2c
4 changed files with 75 additions and 71 deletions

View file

@ -71,6 +71,8 @@ target_link_libraries(interface
${LODEPNG_LIBRARY} ${LODEPNG_LIBRARY}
) )
if (WIN32)
else (WIN32)
# include PortAudio as external project # include PortAudio as external project
include(ExternalProject) include(ExternalProject)
set(PORTAUDIO_PROJ_DIR external/portaudio) set(PORTAUDIO_PROJ_DIR external/portaudio)
@ -94,6 +96,8 @@ include_directories(${source_dir}/include)
ExternalProject_Get_Property(portaudio binary_dir) ExternalProject_Get_Property(portaudio binary_dir)
target_link_libraries(interface ${binary_dir}/lib/.libs/libportaudio.a) target_link_libraries(interface ${binary_dir}/lib/.libs/libportaudio.a)
endif (WIN32)
# link required libraries on UNIX # link required libraries on UNIX
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)

View file

@ -16,20 +16,20 @@
using namespace std; using namespace std;
float skinColor[] = {1.0, 0.84, 0.66}; float skinColor[] = {1.0f, 0.84f, 0.66f};
float browColor[] = {210.0/255.0, 105.0/255.0, 30.0/255.0}; float browColor[] = {210.0f/255.0f, 105.0f/255.0f, 30.0f/255.0f};
float mouthColor[] = {1, 0, 0}; float mouthColor[] = {1, 0, 0};
float BrowRollAngle[5] = {0, 15, 30, -30, -15}; float BrowRollAngle[5] = {0, 15, 30, -30, -15};
float BrowPitchAngle[3] = {-70, -60, -50}; float BrowPitchAngle[3] = {-70, -60, -50};
float eyeColor[3] = {1,1,1}; float eyeColor[3] = {1,1,1};
float MouthWidthChoices[3] = {0.5, 0.77, 0.3}; float MouthWidthChoices[3] = {0.5f, 0.77f, 0.3f};
float browWidth = 0.8; float browWidth = 0.8f;
float browThickness = 0.16; float browThickness = 0.16f;
const float DECAY = 0.1; const float DECAY = 0.1f;
char iris_texture_file[] = "interface.app/Contents/Resources/images/green_eye.png"; char iris_texture_file[] = "interface.app/Contents/Resources/images/green_eye.png";
@ -42,20 +42,20 @@ GLUquadric *sphere = gluNewQuadric();
Head::Head() Head::Head()
{ {
position.x = position.y = position.z = 0; position.x = position.y = position.z = 0;
PupilSize = 0.10; PupilSize = 0.10f;
interPupilDistance = 0.6; interPupilDistance = 0.6f;
interBrowDistance = 0.75; interBrowDistance = 0.75f;
NominalPupilSize = 0.10; NominalPupilSize = 0.10f;
Yaw = 0.0; Yaw = 0.0f;
EyebrowPitch[0] = EyebrowPitch[1] = -30; EyebrowPitch[0] = EyebrowPitch[1] = -30;
EyebrowRoll[0] = 20; EyebrowRoll[0] = 20;
EyebrowRoll[1] = -20; EyebrowRoll[1] = -20;
MouthPitch = 0; MouthPitch = 0;
MouthYaw = 0; MouthYaw = 0;
MouthWidth = 1.0; MouthWidth = 1.0;
MouthHeight = 0.2; MouthHeight = 0.2f;
EyeballPitch[0] = EyeballPitch[1] = 0; EyeballPitch[0] = EyeballPitch[1] = 0;
EyeballScaleX = 1.2; EyeballScaleY = 1.5; EyeballScaleZ = 1.0; EyeballScaleX = 1.2f; EyeballScaleY = 1.5f; EyeballScaleZ = 1.0f;
EyeballYaw[0] = EyeballYaw[1] = 0; EyeballYaw[0] = EyeballYaw[1] = 0;
PitchTarget = YawTarget = 0; PitchTarget = YawTarget = 0;
NoiseEnvelope = 1.0; NoiseEnvelope = 1.0;
@ -150,13 +150,13 @@ void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int hea
const float PITCH_ACCEL_COUPLING = 0.5; const float PITCH_ACCEL_COUPLING = 0.5;
const float ROLL_ACCEL_COUPLING = -1.0; const float ROLL_ACCEL_COUPLING = -1.0;
float measured_pitch_rate = serialInterface->getRelativeValue(PITCH_RATE); float measured_pitch_rate = static_cast<float>(serialInterface->getRelativeValue(PITCH_RATE));
YawRate = serialInterface->getRelativeValue(YAW_RATE); YawRate = static_cast<float>(serialInterface->getRelativeValue(YAW_RATE));
float measured_lateral_accel = serialInterface->getRelativeValue(ACCEL_X) - float measured_lateral_accel = serialInterface->getRelativeValue(ACCEL_X) -
ROLL_ACCEL_COUPLING*serialInterface->getRelativeValue(ROLL_RATE); ROLL_ACCEL_COUPLING*serialInterface->getRelativeValue(ROLL_RATE);
float measured_fwd_accel = serialInterface->getRelativeValue(ACCEL_Z) - float measured_fwd_accel = serialInterface->getRelativeValue(ACCEL_Z) -
PITCH_ACCEL_COUPLING*serialInterface->getRelativeValue(PITCH_RATE); PITCH_ACCEL_COUPLING*serialInterface->getRelativeValue(PITCH_RATE);
float measured_roll_rate = serialInterface->getRelativeValue(ROLL_RATE); float measured_roll_rate = static_cast<float>(serialInterface->getRelativeValue(ROLL_RATE));
//std::cout << "Pitch Rate: " << serialInterface->getRelativeValue(PITCH_RATE) << //std::cout << "Pitch Rate: " << serialInterface->getRelativeValue(PITCH_RATE) <<
// " fwd_accel: " << serialInterface->getRelativeValue(ACCEL_Z) << "\n"; // " fwd_accel: " << serialInterface->getRelativeValue(ACCEL_Z) << "\n";
@ -165,9 +165,9 @@ void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int hea
//std::cout << "Pitch: " << Pitch << "\n"; //std::cout << "Pitch: " << Pitch << "\n";
// Update avatar head position based on measured gyro rates // Update avatar head position based on measured gyro rates
const float HEAD_ROTATION_SCALE = 0.70; const float HEAD_ROTATION_SCALE = 0.70f;
const float HEAD_ROLL_SCALE = 0.40; const float HEAD_ROLL_SCALE = 0.40f;
const float HEAD_LEAN_SCALE = 0.01; const float HEAD_LEAN_SCALE = 0.01f;
const float MAX_PITCH = 45; const float MAX_PITCH = 45;
const float MIN_PITCH = -45; const float MIN_PITCH = -45;
const float MAX_YAW = 85; const float MAX_YAW = 85;
@ -230,8 +230,8 @@ void Head::simulate(float deltaTime)
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.0f + (randFloat() - 0.5f)*10.0f;
EyeballYaw[0] = EyeballYaw[1] = EyeballYaw[0] + 5.0 + (randFloat()- 0.5)*5; EyeballYaw[0] = EyeballYaw[1] = EyeballYaw[0] + 5.0f + (randFloat()- 0.5f)*5.0f;
} 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);
@ -256,15 +256,15 @@ void Head::simulate(float deltaTime)
if (noise) if (noise)
{ {
Pitch += (randFloat() - 0.5)*0.2*NoiseEnvelope; Pitch += (randFloat() - 0.5f)*0.2f*NoiseEnvelope;
Yaw += (randFloat() - 0.5)*0.3*NoiseEnvelope; Yaw += (randFloat() - 0.5f)*0.3f*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.01f) EyeballPitch[0] = EyeballPitch[1] = (randFloat() - 0.5f)*20.0f;
if (randFloat() < 0.01) EyeballYaw[0] = EyeballYaw[1] = (randFloat()- 0.5)*10; if (randFloat() < 0.01f) EyeballYaw[0] = EyeballYaw[1] = (randFloat()- 0.5f)*10.0f;
} else { } else {
float eye_target_yaw_adjust = 0; float eye_target_yaw_adjust = 0;
float eye_target_pitch_adjust = 0; float eye_target_pitch_adjust = 0;
@ -280,17 +280,17 @@ void Head::simulate(float deltaTime)
if ((randFloat() < 0.005) && (fabs(PitchTarget - Pitch) < 1.0) && (fabs(YawTarget - Yaw) < 1.0)) if ((randFloat() < 0.005) && (fabs(PitchTarget - Pitch) < 1.0) && (fabs(YawTarget - Yaw) < 1.0))
{ {
SetNewHeadTarget((randFloat()-0.5)*20.0, (randFloat()-0.5)*45.0); SetNewHeadTarget((randFloat()-0.5f)*20.0f, (randFloat()-0.5f)*45.0f);
} }
if (0) if (0)
{ {
// Pick new target // Pick new target
PitchTarget = (randFloat() - 0.5)*45; PitchTarget = (randFloat() - 0.5f)*45.0f;
YawTarget = (randFloat() - 0.5)*22; YawTarget = (randFloat() - 0.5f)*22.0f;
} }
if (randFloat() < 0.01) if (randFloat() < 0.01f)
{ {
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];
@ -345,35 +345,35 @@ void Head::render(int faceToFace, int isMine, float * myLocation)
for(side = 0; side < 2; side++) for(side = 0; side < 2; side++)
{ {
glPushMatrix(); glPushMatrix();
glScalef(0.3, 0.65, .65); glScalef(0.3f, 0.65f, .65f);
glutSolidSphere(0.5, 30, 30); glutSolidSphere(0.5f, 30, 30);
glPopMatrix(); glPopMatrix();
glTranslatef(-2.0, 0, 0); glTranslatef(-2.0f, 0, 0);
} }
glPopMatrix(); glPopMatrix();
// Eyebrows // Eyebrows
audioAttack = 0.9*audioAttack + 0.1*fabs(loudness - lastLoudness); audioAttack = 0.9f*audioAttack + 0.1f*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.0f;
browAudioLift *= .90; browAudioLift *= .90f;
glPushMatrix(); glPushMatrix();
glTranslatef(-interBrowDistance/2.0,0.4,0.45); glTranslatef(-interBrowDistance/2.0f,0.4f,0.45f);
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.35f + browAudioLift, 0);
glRotatef(EyebrowPitch[side]/2.0, 1, 0, 0); glRotatef(EyebrowPitch[side]/2.0f, 1, 0, 0);
glRotatef(EyebrowRoll[side]/2.0, 0, 0, 1); glRotatef(EyebrowRoll[side]/2.0f, 0, 0, 1);
glScalef(browWidth, browThickness, 1); glScalef(browWidth, browThickness, 1);
glutSolidCube(0.5); glutSolidCube(0.5f);
glPopMatrix(); glPopMatrix();
glTranslatef(interBrowDistance, 0, 0); glTranslatef(interBrowDistance, 0, 0);
} }
@ -383,23 +383,23 @@ void Head::render(int faceToFace, int isMine, float * myLocation)
// Mouth // Mouth
glPushMatrix(); glPushMatrix();
glTranslatef(0,-0.35,0.75); glTranslatef(0,-0.35f,0.75f);
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*(.7f + sqrt(averageLoudness)/60.0f), MouthHeight*(1.0f + sqrt(averageLoudness)/30.0f), 1);
glutSolidCube(0.5); glutSolidCube(0.5f);
glPopMatrix(); glPopMatrix();
glTranslatef(0, 1.0, 0); glTranslatef(0, 1.0, 0);
glTranslatef(-interPupilDistance/2.0,-0.68,0.7); glTranslatef(-interPupilDistance/2.0f,-0.68f,0.7f);
// 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.0f, 0, 0.05f);
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);
@ -420,9 +420,9 @@ void Head::render(int faceToFace, int isMine, float * myLocation)
{ {
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,.35f);
glRotatef(-75,1,0,0); glRotatef(-75,1,0,0);
glScalef(1.0, 0.4, 1.0); glScalef(1.0f, 0.4f, 1.0f);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
gluSphere(sphere, PupilSize, 15, 15); gluSphere(sphere, PupilSize, 15, 15);
@ -435,7 +435,7 @@ void Head::render(int faceToFace, int isMine, float * myLocation)
glTranslatef(interPupilDistance, 0, 0); glTranslatef(interPupilDistance, 0, 0);
glPushMatrix(); glPushMatrix();
{ {
glTranslatef(-interPupilDistance/10.0, 0, .05); glTranslatef(-interPupilDistance/10.0f, 0, .05f);
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);
@ -446,9 +446,9 @@ void Head::render(int faceToFace, int isMine, float * myLocation)
{ {
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, .35f);
glRotatef(-75, 1, 0, 0); glRotatef(-75, 1, 0, 0);
glScalef(1.0, 0.4, 1.0); glScalef(1.0f, 0.4f, 1.0f);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
gluSphere(sphere, PupilSize, 15, 15); gluSphere(sphere, PupilSize, 15, 15);

View file

@ -40,7 +40,7 @@ public:
int getLED() {return LED;}; int getLED() {return LED;};
int getNumSamples() {return samplesAveraged;}; int getNumSamples() {return samplesAveraged;};
int getValue(int num) {return lastMeasured[num];}; int getValue(int num) {return lastMeasured[num];};
int getRelativeValue(int num) {return lastMeasured[num] - trailingAverage[num];}; int getRelativeValue(int num) {return static_cast<int>(lastMeasured[num] - trailingAverage[num]);};
float getTrailingValue(int num) {return trailingAverage[num];}; float getTrailingValue(int num) {return trailingAverage[num];};
void resetTrailingAverages(); void resetTrailingAverages();
void renderLevels(int width, int height); void renderLevels(int width, int height);

View file

@ -38,7 +38,7 @@ int bytesRequiredForCodeLength(unsigned char threeBitCodes) {
if (threeBitCodes == 0) { if (threeBitCodes == 0) {
return 1; return 1;
} else { } else {
return 1 + (int)ceilf((threeBitCodes * 3) / 8.0); return 1 + (int)ceilf((threeBitCodes * 3) / 8.0f);
} }
} }