mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Merge pull request #132 from PhilipRosedale/master
Fixed mouth/eyebrow movements of other avatars
This commit is contained in:
commit
7c69b85bc5
5 changed files with 43 additions and 43 deletions
|
@ -130,7 +130,7 @@ int audioCallback (const void *inputBuffer,
|
||||||
|
|
||||||
loudness /= BUFFER_LENGTH_SAMPLES;
|
loudness /= BUFFER_LENGTH_SAMPLES;
|
||||||
data->lastInputLoudness = loudness;
|
data->lastInputLoudness = loudness;
|
||||||
data->averagedInputLoudness = 0.66*data->averagedInputLoudness + 0.33*loudness;
|
|
||||||
//
|
//
|
||||||
// If scope is turned on, copy input buffer to scope
|
// If scope is turned on, copy input buffer to scope
|
||||||
//
|
//
|
||||||
|
@ -510,9 +510,8 @@ error:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Audio::getInputLoudness(float * lastLoudness, float * averageLoudness) {
|
float Audio::getInputLoudness() const {
|
||||||
*lastLoudness = audioData->lastInputLoudness;
|
return audioData->lastInputLoudness;
|
||||||
*averageLoudness = audioData->averagedInputLoudness;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::render(int screenWidth, int screenHeight)
|
void Audio::render(int screenWidth, int screenHeight)
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
bool getMixerLoopbackFlag();
|
bool getMixerLoopbackFlag();
|
||||||
void setMixerLoopbackFlag(bool newMixerLoopbackFlag);
|
void setMixerLoopbackFlag(bool newMixerLoopbackFlag);
|
||||||
|
|
||||||
void getInputLoudness(float * lastLoudness, float * averageLoudness);
|
float getInputLoudness() const;
|
||||||
void updateMixerParams(in_addr_t mixerAddress, in_port_t mixerPort);
|
void updateMixerParams(in_addr_t mixerAddress, in_port_t mixerPort);
|
||||||
|
|
||||||
void setWalkingState(bool newWalkState);
|
void setWalkingState(bool newWalkState);
|
||||||
|
|
|
@ -36,7 +36,6 @@ class AudioData {
|
||||||
int wasStarved;
|
int wasStarved;
|
||||||
|
|
||||||
float lastInputLoudness;
|
float lastInputLoudness;
|
||||||
float averagedInputLoudness;
|
|
||||||
|
|
||||||
bool mixerLoopbackFlag;
|
bool mixerLoopbackFlag;
|
||||||
bool playWalkSound;
|
bool playWalkSound;
|
||||||
|
|
|
@ -566,6 +566,11 @@ void Head::simulate(float deltaTime) {
|
||||||
_head.eyebrowRoll [1] *=-1;
|
_head.eyebrowRoll [1] *=-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update audio trailing average for rendering facial animations
|
||||||
|
const float AUDIO_AVERAGING_SECS = 0.05;
|
||||||
|
_head.averageLoudness = (1.f - deltaTime / AUDIO_AVERAGING_SECS) * _head.averageLoudness +
|
||||||
|
(deltaTime / AUDIO_AVERAGING_SECS) * _audioLoudness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -740,16 +745,20 @@ void Head::renderHead(bool lookingInMirror) {
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
// _eyebrows
|
|
||||||
_head.audioAttack = 0.9 * _head.audioAttack + 0.1 * fabs(_audioLoudness - _head.lastLoudness);
|
// Update audio attack data for facial animation (eyebrows and mouth)
|
||||||
|
_head.audioAttack = 0.9 * _head.audioAttack + 0.1 * fabs(_audioLoudness - _head.lastLoudness);
|
||||||
_head.lastLoudness = _audioLoudness;
|
_head.lastLoudness = _audioLoudness;
|
||||||
|
|
||||||
|
|
||||||
const float BROW_LIFT_THRESHOLD = 100;
|
const float BROW_LIFT_THRESHOLD = 100;
|
||||||
if (_head.audioAttack > BROW_LIFT_THRESHOLD)
|
if (_head.audioAttack > BROW_LIFT_THRESHOLD)
|
||||||
_head.browAudioLift += sqrt(_head.audioAttack) / 1000.0;
|
_head.browAudioLift += sqrt(_head.audioAttack) / 1000.0;
|
||||||
|
|
||||||
_head.browAudioLift *= .90;
|
_head.browAudioLift *= .90;
|
||||||
|
|
||||||
|
|
||||||
|
// Render Eyebrows
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(-_head.interBrowDistance / 2.0,0.4,0.45);
|
glTranslatef(-_head.interBrowDistance / 2.0,0.4,0.45);
|
||||||
for(side = 0; side < 2; side++) {
|
for(side = 0; side < 2; side++) {
|
||||||
|
|
|
@ -160,8 +160,10 @@ bool perfStatsOn = false; // Do we want to display perfStats?
|
||||||
int noiseOn = 0; // Whether to add random noise
|
int noiseOn = 0; // Whether to add random noise
|
||||||
float noise = 1.0; // Overall magnitude scaling for random noise levels
|
float noise = 1.0; // Overall magnitude scaling for random noise levels
|
||||||
|
|
||||||
|
bool gyroLook = false; // Whether to allow the gyro data from head to move your view
|
||||||
|
|
||||||
int displayLevels = 0;
|
int displayLevels = 0;
|
||||||
bool lookingInMirror = 0; // Are we currently rendering one's own head as if in mirror?
|
bool lookingInMirror = 0; // Are we currently rendering one's own head as if in mirror?
|
||||||
int displayField = 0;
|
int displayField = 0;
|
||||||
|
|
||||||
int displayHeadMouse = 1; // Display sample mouse pointer controlled by head movement
|
int displayHeadMouse = 1; // Display sample mouse pointer controlled by head movement
|
||||||
|
@ -476,31 +478,16 @@ void updateAvatar(float frametime)
|
||||||
headMouseY = min(headMouseY, HEIGHT);
|
headMouseY = min(headMouseY, HEIGHT);
|
||||||
|
|
||||||
// Update render direction (pitch/yaw) based on measured gyro rates
|
// Update render direction (pitch/yaw) based on measured gyro rates
|
||||||
const int MIN_YAW_RATE = 100;
|
const float MIN_YAW_RATE = 5;
|
||||||
const int MIN_PITCH_RATE = 100;
|
const float YAW_SENSITIVITY = 1.0;
|
||||||
const float YAW_SENSITIVITY = 0.02;
|
|
||||||
const float PITCH_SENSITIVITY = 0.05;
|
|
||||||
|
|
||||||
// Update render pitch and yaw rates based on keyPositions
|
// If enabled, Update render pitch and yaw based on gyro data
|
||||||
const float KEY_YAW_SENSITIVITY = 2.0;
|
if (::gyroLook) {
|
||||||
if (myAvatar.getDriveKeys(ROT_LEFT)) renderYawRate -= KEY_YAW_SENSITIVITY*frametime;
|
if (fabs(gyroYawRate) > MIN_YAW_RATE) {
|
||||||
if (myAvatar.getDriveKeys(ROT_RIGHT)) renderYawRate += KEY_YAW_SENSITIVITY*frametime;
|
myAvatar.addBodyYaw(-gyroYawRate * YAW_SENSITIVITY * frametime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fabs(gyroYawRate) > MIN_YAW_RATE)
|
|
||||||
{
|
|
||||||
if (gyroYawRate > 0)
|
|
||||||
renderYawRate += (gyroYawRate - MIN_YAW_RATE) * YAW_SENSITIVITY * frametime;
|
|
||||||
else
|
|
||||||
renderYawRate += (gyroYawRate + MIN_YAW_RATE) * YAW_SENSITIVITY * frametime;
|
|
||||||
}
|
|
||||||
if (fabs(gyroPitchRate) > MIN_PITCH_RATE)
|
|
||||||
{
|
|
||||||
if (gyroPitchRate > 0)
|
|
||||||
renderPitchRate += (gyroPitchRate - MIN_PITCH_RATE) * PITCH_SENSITIVITY * frametime;
|
|
||||||
else
|
|
||||||
renderPitchRate += (gyroPitchRate + MIN_PITCH_RATE) * PITCH_SENSITIVITY * frametime;
|
|
||||||
}
|
|
||||||
|
|
||||||
float renderPitch = myAvatar.getRenderPitch();
|
float renderPitch = myAvatar.getRenderPitch();
|
||||||
// Decay renderPitch toward zero because we never look constantly up/down
|
// Decay renderPitch toward zero because we never look constantly up/down
|
||||||
renderPitch *= (1.f - 2.0*frametime);
|
renderPitch *= (1.f - 2.0*frametime);
|
||||||
|
@ -514,11 +501,8 @@ void updateAvatar(float frametime)
|
||||||
myAvatar.setRenderPitch(renderPitch + renderPitchRate);
|
myAvatar.setRenderPitch(renderPitch + renderPitchRate);
|
||||||
|
|
||||||
// Get audio loudness data from audio input device
|
// Get audio loudness data from audio input device
|
||||||
float loudness, averageLoudness;
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
audio.getInputLoudness(&loudness, &averageLoudness);
|
myAvatar.setLoudness(audio.getInputLoudness());
|
||||||
myAvatar.setLoudness(loudness);
|
|
||||||
myAvatar.setAverageLoudness(averageLoudness);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Update Avatar with latest camera and view frustum data...
|
// Update Avatar with latest camera and view frustum data...
|
||||||
|
@ -1072,6 +1056,11 @@ int setNoise(int state) {
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setGyroLook(int state) {
|
||||||
|
int iRet = setValue(state, &::gyroLook);
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
|
|
||||||
int setVoxels(int state) {
|
int setVoxels(int state) {
|
||||||
return setValue(state, &::showingVoxels);
|
return setValue(state, &::showingVoxels);
|
||||||
}
|
}
|
||||||
|
@ -1190,16 +1179,20 @@ const char* getFrustumRenderModeName(int state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initMenu() {
|
void initMenu() {
|
||||||
MenuColumn *menuColumnOptions, *menuColumnTools, *menuColumnDebug, *menuColumnFrustum;
|
MenuColumn *menuColumnOptions, *menuColumnRender, *menuColumnTools, *menuColumnDebug, *menuColumnFrustum;
|
||||||
// Options
|
// Options
|
||||||
menuColumnOptions = menu.addColumn("Options");
|
menuColumnOptions = menu.addColumn("Options");
|
||||||
menuColumnOptions->addRow("Mirror (h)", setHead);
|
menuColumnOptions->addRow("Mirror (h)", setHead);
|
||||||
menuColumnOptions->addRow("Field (f)", setField);
|
menuColumnOptions->addRow("Noise (n)", setNoise);
|
||||||
menuColumnOptions->addRow("(N)oise", setNoise);
|
menuColumnOptions->addRow("Gyro Look", setGyroLook);
|
||||||
menuColumnOptions->addRow("(V)oxels", setVoxels);
|
menuColumnOptions->addRow("Quit (q)", quitApp);
|
||||||
menuColumnOptions->addRow("Stars (*)", setStars);
|
|
||||||
menuColumnOptions->addRow("(Q)uit", quitApp);
|
|
||||||
|
|
||||||
|
// Render
|
||||||
|
menuColumnRender = menu.addColumn("Render");
|
||||||
|
menuColumnRender->addRow("Voxels (V)", setVoxels);
|
||||||
|
menuColumnRender->addRow("Stars (*)", setStars);
|
||||||
|
menuColumnRender->addRow("Field (f)", setField);
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
menuColumnTools = menu.addColumn("Tools");
|
menuColumnTools = menu.addColumn("Tools");
|
||||||
menuColumnTools->addRow("Stats (/)", setStats);
|
menuColumnTools->addRow("Stats (/)", setStats);
|
||||||
|
|
Loading…
Reference in a new issue