mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +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),
|
||||
_lookingAlongX(false),
|
||||
_lookingAwayFromOrigin(true),
|
||||
_isLookingAtOtherAvatar(false),
|
||||
_lookatTargetAvatar(NULL),
|
||||
_lookatIndicatorScale(1.0f),
|
||||
_perfStatsOn(false),
|
||||
_chatEntryOn(false),
|
||||
|
@ -974,7 +974,7 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
|||
|
||||
maybeEditVoxelUnderCursor();
|
||||
|
||||
if (!_palette.isActive() && (!_isHoverVoxel || _isLookingAtOtherAvatar)) {
|
||||
if (!_palette.isActive() && (!_isHoverVoxel || _lookatTargetAvatar)) {
|
||||
_pieMenu.mousePressEvent(_mouseX, _mouseY);
|
||||
}
|
||||
|
||||
|
@ -1503,7 +1503,7 @@ void Application::setListenModeSingleSource() {
|
|||
glm::vec3 eyePositionIgnored;
|
||||
uint16_t nodeID;
|
||||
|
||||
if (isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) {
|
||||
if (findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeID)) {
|
||||
_audio.addListenSource(nodeID);
|
||||
}
|
||||
}
|
||||
|
@ -1596,12 +1596,16 @@ const float MAX_AVATAR_EDIT_VELOCITY = 1.0f;
|
|||
const float MAX_VOXEL_EDIT_DISTANCE = 20.0f;
|
||||
const float HEAD_SPHERE_RADIUS = 0.07;
|
||||
|
||||
|
||||
static uint16_t DEFAULT_NODE_ID_REF = 1;
|
||||
|
||||
|
||||
Avatar* Application::isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
||||
glm::vec3& eyePosition, uint16_t& nodeID = DEFAULT_NODE_ID_REF) {
|
||||
void Application::updateLookatTargetAvatar(const glm::vec3& mouseRayOrigin, const glm::vec3& mouseRayDirection,
|
||||
glm::vec3& eyePosition) {
|
||||
|
||||
_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) {
|
||||
|
||||
NodeList* nodeList = NodeList::getInstance();
|
||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||
|
@ -1748,8 +1752,8 @@ void Application::update(float deltaTime) {
|
|||
_faceshift.getEstimatedEyePitch(), _faceshift.getEstimatedEyeYaw(), 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f);
|
||||
}
|
||||
|
||||
_isLookingAtOtherAvatar = isLookingAtOtherAvatar(lookAtRayOrigin, lookAtRayDirection, lookAtSpot);
|
||||
if (_isLookingAtOtherAvatar) {
|
||||
updateLookatTargetAvatar(lookAtRayOrigin, lookAtRayDirection, lookAtSpot);
|
||||
if (_lookatTargetAvatar) {
|
||||
// If the mouse is over another avatar's head...
|
||||
_myAvatar.getHead().setLookAtPosition(lookAtSpot);
|
||||
} else if (_isHoverVoxel && !_faceshift.isActive()) {
|
||||
|
@ -2063,15 +2067,15 @@ void Application::updateAvatar(float deltaTime) {
|
|||
const float MIDPOINT_OF_SCREEN = 0.5;
|
||||
|
||||
// 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
|
||||
glm::vec3 screenCenterRayOrigin, screenCenterRayDirection;
|
||||
_viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
|
||||
|
||||
glm::vec3 eyePosition;
|
||||
_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
|
||||
if (_isLookingAtOtherAvatar) {
|
||||
updateLookatTargetAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
|
||||
if (_lookatTargetAvatar) {
|
||||
glm::vec3 myLookAtFromMouse(eyePosition);
|
||||
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
||||
}
|
||||
|
@ -2540,7 +2544,7 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
Menu::getInstance()->isOptionChecked(MenuOption::AvatarAsBalls));
|
||||
_myAvatar.setDisplayingLookatVectors(Menu::getInstance()->isOptionChecked(MenuOption::LookAtVectors));
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::LookAtIndicator) && _isLookingAtOtherAvatar) {
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::LookAtIndicator) && _lookatTargetAvatar) {
|
||||
renderLookatIndicator(_lookatOtherPosition, whichCamera);
|
||||
}
|
||||
}
|
||||
|
@ -3342,10 +3346,7 @@ void Application::toggleFollowMode() {
|
|||
mouseRayOrigin, mouseRayDirection);
|
||||
glm::vec3 eyePositionIgnored;
|
||||
uint16_t nodeIDIgnored;
|
||||
Avatar* leadingAvatar = isLookingAtOtherAvatar(mouseRayOrigin,
|
||||
mouseRayDirection,
|
||||
eyePositionIgnored,
|
||||
nodeIDIgnored);
|
||||
Avatar* leadingAvatar = findLookatTargetAvatar(mouseRayOrigin, mouseRayDirection, eyePositionIgnored, nodeIDIgnored);
|
||||
|
||||
_myAvatar.follow(leadingAvatar);
|
||||
}
|
||||
|
@ -3418,6 +3419,8 @@ void Application::nodeKilled(Node* node) {
|
|||
fade.voxelDetails.s = fade.voxelDetails.s * slightly_smaller;
|
||||
_voxelFades.push_back(fade);
|
||||
}
|
||||
} else if (node->getLinkedData() == _lookatTargetAvatar) {
|
||||
_lookatTargetAvatar = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,6 +130,8 @@ public:
|
|||
TextureCache* getTextureCache() { return &_textureCache; }
|
||||
GlowEffect* getGlowEffect() { return &_glowEffect; }
|
||||
|
||||
Avatar* getLookatTargetAvatar() const { return _lookatTargetAvatar; }
|
||||
|
||||
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
const char* nodeTypes, int numNodeTypes);
|
||||
|
||||
|
@ -195,8 +197,11 @@ private:
|
|||
void init();
|
||||
|
||||
void update(float deltaTime);
|
||||
Avatar* isLookingAtOtherAvatar(glm::vec3& mouseRayOrigin, glm::vec3& mouseRayDirection,
|
||||
glm::vec3& eyePosition, uint16_t& nodeID);
|
||||
|
||||
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);
|
||||
bool isLookingAtMyAvatar(Avatar* avatar);
|
||||
|
||||
void renderLookatIndicator(glm::vec3 pointOfInterest, Camera& whichCamera);
|
||||
|
@ -315,7 +320,7 @@ private:
|
|||
bool _lookingAwayFromOrigin;
|
||||
glm::vec3 _nudgeGuidePosition;
|
||||
|
||||
bool _isLookingAtOtherAvatar;
|
||||
Avatar* _lookatTargetAvatar;
|
||||
glm::vec3 _lookatOtherPosition;
|
||||
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.setPosition(_bodyBall[ BODY_BALL_HEAD_BASE ].position);
|
||||
_head.setScale(_scale);
|
||||
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
||||
_head.simulate(deltaTime, false, gyroCameraSensitivity);
|
||||
_hand.simulate(deltaTime, false);
|
||||
|
|
Loading…
Reference in a new issue