mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 20:44:14 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
6164e6cd7e
4 changed files with 18 additions and 23 deletions
|
@ -74,7 +74,6 @@ Avatar::Avatar(Agent* owningAgent) :
|
|||
_bodyRollDelta(0.0f),
|
||||
_movedHandOffset(0.0f, 0.0f, 0.0f),
|
||||
_mode(AVATAR_MODE_STANDING),
|
||||
_cameraPosition(0.0f, 0.0f, 0.0f),
|
||||
_handHoldingPosition(0.0f, 0.0f, 0.0f),
|
||||
_velocity(0.0f, 0.0f, 0.0f),
|
||||
_thrust(0.0f, 0.0f, 0.0f),
|
||||
|
@ -578,7 +577,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
// set head lookat position
|
||||
if (!_owningAgent) {
|
||||
if (_interactingOther) {
|
||||
_head.setLookAtPosition(_interactingOther->caclulateAverageEyePosition());
|
||||
_head.setLookAtPosition(_interactingOther->calculateAverageEyePosition());
|
||||
} else {
|
||||
_head.setLookAtPosition(glm::vec3(0.0f, 0.0f, 0.0f)); // 0,0,0 represents NOT looking at anything
|
||||
}
|
||||
|
@ -908,9 +907,7 @@ void Avatar::setGravity(glm::vec3 gravity) {
|
|||
}
|
||||
|
||||
void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) {
|
||||
|
||||
_cameraPosition = Application::getInstance()->getCamera()->getPosition();
|
||||
|
||||
|
||||
if (!_owningAgent && usingBigSphereCollisionTest) {
|
||||
// show TEST big sphere
|
||||
glColor4f(0.5f, 0.6f, 0.8f, 0.7);
|
||||
|
@ -929,7 +926,7 @@ void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) {
|
|||
|
||||
// if this is my avatar, then render my interactions with the other avatar
|
||||
if (!_owningAgent) {
|
||||
_avatarTouch.render(getCameraPosition());
|
||||
_avatarTouch.render(Application::getInstance()->getCamera()->getPosition());
|
||||
}
|
||||
|
||||
// Render the balls
|
||||
|
@ -1128,17 +1125,15 @@ glm::quat Avatar::computeRotationFromBodyToWorldUp(float proportion) const {
|
|||
}
|
||||
|
||||
float Avatar::getBallRenderAlpha(int ball, bool lookingInMirror) const {
|
||||
const float RENDER_OPAQUE_BEYOND = 1.0f; // Meters beyond which body is shown opaque
|
||||
const float RENDER_TRANSLUCENT_BEYOND = 0.5f;
|
||||
float distanceToCamera = glm::length(_cameraPosition - _bodyBall[ball].position);
|
||||
const float RENDER_OPAQUE_OUTSIDE = 1.25f; // render opaque if greater than this distance
|
||||
const float DO_NOT_RENDER_INSIDE = 0.75f; // do not render if less than this distance
|
||||
float distanceToCamera = glm::length(Application::getInstance()->getCamera()->getPosition() - _bodyBall[ball].position);
|
||||
return (lookingInMirror || _owningAgent) ? 1.0f : glm::clamp(
|
||||
(distanceToCamera - RENDER_TRANSLUCENT_BEYOND) / (RENDER_OPAQUE_BEYOND - RENDER_TRANSLUCENT_BEYOND), 0.f, 1.f);
|
||||
(distanceToCamera - DO_NOT_RENDER_INSIDE) / (RENDER_OPAQUE_OUTSIDE - DO_NOT_RENDER_INSIDE), 0.f, 1.f);
|
||||
}
|
||||
|
||||
void Avatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) {
|
||||
|
||||
|
||||
|
||||
// Render the body as balls and cones
|
||||
if (renderAvatarBalls || !_voxels.getVoxelURL().isValid()) {
|
||||
for (int b = 0; b < NUM_AVATAR_BODY_BALLS; b++) {
|
||||
|
@ -1147,7 +1142,7 @@ void Avatar::renderBody(bool lookingInMirror, bool renderAvatarBalls) {
|
|||
// Always render other people, and render myself when beyond threshold distance
|
||||
if (b == BODY_BALL_HEAD_BASE) { // the head is rendered as a special
|
||||
if (alpha > 0.0f) {
|
||||
_head.render(lookingInMirror, _cameraPosition, alpha);
|
||||
_head.render(lookingInMirror, alpha);
|
||||
}
|
||||
} else if (alpha > 0.0f) {
|
||||
// Render the body ball sphere
|
||||
|
|
|
@ -178,7 +178,6 @@ private:
|
|||
glm::vec3 _movedHandOffset;
|
||||
AvatarBall _bodyBall[ NUM_AVATAR_BODY_BALLS ];
|
||||
AvatarMode _mode;
|
||||
glm::vec3 _cameraPosition;
|
||||
glm::vec3 _handHoldingPosition;
|
||||
glm::vec3 _velocity;
|
||||
glm::vec3 _thrust;
|
||||
|
@ -203,7 +202,7 @@ private:
|
|||
AvatarVoxelSystem _voxels;
|
||||
|
||||
// private methods...
|
||||
glm::vec3 caclulateAverageEyePosition() { return _head.caclulateAverageEyePosition(); } // get the position smack-dab between the eyes (for lookat)
|
||||
glm::vec3 calculateAverageEyePosition() { return _head.calculateAverageEyePosition(); } // get the position smack-dab between the eyes (for lookat)
|
||||
glm::quat computeRotationFromBodyToWorldUp(float proportion = 1.0f) const;
|
||||
float getBallRenderAlpha(int ball, bool lookingInMirror) const;
|
||||
void renderBody(bool lookingInMirror, bool renderAvatarBalls);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include "Application.h"
|
||||
#include "Avatar.h"
|
||||
#include "Head.h"
|
||||
#include "Util.h"
|
||||
|
@ -161,7 +162,7 @@ void Head::determineIfLookingAtSomething() {
|
|||
if ( fabs(_lookAtPosition.x + _lookAtPosition.y + _lookAtPosition.z) == 0.0 ) { // a lookatPosition of 0,0,0 signifies NOT looking
|
||||
_lookingAtSomething = false;
|
||||
} else {
|
||||
glm::vec3 targetLookatAxis = glm::normalize(_lookAtPosition - caclulateAverageEyePosition());
|
||||
glm::vec3 targetLookatAxis = glm::normalize(_lookAtPosition - calculateAverageEyePosition());
|
||||
float dot = glm::dot(targetLookatAxis, getFrontDirection());
|
||||
if (dot < MINIMUM_EYE_ROTATION_DOT) { // too far off from center for the eyes to rotate
|
||||
_lookingAtSomething = false;
|
||||
|
@ -202,7 +203,7 @@ void Head::calculateGeometry() {
|
|||
}
|
||||
|
||||
|
||||
void Head::render(bool lookingInMirror, glm::vec3 cameraPosition, float alpha) {
|
||||
void Head::render(bool lookingInMirror, float alpha) {
|
||||
|
||||
_renderAlpha = alpha;
|
||||
_lookingInMirror = lookingInMirror;
|
||||
|
@ -212,7 +213,7 @@ void Head::render(bool lookingInMirror, glm::vec3 cameraPosition, float alpha) {
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
|
||||
renderMohawk(cameraPosition);
|
||||
renderMohawk();
|
||||
renderHeadSphere();
|
||||
renderEyeBalls();
|
||||
renderEars();
|
||||
|
@ -256,7 +257,7 @@ void Head::createMohawk() {
|
|||
}
|
||||
}
|
||||
|
||||
void Head::renderMohawk(glm::vec3 cameraPosition) {
|
||||
void Head::renderMohawk() {
|
||||
|
||||
if (!_mohawkTriangleFan) {
|
||||
createMohawk();
|
||||
|
@ -267,7 +268,7 @@ void Head::renderMohawk(glm::vec3 cameraPosition) {
|
|||
|
||||
glm::vec3 baseAxis = _hairTuft[t].midPosition - _hairTuft[t].basePosition;
|
||||
glm::vec3 midAxis = _hairTuft[t].endPosition - _hairTuft[t].midPosition;
|
||||
glm::vec3 viewVector = _hairTuft[t].basePosition - cameraPosition;
|
||||
glm::vec3 viewVector = _hairTuft[t].basePosition - Application::getInstance()->getCamera()->getPosition();
|
||||
|
||||
glm::vec3 basePerpendicular = glm::normalize(glm::cross(baseAxis, viewVector));
|
||||
glm::vec3 midPerpendicular = glm::normalize(glm::cross(midAxis, viewVector));
|
||||
|
|
|
@ -33,8 +33,8 @@ public:
|
|||
|
||||
void reset();
|
||||
void simulate(float deltaTime, bool isMine);
|
||||
void render(bool lookingInMirror, glm::vec3 cameraPosition, float alpha);
|
||||
void renderMohawk(glm::vec3 cameraPosition);
|
||||
void render(bool lookingInMirror, float alpha);
|
||||
void renderMohawk();
|
||||
|
||||
void setScale (float scale ) { _scale = scale; }
|
||||
void setPosition (glm::vec3 position ) { _position = position; }
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
const bool getReturnToCenter() const { return _returnHeadToCenter; } // Do you want head to try to return to center (depends on interface detected)
|
||||
float getAverageLoudness() {return _averageLoudness;};
|
||||
glm::vec3 caclulateAverageEyePosition() { return _leftEyePosition + (_rightEyePosition - _leftEyePosition ) * ONE_HALF; }
|
||||
glm::vec3 calculateAverageEyePosition() { return _leftEyePosition + (_rightEyePosition - _leftEyePosition ) * ONE_HALF; }
|
||||
|
||||
float yawRate;
|
||||
float noise;
|
||||
|
|
Loading…
Reference in a new issue