mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 09:23:17 +02:00
Merge pull request #95 from Ventrella/master
housecleaning, and tidying of the avatar members, including making a head structure. Also, fixed avatar eyeball rotation bug
This commit is contained in:
commit
51aafc3400
2 changed files with 293 additions and 254 deletions
|
@ -48,8 +48,8 @@ unsigned int iris_texture_height = 256;
|
|||
Head::Head(bool isMine) {
|
||||
|
||||
_orientation.setToIdentity();
|
||||
_velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
_closestOtherAvatar = 0;
|
||||
_bodyYaw = -90.0;
|
||||
|
@ -59,6 +59,10 @@ Head::Head(bool isMine) {
|
|||
_triggeringAction = false;
|
||||
_mode = AVATAR_MODE_STANDING;
|
||||
_isMine = isMine;
|
||||
_maxArmLength = 0.0;
|
||||
//_transmitterTimer = 0;
|
||||
_transmitterHz = 0.0;
|
||||
_transmitterPackets = 0;
|
||||
|
||||
initializeSkeleton();
|
||||
|
||||
|
@ -67,47 +71,53 @@ Head::Head(bool isMine) {
|
|||
|
||||
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] = -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;
|
||||
_movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_usingBodySprings = false;
|
||||
_springForce = 6.0f;
|
||||
_springVelocityDecay = 16.0f;
|
||||
_head.pupilSize = 0.10;
|
||||
_head.interPupilDistance = 0.6;
|
||||
_head.interBrowDistance = 0.75;
|
||||
_head.nominalPupilSize = 0.10;
|
||||
_head.yaw = 0.0;
|
||||
_head.pitch = 0.0;
|
||||
_head.roll = 0.0;
|
||||
_head.pitchRate = 0.0;
|
||||
_head.yawRate = 0.0;
|
||||
_head.rollRate = 0.0;
|
||||
_head.eyebrowPitch[0] = -30;
|
||||
_head.eyebrowPitch[1] = -30;
|
||||
_head.eyebrowRoll [0] = 20;
|
||||
_head.eyebrowRoll [1] = -20;
|
||||
_head.mouthPitch = 0;
|
||||
_head.mouthYaw = 0;
|
||||
_head.mouthWidth = 1.0;
|
||||
_head.mouthHeight = 0.2;
|
||||
_head.eyeballPitch[0] = 0;
|
||||
_head.eyeballPitch[1] = 0;
|
||||
_head.eyeballScaleX = 1.2;
|
||||
_head.eyeballScaleY = 1.5;
|
||||
_head.eyeballScaleZ = 1.0;
|
||||
_head.eyeballYaw[0] = 0;
|
||||
_head.eyeballYaw[1] = 0;
|
||||
_head.pitchTarget = 0;
|
||||
_head.yawTarget = 0;
|
||||
_head.noiseEnvelope = 1.0;
|
||||
_head.pupilConverge = 10.0;
|
||||
_head.leanForward = 0.0;
|
||||
_head.leanSideways = 0.0;
|
||||
_head.eyeContact = 1;
|
||||
_head.eyeContactTarget = LEFT_EYE;
|
||||
_head.scale = 1.0;
|
||||
_head.audioAttack = 0.0;
|
||||
_head.loudness = 0.0;
|
||||
_head.averageLoudness = 0.0;
|
||||
_head.lastLoudness = 0.0;
|
||||
_head.browAudioLift = 0.0;
|
||||
_head.noise = 0;
|
||||
|
||||
_movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_usingBodySprings = false;
|
||||
_springForce = 6.0f;
|
||||
_springVelocityDecay = 16.0f;
|
||||
_renderYaw = 0.0;
|
||||
_renderPitch = 0.0;
|
||||
|
||||
_sphere = NULL;
|
||||
|
||||
|
@ -119,77 +129,103 @@ Head::Head(bool isMine) {
|
|||
}
|
||||
}
|
||||
|
||||
if (_isMine)
|
||||
{
|
||||
//--------------------------------------------------
|
||||
// test... just slam them into random positions...
|
||||
//--------------------------------------------------
|
||||
_DEBUG_otherAvatarListPosition[ 0 ] = glm::vec3( 0.0f, 0.3f, 2.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 1 ] = glm::vec3( 4.0f, 0.3f, 2.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 2 ] = glm::vec3( 2.0f, 0.3f, 2.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 3 ] = glm::vec3( 1.0f, 0.3f, -4.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 4 ] = glm::vec3( -2.0f, 0.3f, -2.0f );
|
||||
}
|
||||
//--------------------------------------------------
|
||||
// test... just slam them into random positions...
|
||||
//--------------------------------------------------
|
||||
_DEBUG_otherAvatarListPosition[ 0 ] = glm::vec3( 0.0f, 0.3f, 2.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 1 ] = glm::vec3( 4.0f, 0.3f, 2.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 2 ] = glm::vec3( 2.0f, 0.3f, 2.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 3 ] = glm::vec3( 1.0f, 0.3f, -4.0f );
|
||||
_DEBUG_otherAvatarListPosition[ 4 ] = glm::vec3( -2.0f, 0.3f, -2.0f );
|
||||
}
|
||||
|
||||
Head::Head(const Head &otherHead) {
|
||||
Head::Head(const Head &otherAvatar) {
|
||||
|
||||
_velocity = otherAvatar._velocity;
|
||||
_thrust = otherAvatar._thrust;
|
||||
_rotation = otherAvatar._rotation;
|
||||
_closestOtherAvatar = otherAvatar._closestOtherAvatar;
|
||||
_bodyYaw = otherAvatar._bodyYaw;
|
||||
_bodyPitch = otherAvatar._bodyPitch;
|
||||
_bodyRoll = otherAvatar._bodyRoll;
|
||||
_bodyYawDelta = otherAvatar._bodyYawDelta;
|
||||
_triggeringAction = otherAvatar._triggeringAction;
|
||||
_mode = otherAvatar._mode;
|
||||
_isMine = otherAvatar._isMine;
|
||||
_renderYaw = otherAvatar._renderYaw;
|
||||
_renderPitch = otherAvatar._renderPitch;
|
||||
_maxArmLength = otherAvatar._maxArmLength;
|
||||
_transmitterTimer = otherAvatar._transmitterTimer;
|
||||
_transmitterHz = otherAvatar._transmitterHz;
|
||||
_transmitterPackets = otherAvatar._transmitterPackets;
|
||||
_TEST_bigSphereRadius = otherAvatar._TEST_bigSphereRadius;
|
||||
_TEST_bigSpherePosition = otherAvatar._TEST_bigSpherePosition;
|
||||
_movedHandOffset = otherAvatar._movedHandOffset;
|
||||
_usingBodySprings = otherAvatar._usingBodySprings;
|
||||
_springForce = otherAvatar._springForce;
|
||||
_springVelocityDecay = otherAvatar._springVelocityDecay;
|
||||
|
||||
_orientation.set( otherAvatar._orientation );
|
||||
|
||||
_orientation.set( otherHead._orientation );
|
||||
_velocity = otherHead._velocity;
|
||||
_thrust = otherHead._thrust;
|
||||
_rotation = otherHead._rotation;
|
||||
_closestOtherAvatar = otherHead._closestOtherAvatar;
|
||||
_bodyYaw = otherHead._bodyYaw;
|
||||
_bodyPitch = otherHead._bodyPitch;
|
||||
_bodyRoll = otherHead._bodyRoll;
|
||||
_bodyYawDelta = otherHead._bodyYawDelta;
|
||||
_triggeringAction = otherHead._triggeringAction;
|
||||
_mode = otherHead._mode;
|
||||
//for (int o=0;o<NUM_OTHER_AVATARS; o++) {
|
||||
// _DEBUG_otherAvatarListPosition[o] = otherAvatar._DEBUG_otherAvatarListPosition[o];
|
||||
//}
|
||||
|
||||
_sphere = NULL;
|
||||
|
||||
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] = otherAvatar._driveKeys[i];
|
||||
|
||||
_pupilSize = otherHead._pupilSize;
|
||||
_interPupilDistance = otherHead._interPupilDistance;
|
||||
_interBrowDistance = otherHead._interBrowDistance;
|
||||
_nominalPupilSize = otherHead._nominalPupilSize;
|
||||
_headYaw = otherHead._headYaw;
|
||||
_eyebrowPitch[0] = otherHead._eyebrowPitch[0];
|
||||
_eyebrowPitch[1] = otherHead._eyebrowPitch[1];
|
||||
_eyebrowRoll [0] = otherHead._eyebrowRoll [0];
|
||||
_eyebrowRoll [1] = otherHead._eyebrowRoll [1];
|
||||
_mouthPitch = otherHead._mouthPitch;
|
||||
_mouthYaw = otherHead._mouthYaw;
|
||||
_mouthWidth = otherHead._mouthWidth;
|
||||
_mouthHeight = otherHead._mouthHeight;
|
||||
_eyeballPitch[0] = otherHead._eyeballPitch[0];
|
||||
_eyeballPitch[1] = otherHead._eyeballPitch[1];
|
||||
_eyeballScaleX = otherHead._eyeballScaleX;
|
||||
_eyeballScaleY = otherHead._eyeballScaleY;
|
||||
_eyeballScaleZ = otherHead._eyeballScaleZ;
|
||||
_eyeballYaw[0] = otherHead._eyeballYaw[0];
|
||||
_eyeballYaw[1] = otherHead._eyeballYaw[1];
|
||||
_pitchTarget = otherHead._pitchTarget;
|
||||
_yawTarget = otherHead._yawTarget;
|
||||
_noiseEnvelope = otherHead._noiseEnvelope;
|
||||
_pupilConverge = otherHead._pupilConverge;
|
||||
_leanForward = otherHead._leanForward;
|
||||
_leanSideways = otherHead._leanSideways;
|
||||
_eyeContact = otherHead._eyeContact;
|
||||
_eyeContactTarget = otherHead._eyeContactTarget;
|
||||
_scale = otherHead._scale;
|
||||
_renderYaw = otherHead._renderYaw;
|
||||
_renderPitch = otherHead._renderPitch;
|
||||
_audioAttack = otherHead._audioAttack;
|
||||
_loudness = otherHead._loudness;
|
||||
_averageLoudness = otherHead._averageLoudness;
|
||||
_lastLoudness = otherHead._lastLoudness;
|
||||
_browAudioLift = otherHead._browAudioLift;
|
||||
_noise = otherHead._noise;
|
||||
|
||||
_sphere = NULL;
|
||||
_head.pupilSize = otherAvatar._head.pupilSize;
|
||||
_head.interPupilDistance = otherAvatar._head.interPupilDistance;
|
||||
_head.interBrowDistance = otherAvatar._head.interBrowDistance;
|
||||
_head.nominalPupilSize = otherAvatar._head.nominalPupilSize;
|
||||
_head.yaw = otherAvatar._head.yaw;
|
||||
_head.pitch = otherAvatar._head.pitch;
|
||||
_head.roll = otherAvatar._head.roll;
|
||||
_head.yawRate = otherAvatar._head.yawRate;
|
||||
_head.pitchRate = otherAvatar._head.pitchRate;
|
||||
_head.rollRate = otherAvatar._head.rollRate;
|
||||
_head.eyebrowPitch[0] = otherAvatar._head.eyebrowPitch[0];
|
||||
_head.eyebrowPitch[1] = otherAvatar._head.eyebrowPitch[1];
|
||||
_head.eyebrowRoll [0] = otherAvatar._head.eyebrowRoll [0];
|
||||
_head.eyebrowRoll [1] = otherAvatar._head.eyebrowRoll [1];
|
||||
_head.mouthPitch = otherAvatar._head.mouthPitch;
|
||||
_head.mouthYaw = otherAvatar._head.mouthYaw;
|
||||
_head.mouthWidth = otherAvatar._head.mouthWidth;
|
||||
_head.mouthHeight = otherAvatar._head.mouthHeight;
|
||||
_head.eyeballPitch[0] = otherAvatar._head.eyeballPitch[0];
|
||||
_head.eyeballPitch[1] = otherAvatar._head.eyeballPitch[1];
|
||||
_head.eyeballScaleX = otherAvatar._head.eyeballScaleX;
|
||||
_head.eyeballScaleY = otherAvatar._head.eyeballScaleY;
|
||||
_head.eyeballScaleZ = otherAvatar._head.eyeballScaleZ;
|
||||
_head.eyeballYaw[0] = otherAvatar._head.eyeballYaw[0];
|
||||
_head.eyeballYaw[1] = otherAvatar._head.eyeballYaw[1];
|
||||
_head.pitchTarget = otherAvatar._head.pitchTarget;
|
||||
_head.yawTarget = otherAvatar._head.yawTarget;
|
||||
_head.noiseEnvelope = otherAvatar._head.noiseEnvelope;
|
||||
_head.pupilConverge = otherAvatar._head.pupilConverge;
|
||||
_head.leanForward = otherAvatar._head.leanForward;
|
||||
_head.leanSideways = otherAvatar._head.leanSideways;
|
||||
_head.eyeContact = otherAvatar._head.eyeContact;
|
||||
_head.eyeContactTarget = otherAvatar._head.eyeContactTarget;
|
||||
_head.scale = otherAvatar._head.scale;
|
||||
_head.audioAttack = otherAvatar._head.audioAttack;
|
||||
_head.loudness = otherAvatar._head.loudness;
|
||||
_head.averageLoudness = otherAvatar._head.averageLoudness;
|
||||
_head.lastLoudness = otherAvatar._head.lastLoudness;
|
||||
_head.browAudioLift = otherAvatar._head.browAudioLift;
|
||||
_head.noise = otherAvatar._head.noise;
|
||||
|
||||
|
||||
if (iris_texture.size() == 0) {
|
||||
switchToResourcesParentIfRequired();
|
||||
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
||||
if (error != 0) {
|
||||
printLog("error %u: %s\n", error, lodepng_error_text(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Head::~Head() {
|
||||
|
@ -203,8 +239,8 @@ Head* Head::clone() const {
|
|||
}
|
||||
|
||||
void Head::reset() {
|
||||
_headPitch = _headYaw = _headRoll = 0;
|
||||
_leanForward = _leanSideways = 0;
|
||||
_head.pitch = _head.yaw = _head.roll = 0;
|
||||
_head.leanForward = _head.leanSideways = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,7 +252,7 @@ void Head::UpdateGyros(float frametime, SerialInterface * serialInterface, int h
|
|||
const float PITCH_ACCEL_COUPLING = 0.5;
|
||||
const float ROLL_ACCEL_COUPLING = -1.0;
|
||||
float measured_pitch_rate = serialInterface->getRelativeValue(HEAD_PITCH_RATE);
|
||||
_headYawRate = serialInterface->getRelativeValue(HEAD_YAW_RATE);
|
||||
_head.yawRate = serialInterface->getRelativeValue(HEAD_YAW_RATE);
|
||||
float measured_lateral_accel = serialInterface->getRelativeValue(ACCEL_X) -
|
||||
ROLL_ACCEL_COUPLING*serialInterface->getRelativeValue(HEAD_ROLL_RATE);
|
||||
float measured_fwd_accel = serialInterface->getRelativeValue(ACCEL_Z) -
|
||||
|
@ -238,35 +274,35 @@ void Head::UpdateGyros(float frametime, SerialInterface * serialInterface, int h
|
|||
const float MAX_YAW = 85;
|
||||
const float MIN_YAW = -85;
|
||||
|
||||
if ((_headPitch < MAX_PITCH) && (_headPitch > MIN_PITCH))
|
||||
if ((_head.pitch < MAX_PITCH) && (_head.pitch > MIN_PITCH))
|
||||
addPitch(measured_pitch_rate * -HEAD_ROTATION_SCALE * frametime);
|
||||
|
||||
addRoll(-measured_roll_rate * HEAD_ROLL_SCALE * frametime);
|
||||
|
||||
if (head_mirror) {
|
||||
if ((_headYaw < MAX_YAW) && (_headYaw > MIN_YAW))
|
||||
addYaw(-_headYawRate * HEAD_ROTATION_SCALE * frametime);
|
||||
if ((_head.yaw < MAX_YAW) && (_head.yaw > MIN_YAW))
|
||||
addYaw(-_head.yawRate * HEAD_ROTATION_SCALE * frametime);
|
||||
addLean(-measured_lateral_accel * frametime * HEAD_LEAN_SCALE, -measured_fwd_accel*frametime * HEAD_LEAN_SCALE);
|
||||
} else {
|
||||
if ((_headYaw < MAX_YAW) && (_headYaw > MIN_YAW))
|
||||
addYaw(_headYawRate * -HEAD_ROTATION_SCALE * frametime);
|
||||
if ((_head.yaw < MAX_YAW) && (_head.yaw > MIN_YAW))
|
||||
addYaw(_head.yawRate * -HEAD_ROTATION_SCALE * frametime);
|
||||
addLean(measured_lateral_accel * frametime * -HEAD_LEAN_SCALE, measured_fwd_accel*frametime * HEAD_LEAN_SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
void Head::addLean(float x, float z) {
|
||||
// Add Body lean as impulse
|
||||
_leanSideways += x;
|
||||
_leanForward += z;
|
||||
_head.leanSideways += x;
|
||||
_head.leanForward += z;
|
||||
}
|
||||
|
||||
|
||||
void Head::setLeanForward(float dist){
|
||||
_leanForward = dist;
|
||||
_head.leanForward = dist;
|
||||
}
|
||||
|
||||
void Head::setLeanSideways(float dist){
|
||||
_leanSideways = dist;
|
||||
_head.leanSideways = dist;
|
||||
}
|
||||
|
||||
void Head::setTriggeringAction( bool d ) {
|
||||
|
@ -403,9 +439,9 @@ void Head::simulate(float deltaTime) {
|
|||
}
|
||||
|
||||
// we will be eventually getting head rotation from elsewhere. For now, just setting it to body rotation
|
||||
_headYaw = _bodyYaw;
|
||||
_headPitch = _bodyPitch;
|
||||
_headRoll = _bodyRoll;
|
||||
_head.yaw = _bodyYaw;
|
||||
_head.pitch = _bodyPitch;
|
||||
_head.roll = _bodyRoll;
|
||||
|
||||
//----------------------------------------------------------
|
||||
// decay body yaw delta
|
||||
|
@ -429,32 +465,32 @@ void Head::simulate(float deltaTime) {
|
|||
const float LIN_VEL_DECAY = 5.0;
|
||||
_velocity *= ( 1.0 - LIN_VEL_DECAY * deltaTime );
|
||||
|
||||
if (!_noise) {
|
||||
if (!_head.noise) {
|
||||
// Decay back toward center
|
||||
_headPitch *= (1.0f - DECAY*2*deltaTime);
|
||||
_headYaw *= (1.0f - DECAY*2*deltaTime);
|
||||
_headRoll *= (1.0f - DECAY*2*deltaTime);
|
||||
_head.pitch *= (1.0f - DECAY*2*deltaTime);
|
||||
_head.yaw *= (1.0f - DECAY*2*deltaTime);
|
||||
_head.roll *= (1.0f - DECAY*2*deltaTime);
|
||||
}
|
||||
else {
|
||||
// Move toward new target
|
||||
_headPitch += (_pitchTarget - _headPitch)*10*deltaTime; // (1.f - DECAY*deltaTime)*Pitch + ;
|
||||
_headYaw += (_yawTarget - _headYaw)*10*deltaTime; // (1.f - DECAY*deltaTime);
|
||||
_headRoll *= (1.f - DECAY*deltaTime);
|
||||
_head.pitch += (_head.pitchTarget - _head.pitch)*10*deltaTime; // (1.f - DECAY*deltaTime)*Pitch + ;
|
||||
_head.yaw += (_head.yawTarget - _head.yaw )*10*deltaTime; // (1.f - DECAY*deltaTime);
|
||||
_head.roll *= (1.f - DECAY*deltaTime);
|
||||
}
|
||||
|
||||
_leanForward *= (1.f - DECAY*30.f*deltaTime);
|
||||
_leanSideways *= (1.f - DECAY*30.f*deltaTime);
|
||||
_head.leanForward *= (1.f - DECAY*30.f*deltaTime);
|
||||
_head.leanSideways *= (1.f - DECAY*30.f*deltaTime);
|
||||
|
||||
// Update where the avatar's eyes are
|
||||
//
|
||||
// First, decide if we are making eye contact or not
|
||||
if (randFloat() < 0.005) {
|
||||
_eyeContact = !_eyeContact;
|
||||
_eyeContact = 1;
|
||||
if (!_eyeContact) {
|
||||
_head.eyeContact = !_head.eyeContact;
|
||||
_head.eyeContact = 1;
|
||||
if (!_head.eyeContact) {
|
||||
// If we just stopped making eye contact,move the eyes markedly away
|
||||
_eyeballPitch[0] = _eyeballPitch[1] = _eyeballPitch[0] + 5.0 + (randFloat() - 0.5)*10;
|
||||
_eyeballYaw[0] = _eyeballYaw[1] = _eyeballYaw[0] + 5.0 + (randFloat()- 0.5)*5;
|
||||
_head.eyeballPitch[0] = _head.eyeballPitch[1] = _head.eyeballPitch[0] + 5.0 + (randFloat() - 0.5)*10;
|
||||
_head.eyeballYaw [0] = _head.eyeballYaw [1] = _head.eyeballYaw [0] + 5.0 + (randFloat() - 0.5)*5;
|
||||
} else {
|
||||
// If now making eye contact, turn head to look right at viewer
|
||||
SetNewHeadTarget(0,0);
|
||||
|
@ -464,56 +500,56 @@ void Head::simulate(float deltaTime) {
|
|||
const float DEGREES_BETWEEN_VIEWER_EYES = 3;
|
||||
const float DEGREES_TO_VIEWER_MOUTH = 7;
|
||||
|
||||
if (_eyeContact) {
|
||||
if (_head.eyeContact) {
|
||||
// Should we pick a new eye contact target?
|
||||
if (randFloat() < 0.01) {
|
||||
// Choose where to look next
|
||||
if (randFloat() < 0.1) {
|
||||
_eyeContactTarget = MOUTH;
|
||||
_head.eyeContactTarget = MOUTH;
|
||||
} else {
|
||||
if (randFloat() < 0.5) _eyeContactTarget = LEFT_EYE; else _eyeContactTarget = RIGHT_EYE;
|
||||
if (randFloat() < 0.5) _head.eyeContactTarget = LEFT_EYE; else _head.eyeContactTarget = RIGHT_EYE;
|
||||
}
|
||||
}
|
||||
// Set eyeball pitch and yaw to make contact
|
||||
float eye_target_yaw_adjust = 0;
|
||||
float eye_target_pitch_adjust = 0;
|
||||
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 == MOUTH) eye_target_pitch_adjust = DEGREES_TO_VIEWER_MOUTH;
|
||||
if (_head.eyeContactTarget == LEFT_EYE) eye_target_yaw_adjust = DEGREES_BETWEEN_VIEWER_EYES;
|
||||
if (_head.eyeContactTarget == RIGHT_EYE) eye_target_yaw_adjust = -DEGREES_BETWEEN_VIEWER_EYES;
|
||||
if (_head.eyeContactTarget == MOUTH) eye_target_pitch_adjust = DEGREES_TO_VIEWER_MOUTH;
|
||||
|
||||
_eyeballPitch[0] = _eyeballPitch[1] = -_headPitch + eye_target_pitch_adjust;
|
||||
_eyeballYaw[0] = _eyeballYaw[1] = -_headYaw + eye_target_yaw_adjust;
|
||||
_head.eyeballPitch[0] = _head.eyeballPitch[1] = -_head.pitch + eye_target_pitch_adjust;
|
||||
_head.eyeballYaw[0] = _head.eyeballYaw[1] = -_head.yaw + eye_target_yaw_adjust;
|
||||
}
|
||||
|
||||
|
||||
if (_noise)
|
||||
if (_head.noise)
|
||||
{
|
||||
_headPitch += (randFloat() - 0.5)*0.2*_noiseEnvelope;
|
||||
_headYaw += (randFloat() - 0.5)*0.3*_noiseEnvelope;
|
||||
_head.pitch += (randFloat() - 0.5)*0.2*_head.noiseEnvelope;
|
||||
_head.yaw += (randFloat() - 0.5)*0.3*_head.noiseEnvelope;
|
||||
//PupilSize += (randFloat() - 0.5)*0.001*NoiseEnvelope;
|
||||
|
||||
if (randFloat() < 0.005) _mouthWidth = MouthWidthChoices[rand()%3];
|
||||
if (randFloat() < 0.005) _head.mouthWidth = MouthWidthChoices[rand()%3];
|
||||
|
||||
if (!_eyeContact) {
|
||||
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 (!_head.eyeContact) {
|
||||
if (randFloat() < 0.01) _head.eyeballPitch[0] = _head.eyeballPitch[1] = (randFloat() - 0.5)*20;
|
||||
if (randFloat() < 0.01) _head.eyeballYaw[0] = _head.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(_head.pitchTarget - _head.pitch) < 1.0) && (fabs(_head.yawTarget - _head.yaw) < 1.0)) {
|
||||
SetNewHeadTarget((randFloat()-0.5)*20.0, (randFloat()-0.5)*45.0);
|
||||
}
|
||||
|
||||
if (0) {
|
||||
|
||||
// Pick new target
|
||||
_pitchTarget = (randFloat() - 0.5)*45;
|
||||
_yawTarget = (randFloat() - 0.5)*22;
|
||||
_head.pitchTarget = (randFloat() - 0.5)*45;
|
||||
_head.yawTarget = (randFloat() - 0.5)*22;
|
||||
}
|
||||
if (randFloat() < 0.01)
|
||||
{
|
||||
_eyebrowPitch[0] = _eyebrowPitch[1] = BrowPitchAngle[rand()%3];
|
||||
_eyebrowRoll[0] = _eyebrowRoll[1] = BrowRollAngle[rand()%5];
|
||||
_eyebrowRoll[1]*=-1;
|
||||
_head.eyebrowPitch[0] = _head.eyebrowPitch[1] = BrowPitchAngle[rand()%3];
|
||||
_head.eyebrowRoll [0] = _head.eyebrowRoll[1] = BrowRollAngle[rand()%5];
|
||||
_head.eyebrowRoll [1]*=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -688,9 +724,9 @@ void Head::renderHead(int faceToFace) {
|
|||
|
||||
glScalef( 0.03, 0.03, 0.03 );
|
||||
|
||||
glRotatef(_headYaw, 0, 1, 0);
|
||||
glRotatef(_headPitch, 1, 0, 0);
|
||||
glRotatef(_headRoll, 0, 0, 1);
|
||||
glRotatef(_head.yaw, 0, 1, 0);
|
||||
glRotatef(_head.pitch, 1, 0, 0);
|
||||
glRotatef(_head.roll, 0, 0, 1);
|
||||
|
||||
// Overall scale of head
|
||||
if (faceToFace) glScalef(2.0, 2.0, 2.0);
|
||||
|
@ -719,27 +755,27 @@ void Head::renderHead(int faceToFace) {
|
|||
glPopMatrix();
|
||||
|
||||
// _eyebrows
|
||||
_audioAttack = 0.9*_audioAttack + 0.1*fabs(_loudness - _lastLoudness);
|
||||
_lastLoudness = _loudness;
|
||||
_head.audioAttack = 0.9*_head.audioAttack + 0.1*fabs(_head.loudness - _head.lastLoudness);
|
||||
_head.lastLoudness = _head.loudness;
|
||||
|
||||
const float BROW_LIFT_THRESHOLD = 100;
|
||||
if (_audioAttack > BROW_LIFT_THRESHOLD)
|
||||
_browAudioLift += sqrt(_audioAttack)/1000.0;
|
||||
if (_head.audioAttack > BROW_LIFT_THRESHOLD)
|
||||
_head.browAudioLift += sqrt(_head.audioAttack)/1000.0;
|
||||
|
||||
_browAudioLift *= .90;
|
||||
_head.browAudioLift *= .90;
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-_interBrowDistance/2.0,0.4,0.45);
|
||||
glTranslatef(-_head.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 + _head.browAudioLift, 0);
|
||||
glRotatef(_head.eyebrowPitch[side]/2.0, 1, 0, 0);
|
||||
glRotatef(_head.eyebrowRoll[side]/2.0, 0, 0, 1);
|
||||
glScalef(browWidth, browThickness, 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
glTranslatef(_interBrowDistance, 0, 0);
|
||||
glTranslatef(_head.interBrowDistance, 0, 0);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
|
@ -749,23 +785,23 @@ 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(_head.mouthPitch, 1, 0, 0);
|
||||
glRotatef(_head.mouthYaw, 0, 0, 1);
|
||||
glScalef(_head.mouthWidth*(.7 + sqrt(_head.averageLoudness)/60.0), _head.mouthHeight*(1.0 + sqrt(_head.averageLoudness)/30.0), 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
|
||||
glTranslatef(0, 1.0, 0);
|
||||
|
||||
glTranslatef(-_interPupilDistance/2.0,-0.68,0.7);
|
||||
glTranslatef(-_head.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(_head.interPupilDistance/10.0, 0, 0.05);
|
||||
glRotatef(20, 0, 0, 1);
|
||||
glScalef(_eyeballScaleX, _eyeballScaleY, _eyeballScaleZ);
|
||||
glScalef(_head.eyeballScaleX, _head.eyeballScaleY, _head.eyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
@ -782,40 +818,40 @@ void Head::renderHead(int faceToFace) {
|
|||
|
||||
glPushMatrix();
|
||||
{
|
||||
glRotatef(_eyeballPitch[1], 1, 0, 0);
|
||||
glRotatef(_eyeballYaw[1] + _pupilConverge, 0, 1, 0);
|
||||
glRotatef(_head.eyeballPitch[1], 1, 0, 0);
|
||||
glRotatef(_head.eyeballYaw[1] + _head.yaw + _head.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, _head.pupilSize, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
// Left Eye
|
||||
glColor3fv(eyeColor);
|
||||
glTranslatef(_interPupilDistance, 0, 0);
|
||||
glTranslatef(_head.interPupilDistance, 0, 0);
|
||||
glPushMatrix();
|
||||
{
|
||||
glTranslatef(-_interPupilDistance/10.0, 0, .05);
|
||||
glTranslatef(-_head.interPupilDistance/10.0, 0, .05);
|
||||
glRotatef(-20, 0, 0, 1);
|
||||
glScalef(_eyeballScaleX, _eyeballScaleY, _eyeballScaleZ);
|
||||
glScalef(_head.eyeballScaleX, _head.eyeballScaleY, _head.eyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
}
|
||||
glPopMatrix();
|
||||
// Left Pupil
|
||||
glPushMatrix();
|
||||
{
|
||||
glRotatef(_eyeballPitch[0], 1, 0, 0);
|
||||
glRotatef(_eyeballYaw[0] - _pupilConverge, 0, 1, 0);
|
||||
glRotatef(_head.eyeballPitch[0], 1, 0, 0);
|
||||
glRotatef(_head.eyeballYaw[0] + _head.yaw - _head.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, _head.pupilSize, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
@ -1260,8 +1296,8 @@ void Head::renderBody() {
|
|||
}
|
||||
|
||||
void Head::SetNewHeadTarget(float pitch, float yaw) {
|
||||
_pitchTarget = pitch;
|
||||
_yawTarget = yaw;
|
||||
_head.pitchTarget = pitch;
|
||||
_head.yawTarget = yaw;
|
||||
}
|
||||
|
||||
// getting data from Android transmitte app
|
||||
|
|
|
@ -91,6 +91,48 @@ struct AvatarBone
|
|||
float radius; // used for detecting collisions for certain physical effects
|
||||
};
|
||||
|
||||
struct AvatarHead
|
||||
{
|
||||
float pitch;
|
||||
float yaw;
|
||||
float roll;
|
||||
float pitchRate;
|
||||
float yawRate;
|
||||
float rollRate;
|
||||
float noise;
|
||||
float eyeballPitch[2];
|
||||
float eyeballYaw [2];
|
||||
float eyebrowPitch[2];
|
||||
float eyebrowRoll [2];
|
||||
float eyeballScaleX;
|
||||
float eyeballScaleY;
|
||||
float 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;
|
||||
int eyeContact;
|
||||
float browAudioLift;
|
||||
eyeContactTargets eyeContactTarget;
|
||||
|
||||
// Sound loudness information
|
||||
float loudness, lastLoudness;
|
||||
float averageLoudness;
|
||||
float audioAttack;
|
||||
};
|
||||
|
||||
|
||||
class Head : public AvatarData {
|
||||
public:
|
||||
Head(bool isMine);
|
||||
|
@ -98,30 +140,29 @@ class Head : public AvatarData {
|
|||
Head(const Head &otherHead);
|
||||
Head* clone() const;
|
||||
|
||||
void reset();
|
||||
void UpdateGyros(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity);
|
||||
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;}
|
||||
void reset();
|
||||
void UpdateGyros(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity);
|
||||
void setNoise (float mag) { _head.noise = mag; }
|
||||
void setPitch(float p) {_head.pitch = p; }
|
||||
void setYaw(float y) {_head.yaw = y; }
|
||||
void setRoll(float r) {_head.roll = r; };
|
||||
void setScale(float s) {_head.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; }
|
||||
void addYaw(float y){_headYaw -= y; }
|
||||
void addRoll(float r){_headRoll += r; }
|
||||
void addLean(float x, float z);
|
||||
float getPitch() {return _headPitch;}
|
||||
float getRoll() {return _headRoll;}
|
||||
float getYaw() {return _headYaw;}
|
||||
float getLastMeasuredYaw() {return _headYawRate;}
|
||||
|
||||
void setLeanForward(float dist);
|
||||
void setLeanSideways(float dist);
|
||||
void addPitch(float p) {_head.pitch -= p; }
|
||||
void addYaw(float y){_head.yaw -= y; }
|
||||
void addRoll(float r){_head.roll += r; }
|
||||
void addLean(float x, float z);
|
||||
float getPitch() {return _head.pitch;}
|
||||
float getRoll() {return _head.roll;}
|
||||
float getYaw() {return _head.yaw;}
|
||||
float getLastMeasuredYaw() {return _head.yawRate;}
|
||||
float getBodyYaw() {return _bodyYaw;};
|
||||
void addBodyYaw(float y) {_bodyYaw += y;};
|
||||
void addBodyYaw(float y) {_bodyYaw += y;};
|
||||
|
||||
glm::vec3 getHeadLookatDirection();
|
||||
glm::vec3 getHeadLookatDirectionUp();
|
||||
|
@ -137,7 +178,6 @@ class Head : public AvatarData {
|
|||
|
||||
void renderBody();
|
||||
void renderHead( int faceToFace);
|
||||
//void renderOrientationDirections( glm::vec3 position, Orientation orientation, float size );
|
||||
|
||||
void simulate(float);
|
||||
|
||||
|
@ -146,10 +186,10 @@ class Head : public AvatarData {
|
|||
void setHandMovementValues( 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 _head.loudness;};
|
||||
float getAverageLoudness() {return _head.averageLoudness;};
|
||||
void setAverageLoudness(float al) {_head.averageLoudness = al;};
|
||||
void setLoudness(float l) {_head.loudness = l;};
|
||||
|
||||
void SetNewHeadTarget(float, float);
|
||||
|
||||
|
@ -170,41 +210,8 @@ class Head : public AvatarData {
|
|||
float getTransmitterHz() { return _transmitterHz; };
|
||||
|
||||
private:
|
||||
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;
|
||||
|
||||
// Sound loudness information
|
||||
float _loudness, _lastLoudness;
|
||||
float _averageLoudness;
|
||||
float _audioAttack;
|
||||
float _browAudioLift;
|
||||
|
||||
AvatarHead _head;
|
||||
bool _isMine;
|
||||
glm::vec3 _TEST_bigSpherePosition;
|
||||
float _TEST_bigSphereRadius;
|
||||
glm::vec3 _DEBUG_otherAvatarListPosition[ NUM_OTHER_AVATARS ];
|
||||
|
@ -224,13 +231,9 @@ class Head : public AvatarData {
|
|||
float _maxArmLength;
|
||||
Orientation _orientation;
|
||||
int _driveKeys[MAX_DRIVE_KEYS];
|
||||
int _eyeContact;
|
||||
eyeContactTargets _eyeContactTarget;
|
||||
|
||||
GLUquadric *_sphere;
|
||||
|
||||
float _renderYaw;
|
||||
float _renderPitch; // Pitch from view frustum when this is own head.
|
||||
GLUquadric* _sphere;
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue