mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 21:30:33 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into metavoxels
This commit is contained in:
commit
84698bc98d
3 changed files with 88 additions and 16 deletions
|
@ -554,6 +554,78 @@ void renderCircle(glm::vec3 position, float radius, glm::vec3 surfaceNormal, int
|
|||
}
|
||||
|
||||
|
||||
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance) {
|
||||
glBegin(GL_POLYGON);
|
||||
|
||||
// left side
|
||||
glVertex2f(x, y + bevelDistance);
|
||||
glVertex2f(x, y + height - bevelDistance);
|
||||
|
||||
// top side
|
||||
glVertex2f(x + bevelDistance, y + height);
|
||||
glVertex2f(x + width - bevelDistance, y + height);
|
||||
|
||||
// right
|
||||
glVertex2f(x + width, y + height - bevelDistance);
|
||||
glVertex2f(x + width, y + bevelDistance);
|
||||
|
||||
// bottom
|
||||
glVertex2f(x + width - bevelDistance, y);
|
||||
glVertex2f(x +bevelDistance, y);
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void renderRoundedCornersRect(int x, int y, int width, int height, int radius, int numPointsCorner) {
|
||||
#define MAX_POINTS_CORNER 50
|
||||
// At least "2" is needed
|
||||
if (numPointsCorner <= 1) {
|
||||
return;
|
||||
}
|
||||
if (numPointsCorner > MAX_POINTS_CORNER) {
|
||||
numPointsCorner = MAX_POINTS_CORNER;
|
||||
}
|
||||
|
||||
// Precompute sin and cos for [0, pi/2) for the number of points (numPointCorner)
|
||||
double radiusTimesSin[MAX_POINTS_CORNER];
|
||||
double radiusTimesCos[MAX_POINTS_CORNER];
|
||||
int i = 0;
|
||||
for (int i = 0; i < numPointsCorner; i++) {
|
||||
double t = i * PIf / (2.0f * (numPointsCorner - 1));
|
||||
radiusTimesSin[i] = radius * sin(t);
|
||||
radiusTimesCos[i] = radius * cos(t);
|
||||
}
|
||||
|
||||
glm::dvec2 cornerCenter;
|
||||
glBegin(GL_POINTS);
|
||||
|
||||
// Top left corner
|
||||
cornerCenter = glm::vec2(x + radius, y + height - radius);
|
||||
for (i = 0; i < numPointsCorner; i++) {
|
||||
glVertex2d(cornerCenter.x - radiusTimesCos[i], cornerCenter.y + radiusTimesSin[i]);
|
||||
}
|
||||
|
||||
// Top rigth corner
|
||||
cornerCenter = glm::vec2(x + width - radius, y + height - radius);
|
||||
for (i = 0; i < numPointsCorner; i++) {
|
||||
glVertex2d(cornerCenter.x + radiusTimesSin[i], cornerCenter.y + radiusTimesCos[i]);
|
||||
}
|
||||
|
||||
// Bottom right
|
||||
cornerCenter = glm::vec2(x + width - radius, y + radius);
|
||||
for (i = 0; i < numPointsCorner; i++) {
|
||||
glVertex2d(cornerCenter.x + radiusTimesCos[i], cornerCenter.y - radiusTimesSin[i]);
|
||||
}
|
||||
|
||||
// Bottom left
|
||||
cornerCenter = glm::vec2(x + radius, y + radius);
|
||||
for (i = 0; i < numPointsCorner; i++) {
|
||||
glVertex2d(cornerCenter.x - radiusTimesSin[i], cornerCenter.y - radiusTimesCos[i]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
void renderOrientationDirections(glm::vec3 position, const glm::quat& orientation, float size) {
|
||||
glm::vec3 pRight = position + orientation * IDENTITY_RIGHT * size;
|
||||
glm::vec3 pUp = position + orientation * IDENTITY_UP * size;
|
||||
|
|
|
@ -73,6 +73,8 @@ void renderOrientationDirections( glm::vec3 position, const glm::quat& orientati
|
|||
|
||||
void renderSphereOutline(glm::vec3 position, float radius, int numSides, glm::vec3 cameraPosition);
|
||||
void renderCircle(glm::vec3 position, float radius, glm::vec3 surfaceNormal, int numSides );
|
||||
void renderRoundedCornersRect(int x, int y, int width, int height, int radius, int numPointsCorner);
|
||||
void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance);
|
||||
|
||||
void runTimingTests();
|
||||
|
||||
|
|
|
@ -207,18 +207,23 @@ void Avatar::render() {
|
|||
renderBody();
|
||||
}
|
||||
|
||||
// render sphere when far away
|
||||
const float MAX_ANGLE = 10.f;
|
||||
// render voice intensity sphere for avatars that are farther away
|
||||
const float MAX_SPHERE_ANGLE = 10.f;
|
||||
const float MIN_SPHERE_ANGLE = 1.f;
|
||||
const float MIN_SPHERE_SIZE = 0.01;
|
||||
const float SPHERE_LOUDNESS_SCALING = 0.0005f;
|
||||
const float SPHERE_COLOR[] = { 0.5f, 0.8f, 0.8f };
|
||||
float height = getSkeletonHeight();
|
||||
glm::vec3 delta = height * (getHead()->getCameraOrientation() * IDENTITY_UP) / 2.f;
|
||||
float angle = abs(angleBetween(toTarget + delta, toTarget - delta));
|
||||
|
||||
if (angle < MAX_ANGLE) {
|
||||
glColor4f(0.5f, 0.8f, 0.8f, 1.f - angle / MAX_ANGLE);
|
||||
float sphereRadius = getHead()->getAverageLoudness() * SPHERE_LOUDNESS_SCALING;
|
||||
|
||||
if ((sphereRadius > MIN_SPHERE_SIZE) && (angle < MAX_SPHERE_ANGLE) && (angle > MIN_SPHERE_ANGLE)) {
|
||||
glColor4f(SPHERE_COLOR[0], SPHERE_COLOR[1], SPHERE_COLOR[2], 1.f - angle / MAX_SPHERE_ANGLE);
|
||||
glPushMatrix();
|
||||
glTranslatef(_position.x, _position.y, _position.z);
|
||||
glScalef(height / 2.f, height / 2.f, height / 2.f);
|
||||
glutSolidSphere(1.2f + getHead()->getAverageLoudness() * .0005f, 20, 20);
|
||||
glScalef(height, height, height);
|
||||
glutSolidSphere(sphereRadius, 15, 15);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -424,16 +429,9 @@ void Avatar::renderDisplayName() {
|
|||
glPolygonOffset(1.0f, 1.0f);
|
||||
|
||||
glColor4f(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(left, bottom);
|
||||
glVertex2f(right, bottom);
|
||||
glVertex2f(right, top);
|
||||
glVertex2f(left, top);
|
||||
glEnd();
|
||||
|
||||
|
||||
renderBevelCornersRect(left, bottom, right - left, top - bottom, 3);
|
||||
|
||||
glColor4f(0.93f, 0.93f, 0.93f, _displayNameAlpha);
|
||||
|
||||
QByteArray ba = _displayName.toLocal8Bit();
|
||||
const char* text = ba.data();
|
||||
|
||||
|
|
Loading…
Reference in a new issue