Add mouth as third gaze target in addition to left and right eyes

This commit is contained in:
David Rowe 2015-07-01 21:22:30 -07:00
parent 4ced0dc6c4
commit 026f6d3690
4 changed files with 38 additions and 18 deletions

View file

@ -2295,11 +2295,17 @@ void Application::updateMyAvatarLookAtPosition() {
float faceAngle = glm::angle(lookingAtFaceOrientation, fromLookingAtToMe); float faceAngle = glm::angle(lookingAtFaceOrientation, fromLookingAtToMe);
if (faceAngle < MAXIMUM_FACE_ANGLE) { if (faceAngle < MAXIMUM_FACE_ANGLE) {
// Randomly look back and forth between left and right eyes // Randomly look back and forth between look targets
if (_myAvatar->isLookingAtLeftEye()) { switch (_myAvatar->getEyeContactTarget()) {
case LEFT_EYE:
lookAtSpot = lookingAtHead->getLeftEyePosition(); lookAtSpot = lookingAtHead->getLeftEyePosition();
} else { break;
case RIGHT_EYE:
lookAtSpot = lookingAtHead->getRightEyePosition(); lookAtSpot = lookingAtHead->getRightEyePosition();
break;
case MOUTH:
lookAtSpot = lookingAtHead->getMouthPosition();
break;
} }
} else { } else {
// Just look at their head (mid point between eyes) // Just look at their head (mid point between eyes)

View file

@ -22,11 +22,6 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "world.h" #include "world.h"
enum eyeContactTargets {
LEFT_EYE,
RIGHT_EYE,
MOUTH
};
const float EYE_EAR_GAP = 0.08f; const float EYE_EAR_GAP = 0.08f;
@ -74,6 +69,7 @@ public:
const glm::vec3& getLeftEyePosition() const { return _leftEyePosition; } const glm::vec3& getLeftEyePosition() const { return _leftEyePosition; }
glm::vec3 getRightEarPosition() const { return _rightEyePosition + (getRightDirection() * EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); } glm::vec3 getRightEarPosition() const { return _rightEyePosition + (getRightDirection() * EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); }
glm::vec3 getLeftEarPosition() const { return _leftEyePosition + (getRightDirection() * -EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); } glm::vec3 getLeftEarPosition() const { return _leftEyePosition + (getRightDirection() * -EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); }
glm::vec3 getMouthPosition() const { return _eyePosition - getUpDirection() * glm::length(_rightEyePosition - _leftEyePosition); }
FaceModel& getFaceModel() { return _faceModel; } FaceModel& getFaceModel() { return _faceModel; }
const FaceModel& getFaceModel() const { return _faceModel; } const FaceModel& getFaceModel() const { return _faceModel; }

View file

@ -95,7 +95,7 @@ MyAvatar::MyAvatar() :
_shouldRender(true), _shouldRender(true),
_billboardValid(false), _billboardValid(false),
_feetTouchFloor(true), _feetTouchFloor(true),
_isLookingAtLeftEye(true), _eyeContactTarget(LEFT_EYE),
_realWorldFieldOfView("realWorldFieldOfView", _realWorldFieldOfView("realWorldFieldOfView",
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES), DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
_firstPersonSkeletonModel(this), _firstPersonSkeletonModel(this),
@ -904,12 +904,24 @@ void MyAvatar::clearLookAtTargetAvatar() {
_lookAtTargetAvatar.reset(); _lookAtTargetAvatar.reset();
} }
bool MyAvatar::isLookingAtLeftEye() { eyeContactTarget MyAvatar::getEyeContactTarget() {
float const CHANCE_OF_CHANGING_EYE = 0.01f; float const CHANCE_OF_CHANGING_TARGET = 0.01f;
if (randFloat() < CHANCE_OF_CHANGING_EYE) { if (randFloat() < CHANCE_OF_CHANGING_TARGET) {
_isLookingAtLeftEye = !_isLookingAtLeftEye; float const FIFTY_FIFTY_CHANCE = 0.5f;
switch (_eyeContactTarget) {
case LEFT_EYE:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? MOUTH : RIGHT_EYE;
break;
case RIGHT_EYE:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? LEFT_EYE : MOUTH;
break;
case MOUTH:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? RIGHT_EYE : LEFT_EYE;
break;
} }
return _isLookingAtLeftEye; }
return _eyeContactTarget;
} }
glm::vec3 MyAvatar::getDefaultEyePosition() const { glm::vec3 MyAvatar::getDefaultEyePosition() const {

View file

@ -19,6 +19,12 @@
class ModelItemID; class ModelItemID;
enum eyeContactTarget {
LEFT_EYE,
RIGHT_EYE,
MOUTH
};
class MyAvatar : public Avatar { class MyAvatar : public Avatar {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally) Q_PROPERTY(bool shouldRenderLocally READ getShouldRenderLocally WRITE setShouldRenderLocally)
@ -93,7 +99,7 @@ public:
bool isMyAvatar() const { return true; } bool isMyAvatar() const { return true; }
bool isLookingAtLeftEye(); eyeContactTarget getEyeContactTarget();
virtual int parseDataAtOffset(const QByteArray& packet, int offset); virtual int parseDataAtOffset(const QByteArray& packet, int offset);
@ -245,7 +251,7 @@ private:
QList<AnimationHandlePointer> _animationHandles; QList<AnimationHandlePointer> _animationHandles;
bool _feetTouchFloor; bool _feetTouchFloor;
bool _isLookingAtLeftEye; eyeContactTarget _eyeContactTarget;
RecorderPointer _recorder; RecorderPointer _recorder;