mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
Merge pull request #982 from ey6es/grower
Enlarge heads when they're moused over.
This commit is contained in:
commit
a44d665767
3 changed files with 40 additions and 21 deletions
|
@ -116,7 +116,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_nudgeStarted(false),
|
_nudgeStarted(false),
|
||||||
_lookingAlongX(false),
|
_lookingAlongX(false),
|
||||||
_lookingAwayFromOrigin(true),
|
_lookingAwayFromOrigin(true),
|
||||||
_isLookingAtOtherAvatar(false),
|
_lookatTargetAvatar(NULL),
|
||||||
_lookatIndicatorScale(1.0f),
|
_lookatIndicatorScale(1.0f),
|
||||||
_perfStatsOn(false),
|
_perfStatsOn(false),
|
||||||
_chatEntryOn(false),
|
_chatEntryOn(false),
|
||||||
|
@ -974,7 +974,7 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
|
|
||||||
maybeEditVoxelUnderCursor();
|
maybeEditVoxelUnderCursor();
|
||||||
|
|
||||||
if (!_palette.isActive() && (!_isHoverVoxel || _isLookingAtOtherAvatar)) {
|
if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) {
|
||||||
_pieMenu.mousePressEvent(_mouseX, _mouseY);
|
_pieMenu.mousePressEvent(_mouseX, _mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1503,7 +1503,7 @@ void Application::setListenModeSingleSource() {
|
||||||
glm::vec3 eyePositionIgnored;
|
glm::vec3 eyePositionIgnored;
|
||||||
uint16_t nodeID;
|
uint16_t nodeID;
|
||||||
|
|
||||||
if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) {
|
if (findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) {
|
||||||
_audio.addListenSource(nodeID);
|
_audio.addListenSource(nodeID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1596,11 +1596,15 @@ const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
|
||||||
const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
|
const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
|
||||||
const float HEAD_SPHERE_RADIUS = 0.07;
|
const float HEAD_SPHERE_RADIUS = 0.07;
|
||||||
|
|
||||||
|
|
||||||
static uint16_t DEFAULT_NODE_ID_REF = 1;
|
static uint16_t DEFAULT_NODE_ID_REF = 1;
|
||||||
|
|
||||||
|
void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
|
||||||
|
glm::vec3& eyePosition) {
|
||||||
|
|
||||||
Avatar* Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
_lookatTargetAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePosition, DEFAULT_NODE_ID_REF);
|
||||||
|
}
|
||||||
|
|
||||||
|
Avatar* Application::findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
|
||||||
glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) {
|
glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) {
|
||||||
|
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
@ -1748,8 +1752,8 @@ void Application::update(float deltaTime) {
|
||||||
_faceshift.getEstimatedEyePitch(), _faceshift.getEstimatedEyeYaw(), 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f);
|
_faceshift.getEstimatedEyePitch(), _faceshift.getEstimatedEyeYaw(), 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
_isLookingAtOtherAvatar = isLookingAtOtherAvatar(lookAtRayOrigin, lookAtRayDirection, lookAtSpot);
|
updateLookatTargetAvatar(lookAtRayOrigin, lookAtRayDirection, lookAtSpot);
|
||||||
if (_isLookingAtOtherAvatar) {
|
if (_lookatTargetAvatar) {
|
||||||
// If the mouse is over another avatar's head...
|
// If the mouse is over another avatar's head...
|
||||||
_myAvatar.getHead().setLookAtPosition(lookAtSpot);
|
_myAvatar.getHead().setLookAtPosition(lookAtSpot);
|
||||||
} else if (_isHoverVoxel && !_faceshift.isActive()) {
|
} else if (_isHoverVoxel && !_faceshift.isActive()) {
|
||||||
|
@ -2063,15 +2067,15 @@ void Application::updateAvatar(float deltaTime) {
|
||||||
const float MIDPOINT_OF_SCREEN = 0.5;
|
const float MIDPOINT_OF_SCREEN = 0.5;
|
||||||
|
|
||||||
// Only use gyro to set lookAt if mouse hasn't selected an avatar
|
// Only use gyro to set lookAt if mouse hasn't selected an avatar
|
||||||
if (!_isLookingAtOtherAvatar) {
|
if (!_lookatTargetAvatar) {
|
||||||
|
|
||||||
// Set lookAtPosition if an avatar is at the center of the screen
|
// Set lookAtPosition if an avatar is at the center of the screen
|
||||||
glm::vec3 screenCenterRayOrigin, screenCenterRayDirection;
|
glm::vec3 screenCenterRayOrigin, screenCenterRayDirection;
|
||||||
_viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
|
_viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
|
||||||
|
|
||||||
glm::vec3 eyePosition;
|
glm::vec3 eyePosition;
|
||||||
_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
|
updateLookatTargetAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
|
||||||
if (_isLookingAtOtherAvatar) {
|
if (_lookatTargetAvatar) {
|
||||||
glm::vec3 myLookAtFromMouse(eyePosition);
|
glm::vec3 myLookAtFromMouse(eyePosition);
|
||||||
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
||||||
}
|
}
|
||||||
|
@ -2540,7 +2544,7 @@ void Application::displaySide(Camera& whichCamera) {
|
||||||
Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
|
Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
|
||||||
_myAvatar.setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
|
_myAvatar.setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::LookAtIndicator) && _isLookingAtOtherAvatar) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::LookAtIndicator) && _lookatTargetAvatar) {
|
||||||
renderLookatIndicator(_lookatOtherPosition, whichCamera);
|
renderLookatIndicator(_lookatOtherPosition, whichCamera);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3342,10 +3346,7 @@ void Application::toggleFollowMode() {
|
||||||
mouseRayOrigin, mouseRayDirection);
|
mouseRayOrigin, mouseRayDirection);
|
||||||
glm::vec3 eyePositionIgnored;
|
glm::vec3 eyePositionIgnored;
|
||||||
uint16_t nodeIDIgnored;
|
uint16_t nodeIDIgnored;
|
||||||
Avatar* leadingAvatar = isLookingAtOtherAvatar(mouseRayOrigin,
|
Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeIDIgnored);
|
||||||
mouseRayDirection,
|
|
||||||
eyePositionIgnored,
|
|
||||||
nodeIDIgnored);
|
|
||||||
|
|
||||||
_myAvatar.follow(leadingAvatar);
|
_myAvatar.follow(leadingAvatar);
|
||||||
}
|
}
|
||||||
|
@ -3418,6 +3419,8 @@ void Application::nodeKilled(Node* node) {
|
||||||
fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
|
fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
|
||||||
_voxelFades.push_back(fade);
|
_voxelFades.push_back(fade);
|
||||||
}
|
}
|
||||||
|
} else if (node->getLinkedData() == _lookatTargetAvatar) {
|
||||||
|
_lookatTargetAvatar = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,8 @@ public:
|
||||||
TextureCache* getTextureCache() { return &_textureCache; }
|
TextureCache* getTextureCache() { return &_textureCache; }
|
||||||
GlowEffect* getGlowEffect() { return &_glowEffect; }
|
GlowEffect* getGlowEffect() { return &_glowEffect; }
|
||||||
|
|
||||||
|
Avatar* getLookatTargetAvatar() const { return _lookatTargetAvatar; }
|
||||||
|
|
||||||
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||||
const char* nodeTypes, int numNodeTypes);
|
const char* nodeTypes, int numNodeTypes);
|
||||||
|
|
||||||
|
@ -195,7 +197,10 @@ private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void update(float deltaTime);
|
void update(float deltaTime);
|
||||||
Avatar* isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
|
||||||
|
void updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
|
||||||
|
glm::vec3& eyePosition);
|
||||||
|
Avatar* findLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
|
||||||
glm::vec3& eyePosition, uint16_t& nodeID);
|
glm::vec3& eyePosition, uint16_t& nodeID);
|
||||||
bool isLookingAtMyAvatar(Avatar* avatar);
|
bool isLookingAtMyAvatar(Avatar* avatar);
|
||||||
|
|
||||||
|
@ -315,7 +320,7 @@ private:
|
||||||
bool _lookingAwayFromOrigin;
|
bool _lookingAwayFromOrigin;
|
||||||
glm::vec3 _nudgeGuidePosition;
|
glm::vec3 _nudgeGuidePosition;
|
||||||
|
|
||||||
bool _isLookingAtOtherAvatar;
|
Avatar* _lookatTargetAvatar;
|
||||||
glm::vec3 _lookatOtherPosition;
|
glm::vec3 _lookatOtherPosition;
|
||||||
float _lookatIndicatorScale;
|
float _lookatIndicatorScale;
|
||||||
|
|
||||||
|
|
|
@ -388,9 +388,20 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter, float gyroCamer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// head scale grows when avatar is looked at
|
||||||
|
if (Application::getInstance()->getLookatTargetAvatar() == this) {
|
||||||
|
const float BASE_MAX_SCALE = 3.0f;
|
||||||
|
const float GROW_SPEED = 0.1f;
|
||||||
|
_head.setScale(min(BASE_MAX_SCALE * glm::distance(_position, Application::getInstance()->getCamera()->getPosition()),
|
||||||
|
_head.getScale() + deltaTime * GROW_SPEED));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const float SHRINK_SPEED = 100.0f;
|
||||||
|
_head.setScale(max(_scale, _head.getScale() - deltaTime * SHRINK_SPEED));
|
||||||
|
}
|
||||||
|
|
||||||
_head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
_head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
||||||
_head.setPosition(_bodyBall[ BODY_BALL_HEAD_BASE ].position);
|
_head.setPosition(_bodyBall[ BODY_BALL_HEAD_BASE ].position);
|
||||||
_head.setScale(_scale);
|
|
||||||
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
||||||
_head.simulate(deltaTime, false, gyroCameraSensitivity);
|
_head.simulate(deltaTime, false, gyroCameraSensitivity);
|
||||||
_hand.simulate(deltaTime, false);
|
_hand.simulate(deltaTime, false);
|
||||||
|
|
Loading…
Reference in a new issue