mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
Enlarge heads when they're moused over.
This commit is contained in:
parent
3ccf276137
commit
4dec183262
3 changed files with 27 additions and 5 deletions
|
@ -1596,10 +1596,14 @@ 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;
|
||||
|
||||
|
||||
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) {
|
||||
|
||||
|
@ -1748,7 +1752,7 @@ void Application::update(float deltaTime) {
|
|||
_faceshift.getEstimatedEyePitch(), _faceshift.getEstimatedEyeYaw(), 0.0f))) * glm::vec3(0.0f, 0.0f, -1.0f);
|
||||
}
|
||||
|
||||
_lookatTargetAvatar = findLookatTargetAvatar(lookAtRayOrigin, lookAtRayDirection, lookAtSpot);
|
||||
updateLookatTargetAvatar(lookAtRayOrigin, lookAtRayDirection, lookAtSpot);
|
||||
if (_lookatTargetAvatar) {
|
||||
// If the mouse is over another avatar's head...
|
||||
_myAvatar.getHead().setLookAtPosition(lookAtSpot);
|
||||
|
@ -2070,7 +2074,7 @@ void Application::updateAvatar(float deltaTime) {
|
|||
_viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
|
||||
|
||||
glm::vec3 eyePosition;
|
||||
_lookatTargetAvatar = findLookatTargetAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
|
||||
updateLookatTargetAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition);
|
||||
if (_lookatTargetAvatar) {
|
||||
glm::vec3 myLookAtFromMouse(eyePosition);
|
||||
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
|
||||
|
@ -3415,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,6 +197,9 @@ private:
|
|||
void init();
|
||||
|
||||
void update(float deltaTime);
|
||||
|
||||
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);
|
||||
|
|
|
@ -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