mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 14:47:19 +02:00
Avatar can look at corrected position when looking at me
This commit is contained in:
parent
034870e46e
commit
21a15cff2a
6 changed files with 33 additions and 5 deletions
|
@ -43,7 +43,7 @@ var noFly = true;
|
|||
var fixedWalkVelocity = true;
|
||||
|
||||
//var roomLimits = { xMin: 618, xMax: 635.5, zMin: 528, zMax: 552.5 };
|
||||
var roomLimits = { xMin: 193.0, xMax: 206.5, zMin: 251.4, zMax: 269.5 };
|
||||
var roomLimits = { xMin: 100.0, xMax: 206.5, zMin: 251.4, zMax: 269.5 };
|
||||
|
||||
function isInRoom(position) {
|
||||
var BUFFER = 2.0;
|
||||
|
|
|
@ -1882,13 +1882,13 @@ void Application::shrinkMirrorView() {
|
|||
}
|
||||
}
|
||||
|
||||
const float HEAD_SPHERE_RADIUS = 0.07f;
|
||||
const float HEAD_SPHERE_RADIUS = 0.1f;
|
||||
|
||||
bool Application::isLookingAtMyAvatar(Avatar* avatar) {
|
||||
glm::vec3 theirLookat = avatar->getHead()->getLookAtPosition();
|
||||
glm::vec3 myHeadPosition = _myAvatar->getHead()->getPosition();
|
||||
glm::vec3 myEyePosition = _myAvatar->getHead()->getEyePosition();
|
||||
|
||||
if (pointInSphere(theirLookat, myHeadPosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) {
|
||||
if (pointInSphere(theirLookat, myEyePosition, HEAD_SPHERE_RADIUS * _myAvatar->getScale())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -300,6 +300,8 @@ public:
|
|||
ScriptEngine* getScriptEngine(QString scriptHash) { return _scriptEnginesHash.contains(scriptHash) ? _scriptEnginesHash[scriptHash] : NULL; }
|
||||
|
||||
void setCursorVisible(bool visible);
|
||||
|
||||
bool isLookingAtMyAvatar(Avatar* avatar);
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -414,7 +416,6 @@ private:
|
|||
void updateCursor(float deltaTime);
|
||||
|
||||
Avatar* findLookatTargetAvatar(glm::vec3& eyePosition, QUuid &nodeUUID);
|
||||
bool isLookingAtMyAvatar(Avatar* avatar);
|
||||
|
||||
void renderLookatIndicator(glm::vec3 pointOfInterest);
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ Head::Head(Avatar* owningAvatar) :
|
|||
_deltaLeanSideways(0.f),
|
||||
_deltaLeanForward(0.f),
|
||||
_isCameraMoving(false),
|
||||
_isLookingAtMe(false),
|
||||
_faceModel(this)
|
||||
{
|
||||
|
||||
|
@ -219,6 +220,14 @@ glm::quat Head::getFinalOrientationInLocalFrame() const {
|
|||
return glm::quat(glm::radians(glm::vec3(getFinalPitch(), getFinalYaw(), getFinalRoll() )));
|
||||
}
|
||||
|
||||
glm::vec3 Head::getCorrectedLookAtPosition() {
|
||||
if (_isLookingAtMe) {
|
||||
return getLookAtPosition();
|
||||
} else {
|
||||
return _correctedLookAtPosition;
|
||||
}
|
||||
}
|
||||
|
||||
glm::quat Head::getCameraOrientation () const {
|
||||
if (OculusManager::isConnected()) {
|
||||
return getOrientation();
|
||||
|
|
|
@ -63,6 +63,10 @@ public:
|
|||
const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
|
||||
void setAngularVelocity(glm::vec3 angularVelocity) { _angularVelocity = angularVelocity; }
|
||||
|
||||
void setCorrectedLookAtPosition(glm::vec3 correctedLookAtPosition) { _correctedLookAtPosition = correctedLookAtPosition; }
|
||||
glm::vec3 getCorrectedLookAtPosition();
|
||||
void clearCorrectedLookAtPosition() { _isLookingAtMe = false; }
|
||||
|
||||
float getScale() const { return _scale; }
|
||||
glm::vec3 getPosition() const { return _position; }
|
||||
const glm::vec3& getEyePosition() const { return _eyePosition; }
|
||||
|
@ -143,8 +147,11 @@ private:
|
|||
float _deltaLeanForward;
|
||||
|
||||
bool _isCameraMoving;
|
||||
bool _isLookingAtMe;
|
||||
FaceModel _faceModel;
|
||||
|
||||
glm::vec3 _correctedLookAtPosition;
|
||||
|
||||
// private methods
|
||||
void renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition);
|
||||
|
||||
|
|
|
@ -953,6 +953,7 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
_targetAvatarPosition = glm::vec3(0.0f);
|
||||
const float MIN_LOOKAT_ANGLE = PI / 4.0f; // Smallest angle between face and person where we will look at someone
|
||||
float smallestAngleTo = MIN_LOOKAT_ANGLE;
|
||||
int howManyLookingAtMe = 0;
|
||||
foreach (const AvatarSharedPointer& avatarPointer, Application::getInstance()->getAvatarManager().getAvatarHash()) {
|
||||
Avatar* avatar = static_cast<Avatar*>(avatarPointer.data());
|
||||
avatar->setIsLookAtTarget(false);
|
||||
|
@ -965,11 +966,21 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
_targetAvatarPosition = avatarPointer->getPosition();
|
||||
smallestAngleTo = angleTo;
|
||||
}
|
||||
// Check if this avatar is looking at me, and fix their gaze on my camera if so
|
||||
if (Application::getInstance()->isLookingAtMyAvatar(avatar)) {
|
||||
howManyLookingAtMe++;
|
||||
// Have that avatar look directly at my camera
|
||||
// TODO: correct to look at left/right eye
|
||||
avatar->getHead()->setLookAtPosition(Application::getInstance()->getCamera()->getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_lookAtTargetAvatar) {
|
||||
static_cast<Avatar*>(_lookAtTargetAvatar.data())->setIsLookAtTarget(true);
|
||||
}
|
||||
if (howManyLookingAtMe > 0) {
|
||||
qDebug() << "look @me: " << howManyLookingAtMe;
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::clearLookAtTargetAvatar() {
|
||||
|
|
Loading…
Reference in a new issue