mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 05:28:41 +02:00
Merge pull request #3582 from PhilipRosedale/master
'Ribbons' that are driven by audio loudness and tuned/draped for mask avatars
This commit is contained in:
commit
8372975bad
9 changed files with 46 additions and 224 deletions
|
@ -26,7 +26,6 @@
|
||||||
#include "AudioSourceTone.h"
|
#include "AudioSourceTone.h"
|
||||||
#include "AudioSourceNoise.h"
|
#include "AudioSourceNoise.h"
|
||||||
#include "AudioGain.h"
|
#include "AudioGain.h"
|
||||||
#include "AudioPan.h"
|
|
||||||
#include "AudioFilter.h"
|
#include "AudioFilter.h"
|
||||||
#include "AudioFilterBank.h"
|
#include "AudioFilterBank.h"
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ BuckyBalls::BuckyBalls() {
|
||||||
colors[1] = glm::vec3(0.64f, 0.16f, 0.16f);
|
colors[1] = glm::vec3(0.64f, 0.16f, 0.16f);
|
||||||
colors[2] = glm::vec3(0.31f, 0.58f, 0.80f);
|
colors[2] = glm::vec3(0.31f, 0.58f, 0.80f);
|
||||||
|
|
||||||
qDebug("Creating buckyballs...");
|
|
||||||
for (int i = 0; i < NUM_BBALLS; i++) {
|
for (int i = 0; i < NUM_BBALLS; i++) {
|
||||||
_bballPosition[i] = CORNER_BBALLS + randVector() * RANGE_BBALLS;
|
_bballPosition[i] = CORNER_BBALLS + randVector() * RANGE_BBALLS;
|
||||||
int element = (rand() % NUM_ELEMENTS);
|
int element = (rand() % NUM_ELEMENTS);
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
|
|
||||||
const float HAIR_DAMPING = 0.99f;
|
const float HAIR_DAMPING = 0.99f;
|
||||||
const float CONSTRAINT_RELAXATION = 10.0f;
|
const float CONSTRAINT_RELAXATION = 10.0f;
|
||||||
const float HAIR_ACCELERATION_COUPLING = 0.025f;
|
const float HAIR_ACCELERATION_COUPLING = 0.045f;
|
||||||
const float HAIR_ANGULAR_VELOCITY_COUPLING = 0.01f;
|
const float HAIR_ANGULAR_VELOCITY_COUPLING = 0.020f;
|
||||||
const float HAIR_ANGULAR_ACCELERATION_COUPLING = 0.001f;
|
const float HAIR_ANGULAR_ACCELERATION_COUPLING = 0.003f;
|
||||||
const float HAIR_MAX_LINEAR_ACCELERATION = 4.0f;
|
const float HAIR_MAX_LINEAR_ACCELERATION = 4.0f;
|
||||||
const float HAIR_STIFFNESS = 0.005f;
|
const float HAIR_STIFFNESS = 0.00f;
|
||||||
const glm::vec3 HAIR_COLOR1(0.98f, 0.92f, 0.843f);
|
const glm::vec3 HAIR_COLOR1(0.98f, 0.76f, 0.075f);
|
||||||
const glm::vec3 HAIR_COLOR2(0.545f, 0.533f, 0.47f);
|
const glm::vec3 HAIR_COLOR2(0.912f, 0.184f, 0.101f);
|
||||||
|
|
||||||
Hair::Hair(int strands,
|
Hair::Hair(int strands,
|
||||||
int links,
|
int links,
|
||||||
|
@ -38,7 +38,8 @@ Hair::Hair(int strands,
|
||||||
_acceleration(0.0f),
|
_acceleration(0.0f),
|
||||||
_angularVelocity(0.0f),
|
_angularVelocity(0.0f),
|
||||||
_angularAcceleration(0.0f),
|
_angularAcceleration(0.0f),
|
||||||
_gravity(0.0f)
|
_gravity(0.0f),
|
||||||
|
_loudness()
|
||||||
{
|
{
|
||||||
_hairPosition = new glm::vec3[_strands * _links];
|
_hairPosition = new glm::vec3[_strands * _links];
|
||||||
_hairOriginalPosition = new glm::vec3[_strands * _links];
|
_hairOriginalPosition = new glm::vec3[_strands * _links];
|
||||||
|
@ -48,12 +49,15 @@ Hair::Hair(int strands,
|
||||||
_hairColors = new glm::vec3[_strands * _links];
|
_hairColors = new glm::vec3[_strands * _links];
|
||||||
_hairIsMoveable = new int[_strands * _links];
|
_hairIsMoveable = new int[_strands * _links];
|
||||||
_hairConstraints = new int[_strands * _links * HAIR_CONSTRAINTS]; // Hair can link to two others
|
_hairConstraints = new int[_strands * _links * HAIR_CONSTRAINTS]; // Hair can link to two others
|
||||||
const float FACE_WIDTH = PI / 4.0f;
|
|
||||||
glm::vec3 thisVertex;
|
glm::vec3 thisVertex;
|
||||||
for (int strand = 0; strand < _strands; strand++) {
|
for (int strand = 0; strand < _strands; strand++) {
|
||||||
float strandAngle = randFloat() * PI;
|
float strandAngle = randFloat() * PI;
|
||||||
float azimuth = FACE_WIDTH / 2.0f + (randFloat() * (2.0 * PI - FACE_WIDTH));
|
float azimuth;
|
||||||
float elevation = PI_OVER_TWO - (randFloat() * 0.75 * PI);
|
float elevation = PI_OVER_TWO - (randFloat() * 0.10f * PI);
|
||||||
|
azimuth = PI_OVER_TWO;
|
||||||
|
if (randFloat() < 0.5f) {
|
||||||
|
azimuth *= -1.0f;
|
||||||
|
}
|
||||||
glm::vec3 thisStrand(sinf(azimuth) * cosf(elevation), sinf(elevation), -cosf(azimuth) * cosf(elevation));
|
glm::vec3 thisStrand(sinf(azimuth) * cosf(elevation), sinf(elevation), -cosf(azimuth) * cosf(elevation));
|
||||||
thisStrand *= _radius;
|
thisStrand *= _radius;
|
||||||
|
|
||||||
|
@ -77,7 +81,7 @@ Hair::Hair(int strands,
|
||||||
_hairOriginalPosition[vertexIndex] = _hairLastPosition[vertexIndex] = _hairPosition[vertexIndex] = thisVertex;
|
_hairOriginalPosition[vertexIndex] = _hairLastPosition[vertexIndex] = _hairPosition[vertexIndex] = thisVertex;
|
||||||
|
|
||||||
_hairQuadDelta[vertexIndex] = glm::vec3(cos(strandAngle) * _hairThickness, 0.f, sin(strandAngle) * _hairThickness);
|
_hairQuadDelta[vertexIndex] = glm::vec3(cos(strandAngle) * _hairThickness, 0.f, sin(strandAngle) * _hairThickness);
|
||||||
_hairQuadDelta[vertexIndex] *= 1.f - ((float)link / _links);
|
_hairQuadDelta[vertexIndex] *= ((float)link / _links);
|
||||||
_hairNormals[vertexIndex] = glm::normalize(randVector());
|
_hairNormals[vertexIndex] = glm::normalize(randVector());
|
||||||
if (randFloat() < elevation / PI_OVER_TWO) {
|
if (randFloat() < elevation / PI_OVER_TWO) {
|
||||||
_hairColors[vertexIndex] = HAIR_COLOR1 * ((float)(link + 1) / (float)_links);
|
_hairColors[vertexIndex] = HAIR_COLOR1 * ((float)(link + 1) / (float)_links);
|
||||||
|
@ -114,9 +118,15 @@ void Hair::simulate(float deltaTime) {
|
||||||
_hairPosition[vertexIndex] += glm::normalize(_hairPosition[vertexIndex]) *
|
_hairPosition[vertexIndex] += glm::normalize(_hairPosition[vertexIndex]) *
|
||||||
(_radius - glm::length(_hairPosition[vertexIndex]));
|
(_radius - glm::length(_hairPosition[vertexIndex]));
|
||||||
}
|
}
|
||||||
|
// Add random thing driven by loudness
|
||||||
|
const float LOUD_BASE = 0.0005f;
|
||||||
|
float loudnessFactor = (_loudness > 0.0f) ? logf(_loudness) / 2000.0f : 0.0f;
|
||||||
|
|
||||||
|
_hairPosition[vertexIndex] += randVector() * (LOUD_BASE + loudnessFactor) * ((float)link / (float)_links);
|
||||||
|
|
||||||
// Add gravity
|
// Add gravity
|
||||||
_hairPosition[vertexIndex] += _gravity * deltaTime;
|
const float SCALE_GRAVITY = 0.10f;
|
||||||
|
_hairPosition[vertexIndex] += _gravity * deltaTime * SCALE_GRAVITY;
|
||||||
|
|
||||||
// Add linear acceleration
|
// Add linear acceleration
|
||||||
_hairPosition[vertexIndex] -= acceleration * HAIR_ACCELERATION_COUPLING * deltaTime;
|
_hairPosition[vertexIndex] -= acceleration * HAIR_ACCELERATION_COUPLING * deltaTime;
|
||||||
|
@ -179,11 +189,23 @@ void Hair::render() {
|
||||||
//
|
//
|
||||||
// Before calling this function, translate/rotate to the origin of the owning object
|
// Before calling this function, translate/rotate to the origin of the owning object
|
||||||
//
|
//
|
||||||
|
float loudnessFactor = (_loudness > 0.0f) ? logf(_loudness) / 16.0f : 0.0f;
|
||||||
|
const int SPARKLE_EVERY = 5;
|
||||||
|
const float HAIR_SETBACK = 0.125f;
|
||||||
|
int sparkleIndex = (int) (randFloat() * SPARKLE_EVERY);
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(0.f, 0.f, HAIR_SETBACK);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
for (int strand = 0; strand < _strands; strand++) {
|
for (int strand = 0; strand < _strands; strand++) {
|
||||||
for (int link = 0; link < _links - 1; link++) {
|
for (int link = 0; link < _links - 1; link++) {
|
||||||
int vertexIndex = strand * _links + link;
|
int vertexIndex = strand * _links + link;
|
||||||
glColor3fv(&_hairColors[vertexIndex].x);
|
glm::vec3 thisColor = _hairColors[vertexIndex];
|
||||||
|
if (sparkleIndex % SPARKLE_EVERY == 0) {
|
||||||
|
thisColor.x += (1.f - thisColor.x) * loudnessFactor;
|
||||||
|
thisColor.y += (1.f - thisColor.y) * loudnessFactor;
|
||||||
|
thisColor.z += (1.f - thisColor.z) * loudnessFactor;
|
||||||
|
}
|
||||||
|
glColor3fv(&thisColor.x);
|
||||||
glNormal3fv(&_hairNormals[vertexIndex].x);
|
glNormal3fv(&_hairNormals[vertexIndex].x);
|
||||||
glVertex3f(_hairPosition[vertexIndex].x - _hairQuadDelta[vertexIndex].x,
|
glVertex3f(_hairPosition[vertexIndex].x - _hairQuadDelta[vertexIndex].x,
|
||||||
_hairPosition[vertexIndex].y - _hairQuadDelta[vertexIndex].y,
|
_hairPosition[vertexIndex].y - _hairQuadDelta[vertexIndex].y,
|
||||||
|
@ -198,9 +220,11 @@ void Hair::render() {
|
||||||
glVertex3f(_hairPosition[vertexIndex + 1].x - _hairQuadDelta[vertexIndex].x,
|
glVertex3f(_hairPosition[vertexIndex + 1].x - _hairQuadDelta[vertexIndex].x,
|
||||||
_hairPosition[vertexIndex + 1].y - _hairQuadDelta[vertexIndex].y,
|
_hairPosition[vertexIndex + 1].y - _hairQuadDelta[vertexIndex].y,
|
||||||
_hairPosition[vertexIndex + 1].z - _hairQuadDelta[vertexIndex].z);
|
_hairPosition[vertexIndex + 1].z - _hairQuadDelta[vertexIndex].z);
|
||||||
|
sparkleIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,11 @@
|
||||||
|
|
||||||
const int HAIR_CONSTRAINTS = 2;
|
const int HAIR_CONSTRAINTS = 2;
|
||||||
|
|
||||||
const int DEFAULT_HAIR_STRANDS = 50;
|
const int DEFAULT_HAIR_STRANDS = 20;
|
||||||
const int DEFAULT_HAIR_LINKS = 10;
|
const int DEFAULT_HAIR_LINKS = 10;
|
||||||
const float DEFAULT_HAIR_RADIUS = 0.15f;
|
const float DEFAULT_HAIR_RADIUS = 0.15f;
|
||||||
const float DEFAULT_HAIR_LINK_LENGTH = 0.03f;
|
const float DEFAULT_HAIR_LINK_LENGTH = 0.04f;
|
||||||
const float DEFAULT_HAIR_THICKNESS = 0.015f;
|
const float DEFAULT_HAIR_THICKNESS = 0.025f;
|
||||||
|
|
||||||
class Hair {
|
class Hair {
|
||||||
public:
|
public:
|
||||||
|
@ -42,6 +42,7 @@ public:
|
||||||
void setAngularVelocity(const glm::vec3& angularVelocity) { _angularVelocity = angularVelocity; }
|
void setAngularVelocity(const glm::vec3& angularVelocity) { _angularVelocity = angularVelocity; }
|
||||||
void setAngularAcceleration(const glm::vec3& angularAcceleration) { _angularAcceleration = angularAcceleration; }
|
void setAngularAcceleration(const glm::vec3& angularAcceleration) { _angularAcceleration = angularAcceleration; }
|
||||||
void setGravity(const glm::vec3& gravity) { _gravity = gravity; }
|
void setGravity(const glm::vec3& gravity) { _gravity = gravity; }
|
||||||
|
void setLoudness(const float loudness) { _loudness = loudness; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _strands;
|
int _strands;
|
||||||
|
@ -61,7 +62,7 @@ private:
|
||||||
glm::vec3 _angularVelocity;
|
glm::vec3 _angularVelocity;
|
||||||
glm::vec3 _angularAcceleration;
|
glm::vec3 _angularAcceleration;
|
||||||
glm::vec3 _gravity;
|
glm::vec3 _gravity;
|
||||||
|
float _loudness;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,92 +37,7 @@ using namespace std;
|
||||||
#define WORKAROUND_BROKEN_GLUT_STROKES
|
#define WORKAROUND_BROKEN_GLUT_STROKES
|
||||||
// see http://www.opengl.org/resources/libraries/glut/spec3/node78.html
|
// see http://www.opengl.org/resources/libraries/glut/spec3/node78.html
|
||||||
|
|
||||||
void eulerToOrthonormals(glm::vec3 * angles, glm::vec3 * front, glm::vec3 * right, glm::vec3 * up) {
|
|
||||||
//
|
|
||||||
// Converts from three euler angles to the associated orthonormal vectors
|
|
||||||
//
|
|
||||||
// Angles contains (pitch, yaw, roll) in radians
|
|
||||||
//
|
|
||||||
|
|
||||||
// First, create the quaternion associated with these euler angles
|
|
||||||
glm::quat q(glm::vec3(angles->x, -(angles->y), angles->z));
|
|
||||||
|
|
||||||
// Next, create a rotation matrix from that quaternion
|
|
||||||
glm::mat4 rotation;
|
|
||||||
rotation = glm::mat4_cast(q);
|
|
||||||
|
|
||||||
// Transform the original vectors by the rotation matrix to get the new vectors
|
|
||||||
glm::vec4 qup(0,1,0,0);
|
|
||||||
glm::vec4 qright(-1,0,0,0);
|
|
||||||
glm::vec4 qfront(0,0,1,0);
|
|
||||||
glm::vec4 upNew = qup*rotation;
|
|
||||||
glm::vec4 rightNew = qright*rotation;
|
|
||||||
glm::vec4 frontNew = qfront*rotation;
|
|
||||||
|
|
||||||
// Copy the answers to output vectors
|
|
||||||
up->x = upNew.x; up->y = upNew.y; up->z = upNew.z;
|
|
||||||
right->x = rightNew.x; right->y = rightNew.y; right->z = rightNew.z;
|
|
||||||
front->x = frontNew.x; front->y = frontNew.y; front->z = frontNew.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printVector(glm::vec3 vec) {
|
|
||||||
qDebug("%4.2f, %4.2f, %4.2f", vec.x, vec.y, vec.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Return the azimuth angle (in radians) between two points.
|
|
||||||
float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos) {
|
|
||||||
return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the angle (in radians) between the head and an object in the scene.
|
|
||||||
// The value is zero if you are looking right at it.
|
|
||||||
// The angle is negative if the object is to your right.
|
|
||||||
float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw) {
|
|
||||||
return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z) + render_yaw + head_yaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a 3D vector floating in space
|
|
||||||
void drawVector(glm::vec3 * vector) {
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
glEnable(GL_POINT_SMOOTH);
|
|
||||||
glPointSize(3.0);
|
|
||||||
glLineWidth(2.0);
|
|
||||||
|
|
||||||
// Draw axes
|
|
||||||
glBegin(GL_LINES);
|
|
||||||
glColor3f(1,0,0);
|
|
||||||
glVertex3f(0,0,0);
|
|
||||||
glVertex3f(1,0,0);
|
|
||||||
glColor3f(0,1,0);
|
|
||||||
glVertex3f(0,0,0);
|
|
||||||
glVertex3f(0, 1, 0);
|
|
||||||
glColor3f(0,0,1);
|
|
||||||
glVertex3f(0,0,0);
|
|
||||||
glVertex3f(0, 0, 1);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Draw the vector itself
|
|
||||||
glBegin(GL_LINES);
|
|
||||||
glColor3f(1,1,1);
|
|
||||||
glVertex3f(0,0,0);
|
|
||||||
glVertex3f(vector->x, vector->y, vector->z);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Draw spheres for magnitude
|
|
||||||
glPushMatrix();
|
|
||||||
glColor3f(1,0,0);
|
|
||||||
glTranslatef(vector->x, 0, 0);
|
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(0.02f, 10, 10);
|
|
||||||
glColor3f(0,1,0);
|
|
||||||
glTranslatef(-vector->x, vector->y, 0);
|
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(0.02f, 10, 10);
|
|
||||||
glColor3f(0,0,1);
|
|
||||||
glTranslatef(0, -vector->y, vector->z);
|
|
||||||
Application::getInstance()->getGeometryCache()->renderSphere(0.02f, 10, 10);
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void renderWorldBox() {
|
void renderWorldBox() {
|
||||||
// Show edge of world
|
// Show edge of world
|
||||||
|
@ -201,10 +116,6 @@ int widthText(float scale, int mono, char const* string) {
|
||||||
return textRenderer(mono)->computeWidth(string) * (scale / 0.10);
|
return textRenderer(mono)->computeWidth(string) * (scale / 0.10);
|
||||||
}
|
}
|
||||||
|
|
||||||
float widthChar(float scale, int mono, char ch) {
|
|
||||||
return textRenderer(mono)->computeWidth(ch) * (scale / 0.10);
|
|
||||||
}
|
|
||||||
|
|
||||||
void drawText(int x, int y, float scale, float radians, int mono,
|
void drawText(int x, int y, float scale, float radians, int mono,
|
||||||
char const* string, const float* color) {
|
char const* string, const float* color) {
|
||||||
//
|
//
|
||||||
|
@ -219,29 +130,6 @@ void drawText(int x, int y, float scale, float radians, int mono,
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void drawvec3(int x, int y, float scale, float radians, float thick, int mono, glm::vec3 vec, float r, float g, float b) {
|
|
||||||
//
|
|
||||||
// Draws vec3 on screen as stroked so it can be resized
|
|
||||||
//
|
|
||||||
char vectext[20];
|
|
||||||
sprintf(vectext,"%3.1f,%3.1f,%3.1f", vec.x, vec.y, vec.z);
|
|
||||||
int len, i;
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(static_cast<float>(x), static_cast<float>(y), 0);
|
|
||||||
glColor3f(r,g,b);
|
|
||||||
glRotated(180.0 + double(radians * DEGREES_PER_RADIAN), 0.0, 0.0, 1.0);
|
|
||||||
glRotated(180.0, 0.0, 1.0, 0.0);
|
|
||||||
glLineWidth(thick);
|
|
||||||
glScalef(scale, scale, 1.f);
|
|
||||||
len = (int) strlen(vectext);
|
|
||||||
for (i = 0; i < len; i++) {
|
|
||||||
if (!mono) glutStrokeCharacter(GLUT_STROKE_ROMAN, int(vectext[i]));
|
|
||||||
else glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN, int(vectext[i]));
|
|
||||||
}
|
|
||||||
glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void renderCollisionOverlay(int width, int height, float magnitude, float red, float blue, float green) {
|
void renderCollisionOverlay(int width, int height, float magnitude, float red, float blue, float green) {
|
||||||
const float MIN_VISIBLE_COLLISION = 0.01f;
|
const float MIN_VISIBLE_COLLISION = 0.01f;
|
||||||
if (magnitude > MIN_VISIBLE_COLLISION) {
|
if (magnitude > MIN_VISIBLE_COLLISION) {
|
||||||
|
@ -255,27 +143,6 @@ void renderCollisionOverlay(int width, int height, float magnitude, float red, f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderSphereOutline(glm::vec3 position, float radius, int numSides, glm::vec3 cameraPosition) {
|
|
||||||
glm::vec3 vectorToPosition(glm::normalize(position - cameraPosition));
|
|
||||||
glm::vec3 right = glm::cross(vectorToPosition, glm::vec3(0.0f, 1.0f, 0.0f));
|
|
||||||
glm::vec3 up = glm::cross(right, vectorToPosition);
|
|
||||||
|
|
||||||
glBegin(GL_LINE_STRIP);
|
|
||||||
for (int i=0; i<numSides+1; i++) {
|
|
||||||
float r = ((float)i / (float)numSides) * TWO_PI;
|
|
||||||
float s = radius * sinf(r);
|
|
||||||
float c = radius * cosf(r);
|
|
||||||
|
|
||||||
glVertex3f
|
|
||||||
(
|
|
||||||
position.x + right.x * s + up.x * c,
|
|
||||||
position.y + right.y * s + up.y * c,
|
|
||||||
position.z + right.z * s + up.z * c
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
glEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void renderCircle(glm::vec3 position, float radius, glm::vec3 surfaceNormal, int numSides) {
|
void renderCircle(glm::vec3 position, float radius, glm::vec3 surfaceNormal, int numSides) {
|
||||||
|
@ -321,54 +188,6 @@ void renderBevelCornersRect(int x, int y, int width, int height, int bevelDistan
|
||||||
glEnd();
|
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 = (double)i * (double)PI_OVER_TWO / (double)(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) {
|
void renderOrientationDirections(glm::vec3 position, const glm::quat& orientation, float size) {
|
||||||
|
@ -395,12 +214,6 @@ void renderOrientationDirections(glm::vec3 position, const glm::quat& orientatio
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool closeEnoughForGovernmentWork(float a, float b) {
|
|
||||||
float distance = std::abs(a-b);
|
|
||||||
//qDebug("closeEnoughForGovernmentWork() a=%1.10f b=%1.10f distance=%1.10f\n",a,b,distance);
|
|
||||||
return (distance < 0.00001f);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do some basic timing tests and report the results
|
// Do some basic timing tests and report the results
|
||||||
void runTimingTests() {
|
void runTimingTests() {
|
||||||
// How long does it take to make a call to get the time?
|
// How long does it take to make a call to get the time?
|
||||||
|
|
|
@ -16,35 +16,20 @@
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
void eulerToOrthonormals(glm::vec3 * angles, glm::vec3 * fwd, glm::vec3 * left, glm::vec3 * up);
|
|
||||||
|
|
||||||
float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos);
|
|
||||||
float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw);
|
|
||||||
|
|
||||||
float randFloat();
|
float randFloat();
|
||||||
const glm::vec3 randVector();
|
const glm::vec3 randVector();
|
||||||
|
|
||||||
void renderWorldBox();
|
void renderWorldBox();
|
||||||
int widthText(float scale, int mono, char const* string);
|
int widthText(float scale, int mono, char const* string);
|
||||||
float widthChar(float scale, int mono, char ch);
|
|
||||||
|
|
||||||
void drawText(int x, int y, float scale, float radians, int mono,
|
void drawText(int x, int y, float scale, float radians, int mono,
|
||||||
char const* string, const float* color);
|
char const* string, const float* color);
|
||||||
|
|
||||||
void drawvec3(int x, int y, float scale, float radians, float thick, int mono, glm::vec3 vec,
|
|
||||||
float r=1.0, float g=1.0, float b=1.0);
|
|
||||||
|
|
||||||
void drawVector(glm::vec3* vector);
|
|
||||||
|
|
||||||
void printVector(glm::vec3 vec);
|
|
||||||
|
|
||||||
void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0);
|
void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0);
|
||||||
|
|
||||||
void renderOrientationDirections( glm::vec3 position, const glm::quat& orientation, float size );
|
void renderOrientationDirections( glm::vec3 position, const glm::quat& orientation, float size );
|
||||||
|
|
||||||
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 renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance);
|
||||||
|
|
||||||
void runTimingTests();
|
void runTimingTests();
|
||||||
|
|
|
@ -192,6 +192,7 @@ void Avatar::simulate(float deltaTime) {
|
||||||
_hair.setAngularVelocity((getAngularVelocity() + getHead()->getAngularVelocity()) * getHead()->getFinalOrientationInWorldFrame());
|
_hair.setAngularVelocity((getAngularVelocity() + getHead()->getAngularVelocity()) * getHead()->getFinalOrientationInWorldFrame());
|
||||||
_hair.setAngularAcceleration(getAngularAcceleration() * getHead()->getFinalOrientationInWorldFrame());
|
_hair.setAngularAcceleration(getAngularAcceleration() * getHead()->getFinalOrientationInWorldFrame());
|
||||||
_hair.setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()) * getHead()->getFinalOrientationInWorldFrame());
|
_hair.setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()) * getHead()->getFinalOrientationInWorldFrame());
|
||||||
|
_hair.setLoudness((float) getHeadData()->getAudioLoudness());
|
||||||
_hair.simulate(deltaTime);
|
_hair.simulate(deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,6 +218,7 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
_hair.setAngularVelocity((getAngularVelocity() + getHead()->getAngularVelocity()) * getHead()->getFinalOrientationInWorldFrame());
|
_hair.setAngularVelocity((getAngularVelocity() + getHead()->getAngularVelocity()) * getHead()->getFinalOrientationInWorldFrame());
|
||||||
_hair.setAngularAcceleration(getAngularAcceleration() * getHead()->getFinalOrientationInWorldFrame());
|
_hair.setAngularAcceleration(getAngularAcceleration() * getHead()->getFinalOrientationInWorldFrame());
|
||||||
_hair.setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()) * getHead()->getFinalOrientationInWorldFrame());
|
_hair.setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()) * getHead()->getFinalOrientationInWorldFrame());
|
||||||
|
_hair.setLoudness((float)getHeadData()->getAudioLoudness());
|
||||||
_hair.simulate(deltaTime);
|
_hair.simulate(deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,5 @@
|
||||||
#define hifi_world_h
|
#define hifi_world_h
|
||||||
|
|
||||||
const float GRAVITY_EARTH = 9.80665f;
|
const float GRAVITY_EARTH = 9.80665f;
|
||||||
const float EDGE_SIZE_GROUND_PLANE = 20.f;
|
|
||||||
|
|
||||||
#endif // hifi_world_h
|
#endif // hifi_world_h
|
||||||
|
|
Loading…
Reference in a new issue