mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 15:11:10 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
8c71741843
14 changed files with 273 additions and 131 deletions
|
@ -153,8 +153,8 @@ Application::Application(int& argc, char** argv) :
|
|||
_packetCount(0),
|
||||
_packetsPerSecond(0),
|
||||
_bytesPerSecond(0),
|
||||
_bytesCount(0) {
|
||||
|
||||
_bytesCount(0)
|
||||
{
|
||||
gettimeofday(&_applicationStartupTime, NULL);
|
||||
printLog("Interface Startup:\n");
|
||||
|
||||
|
@ -170,7 +170,9 @@ Application::Application(int& argc, char** argv) :
|
|||
if (portStr) {
|
||||
listenPort = atoi(portStr);
|
||||
}
|
||||
|
||||
AgentList::createInstance(AGENT_TYPE_AVATAR, listenPort);
|
||||
|
||||
_enableNetworkThread = !cmdOptionExists(argc, constArgv, "--nonblocking");
|
||||
if (!_enableNetworkThread) {
|
||||
AgentList::getInstance()->getAgentSocket()->setBlocking(false);
|
||||
|
@ -305,7 +307,6 @@ void Application::paintGL() {
|
|||
_myCamera.setTargetRotation(_myAvatar.getBodyYaw() - 180.0f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
|
||||
} else {
|
||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
|
||||
|
|
|
@ -188,6 +188,7 @@ private:
|
|||
Oscilloscope _audioScope;
|
||||
|
||||
Avatar _myAvatar; // The rendered avatar of oneself
|
||||
|
||||
Camera _myCamera; // My view onto the world
|
||||
Camera _viewFrustumOffsetCamera; // The camera we use to sometimes show the view frustum from an offset mode
|
||||
|
||||
|
|
|
@ -50,14 +50,16 @@ const float PERIPERSONAL_RADIUS = 1.0f;
|
|||
const float AVATAR_BRAKING_STRENGTH = 40.0f;
|
||||
const float JOINT_TOUCH_RANGE = 0.0005f;
|
||||
|
||||
float skinColor [] = {1.0, 0.84, 0.66};
|
||||
float lightBlue [] = {0.7, 0.8, 1.0};
|
||||
float skinColor [] = {1.0, 0.84, 0.66};
|
||||
float darkSkinColor[] = {0.8, 0.74, 0.6 };
|
||||
float lightBlue [] = {0.7, 0.8, 1.0 };
|
||||
|
||||
bool usingBigSphereCollisionTest = true;
|
||||
|
||||
float chatMessageScale = 0.0015;
|
||||
float chatMessageHeight = 0.45;
|
||||
|
||||
|
||||
Avatar::Avatar(bool isMine) {
|
||||
_orientation.setToIdentity();
|
||||
|
||||
|
@ -393,17 +395,20 @@ void Avatar::simulate(float deltaTime) {
|
|||
_joint[ AVATAR_JOINT_HEAD_BASE ].radius
|
||||
);
|
||||
|
||||
_head.setBodyYaw(_bodyYaw);
|
||||
|
||||
//the following is still being prototyped (making the eyes look at a specific location), it should be finished by 5/20/13
|
||||
setLookatPosition(glm::vec3(0.0f, 0.0f, 0.0f)); //default lookat position is 0,0,0
|
||||
|
||||
if (_interactingOther) {
|
||||
_head.setLooking(true);
|
||||
_head.setLookatPosition(_interactingOther->getSpringyHeadPosition());
|
||||
//_head.setLookatPosition(_interactingOther->getApproximateEyePosition());
|
||||
|
||||
if (_isMine) {
|
||||
setLookatPosition(_interactingOther->getSpringyHeadPosition());
|
||||
}
|
||||
} else {
|
||||
_head.setLooking(false);
|
||||
}
|
||||
|
||||
|
||||
_head.setBodyYaw(_bodyYaw);
|
||||
_head.setLookatPosition(_lookatPosition);
|
||||
_head.setAudioLoudness(_audioLoudness);
|
||||
_head.setSkinColor(glm::vec3(skinColor[0], skinColor[1], skinColor[2]));
|
||||
_head.simulate(deltaTime, _isMine);
|
||||
|
@ -692,19 +697,6 @@ void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) {
|
|||
|
||||
_cameraPosition = cameraPosition; // store this for use in various parts of the code
|
||||
|
||||
// render a simple round on the ground projected down from the avatar's position
|
||||
renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), 0.1f, 0.2f);
|
||||
|
||||
/*
|
||||
// show avatar position
|
||||
glColor4f(0.5f, 0.5f, 0.5f, 0.6);
|
||||
glPushMatrix();
|
||||
glTranslatef(_position.x, _position.y, _position.z);
|
||||
glScalef(0.03, 0.03, 0.03);
|
||||
glutSolidSphere(1, 10, 10);
|
||||
glPopMatrix();
|
||||
*/
|
||||
|
||||
if (usingBigSphereCollisionTest) {
|
||||
// show TEST big sphere
|
||||
glColor4f(0.5f, 0.6f, 0.8f, 0.7);
|
||||
|
@ -715,10 +707,12 @@ void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
// render a simple round on the ground projected down from the avatar's position
|
||||
renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), 0.1f, 0.2f);
|
||||
|
||||
//render body
|
||||
renderBody(lookingInMirror);
|
||||
|
||||
|
||||
// if this is my avatar, then render my interactions with the other avatar
|
||||
if (_isMine) {
|
||||
_avatarTouch.render(_cameraPosition);
|
||||
|
@ -1039,10 +1033,12 @@ void Avatar::updateBodySprings(float deltaTime) {
|
|||
_joint[b].springyVelocity = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
/*
|
||||
//apply forces from touch...
|
||||
if (_joint[b].touchForce > 0.0) {
|
||||
_joint[b].springyVelocity += _mouseRayDirection * _joint[b].touchForce * 0.7f;
|
||||
}
|
||||
*/
|
||||
|
||||
//update position by velocity...
|
||||
_joint[b].springyPosition += _joint[b].springyVelocity * deltaTime;
|
||||
|
@ -1133,14 +1129,27 @@ void Avatar::renderBody(bool lookingInMirror) {
|
|||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
// Render lines connecting the joint positions
|
||||
glColor3f(0.4f, 0.5f, 0.6f);
|
||||
glLineWidth(3.0);
|
||||
|
||||
for (int b = 1; b < NUM_AVATAR_JOINTS; b++) {
|
||||
if (_joint[b].parent != AVATAR_JOINT_NULL)
|
||||
if (b != AVATAR_JOINT_HEAD_TOP) {
|
||||
|
||||
/*
|
||||
// Render cone sections connecting the joint positions
|
||||
glColor3fv(darkSkinColor);
|
||||
renderJointConnectingCone
|
||||
(
|
||||
_joint[_joint[b].parent ].springyPosition,
|
||||
_joint[b ].springyPosition,
|
||||
_joint[_joint[b].parent ].radius,
|
||||
_joint[b ].radius
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
// Render lines connecting the joint positions
|
||||
glColor3f(0.4f, 0.5f, 0.6f);
|
||||
glLineWidth(3.0);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(&_joint[ _joint[ b ].parent ].springyPosition.x);
|
||||
glVertex3fv(&_joint[ b ].springyPosition.x);
|
||||
|
@ -1378,3 +1387,47 @@ void Avatar::readAvatarDataFromFile() {
|
|||
fclose(avatarFile);
|
||||
}
|
||||
}
|
||||
|
||||
void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2) {
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
int num = 5;
|
||||
|
||||
glm::vec3 axis = glm::normalize(position2 - position1);
|
||||
float length = glm::length(axis);
|
||||
|
||||
if (length > 0.0f) {
|
||||
|
||||
glm::vec3 perpSin = glm::vec3(axis.y, axis.z, axis.x);
|
||||
glm::vec3 perpCos = glm::vec3(axis.z, axis.x, axis.y);
|
||||
|
||||
for (int i = 0; i < num; i ++) {
|
||||
|
||||
float angle1 = ((float)i / (float)num) * PI * 2.0;
|
||||
float angle2 = ((float)(i+1) / (float)num) * PI * 2.0;
|
||||
|
||||
glm::vec3 p1a = position1 + perpSin * sin(angle1) * radius1;
|
||||
glm::vec3 p1b = position1 + perpCos * cos(angle2) * radius1;
|
||||
|
||||
glm::vec3 p2a = position2 + perpSin * sin(angle1) * radius2;
|
||||
glm::vec3 p2b = position2 + perpCos * cos(angle2) * radius2;
|
||||
|
||||
glVertex3f(p1a.x, p1a.y, p1a.z);
|
||||
glVertex3f(p1b.x, p1b.y, p1b.z);
|
||||
glVertex3f(p2a.x, p2a.y, p2a.z);
|
||||
|
||||
/*
|
||||
glVertex3f(p1b.x, p1b.y, p1b.z);
|
||||
glVertex3f(p2a.x, p2a.y, p2a.z);
|
||||
glVertex3f(p2b.x, p2b.y, p2b.z);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <Orientation.h>
|
||||
#include "world.h"
|
||||
#include "AvatarTouch.h"
|
||||
#include "AvatarRenderer.h"
|
||||
#include "InterfaceConfig.h"
|
||||
#include "SerialInterface.h"
|
||||
#include "Balls.h"
|
||||
|
@ -217,6 +218,7 @@ private:
|
|||
void applyCollisionWithOtherAvatar( Avatar * other, float deltaTime );
|
||||
void setHeadFromGyros(glm::vec3 * eulerAngles, glm::vec3 * angularVelocity, float deltaTime, float smoothingTime);
|
||||
void checkForMouseRayTouching();
|
||||
void renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2, float radius1, float radius2);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,54 +10,61 @@
|
|||
#include "AvatarRenderer.h"
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
/*
|
||||
AvatarRenderer::AvatarRenderer() {
|
||||
}
|
||||
|
||||
// this method renders the avatar
|
||||
void AvatarRenderer::render(Avatar *avatarToRender, bool lookingInMirror, glm::vec3 cameraPosition) {
|
||||
void AvatarRenderer::render() {
|
||||
|
||||
avatar = avatarToRender;
|
||||
|
||||
/*
|
||||
// show avatar position
|
||||
glColor4f(0.5f, 0.5f, 0.5f, 0.6);
|
||||
glPushMatrix();
|
||||
glm::vec3 j( avatar->getJointPosition( AVATAR_JOINT_PELVIS ) );
|
||||
glm::vec3 j( getJointPosition( AVATAR_JOINT_PELVIS ) );
|
||||
glTranslatef(j.x, j.y, j.z);
|
||||
glScalef(0.08, 0.08, 0.08);
|
||||
glutSolidSphere(1, 10, 10);
|
||||
glPopMatrix();
|
||||
*/
|
||||
|
||||
//renderDiskShadow(avatar->getJointPosition( AVATAR_JOINT_PELVIS ), glm::vec3(0.0f, 1.0f, 0.0f), 0.1f, 0.2f);
|
||||
renderDiskShadow(getJointPosition( AVATAR_JOINT_PELVIS ), glm::vec3(0.0f, 1.0f, 0.0f), 0.1f, 0.2f);
|
||||
|
||||
//renderBody();
|
||||
//renderBody(lookingInMirror);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void AvatarRenderer::renderBody() {
|
||||
/*
|
||||
// Render joint positions as spheres
|
||||
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
|
||||
|
||||
if (b != AVATAR_JOINT_HEAD_BASE) { // the head is rendered as a special case in "renderHead"
|
||||
if (b == AVATAR_JOINT_HEAD_BASE) { // the head is rendered as a special case
|
||||
if (_displayingHead) {
|
||||
_head.render(lookingInMirror);
|
||||
}
|
||||
} else {
|
||||
|
||||
//show direction vectors of the bone orientation
|
||||
//renderOrientationDirections(_joint[b].springyPosition, _joint[b].orientation, _joint[b].radius * 2.0);
|
||||
|
||||
glm::vec3 j( avatar->getJointPosition( AVATAR_JOINT_PELVIS ) );
|
||||
glColor3fv(skinColor);
|
||||
glColor3fv(_avatar->skinColor);
|
||||
glPushMatrix();
|
||||
glTranslatef(j.x, j.y, j.z);
|
||||
glutSolidSphere(_joint[b].radius, 20.0f, 20.0f);
|
||||
glTranslatef(_avatar->[b].springyPosition.x, _avatar->_joint[b].springyPosition.y, _avatar->_joint[b].springyPosition.z);
|
||||
glutSolidSphere(_avatar->_joint[b].radius, 20.0f, 20.0f);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
if (_joint[b].touchForce > 0.0f) {
|
||||
|
||||
float alpha = _joint[b].touchForce * 0.2;
|
||||
float r = _joint[b].radius * 1.1f + 0.005f;
|
||||
glColor4f(0.5f, 0.2f, 0.2f, alpha);
|
||||
glPushMatrix();
|
||||
glTranslatef(_joint[b].springyPosition.x, _joint[b].springyPosition.y, _joint[b].springyPosition.z);
|
||||
glScalef(r, r, r);
|
||||
glutSolidSphere(1, 20, 20);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Render lines connecting the joint positions
|
||||
glColor3f(0.4f, 0.5f, 0.6f);
|
||||
glLineWidth(3.0);
|
||||
|
@ -71,5 +78,6 @@ void AvatarRenderer::renderBody() {
|
|||
glEnd();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
|
@ -11,16 +11,17 @@
|
|||
#include "Avatar.h"
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class AvatarRenderer {
|
||||
/*
|
||||
class AvatarRenderer : public Avatar {
|
||||
public:
|
||||
|
||||
AvatarRenderer();
|
||||
void render(Avatar *avatarToRender, bool lookingInMirror, glm::vec3 cameraPosition );
|
||||
void render();
|
||||
|
||||
private:
|
||||
|
||||
Avatar *avatar;
|
||||
void renderBody();
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,12 +15,16 @@ using namespace std;
|
|||
const float HEAD_MOTION_DECAY = 0.1;
|
||||
const float MINIMUM_EYE_ROTATION = 0.7f; // based on a dot product: 1.0 is straight ahead, 0.0 is 90 degrees off
|
||||
|
||||
const float EYEBALL_RADIUS = 0.02;
|
||||
const float IRIS_RADIUS = 0.007;
|
||||
const float IRIS_PROTRUSION = 0.018f;
|
||||
|
||||
float _browColor [] = {210.0/255.0, 105.0/255.0, 30.0/255.0};
|
||||
float _mouthColor[] = {1, 0, 0};
|
||||
|
||||
float _BrowRollAngle [5] = {0, 15, 30, -30, -15};
|
||||
float _BrowPitchAngle[3] = {-70, -60, -50};
|
||||
float _eyeColor [3] = {1,1,1};
|
||||
float _BrowRollAngle [5] = { 0.0f, 15.0f, 30.0f, -30.0f, -15.0f};
|
||||
float _BrowPitchAngle[3] = {-70.0f, -60.0f, -50.0f};
|
||||
float _eyeColor [3] = { 0.9f, 0.9f, 0.8f};
|
||||
|
||||
float _MouthWidthChoices[3] = {0.5, 0.77, 0.3};
|
||||
|
||||
|
@ -66,12 +70,13 @@ Head::Head() :
|
|||
_bodyYaw(0.0f),
|
||||
_eyeContactTarget(LEFT_EYE)
|
||||
{
|
||||
_eyebrowPitch[0] = -30;
|
||||
_eyebrowPitch[1] = -30;
|
||||
_eyebrowRoll [0] = 20;
|
||||
_eyebrowRoll [1] = -20;
|
||||
_eyebrowPitch[0] = -30;
|
||||
_eyebrowPitch[1] = -30;
|
||||
_eyebrowRoll [0] = 20;
|
||||
_eyebrowRoll [1] = -20;
|
||||
}
|
||||
|
||||
|
||||
void Head::setPositionRotationAndScale(glm::vec3 p, glm::vec3 r, float s) {
|
||||
_position = p;
|
||||
_scale = s;
|
||||
|
@ -219,16 +224,17 @@ void Head::updateEyePositions() {
|
|||
+ _orientation.getFront() * frontShift;
|
||||
}
|
||||
|
||||
|
||||
void Head::setLooking(bool looking) {
|
||||
|
||||
_looking = looking;
|
||||
_lookingAtSomething = looking;
|
||||
|
||||
glm::vec3 averageEyePosition = _leftEyePosition + (_rightEyePosition - _leftEyePosition ) * ONE_HALF;
|
||||
glm::vec3 targetLookatAxis = glm::normalize(_lookatPosition - averageEyePosition);
|
||||
|
||||
float dot = glm::dot(targetLookatAxis, _orientation.getFront());
|
||||
if (dot < MINIMUM_EYE_ROTATION) {
|
||||
_looking = false;
|
||||
_lookingAtSomething = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,9 +251,8 @@ void Head::render(bool lookingInMirror) {
|
|||
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(_position.x, _position.y, _position.z);
|
||||
|
||||
glScalef(_scale, _scale, _scale);
|
||||
glTranslatef(_position.x, _position.y, _position.z); //translate to head position
|
||||
glScalef(_scale, _scale, _scale); //scale to head size
|
||||
|
||||
if (lookingInMirror) {
|
||||
glRotatef(_bodyYaw - _yaw, 0, 1, 0);
|
||||
|
@ -326,13 +331,14 @@ void Head::render(bool lookingInMirror) {
|
|||
|
||||
glPopMatrix();
|
||||
|
||||
//a new version of eyeballs that has the ability to look at specific targets in the world (algo still not finished yet)
|
||||
renderEyeBalls();
|
||||
|
||||
if (_looking) {
|
||||
/*
|
||||
if (_lookingAtSomething) {
|
||||
// Render lines originating from the eyes and converging on the lookatPosition
|
||||
debugRenderLookatVectors(_leftEyePosition, _rightEyePosition, _lookatPosition);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void Head::renderEyeBalls() {
|
||||
|
@ -345,7 +351,7 @@ void Head::renderEyeBalls() {
|
|||
}
|
||||
}
|
||||
|
||||
// setup the texutre to be used on each eye
|
||||
// setup the texutre to be used on each iris
|
||||
GLUquadric* irisQuadric = gluNewQuadric();
|
||||
gluQuadricTexture(irisQuadric, GL_TRUE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
@ -353,60 +359,90 @@ void Head::renderEyeBalls() {
|
|||
gluQuadricOrientation(irisQuadric, GLU_OUTSIDE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, IRIS_TEXTURE_WIDTH, IRIS_TEXTURE_HEIGHT,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, &::irisTexture[0]);
|
||||
|
||||
// left eyeball
|
||||
|
||||
// render white ball of left eyeball
|
||||
glPushMatrix();
|
||||
glColor3fv(_eyeColor);
|
||||
glTranslatef(_leftEyePosition.x, _leftEyePosition.y, _leftEyePosition.z);
|
||||
gluSphere(irisQuadric, 0.02, 30, 30);
|
||||
gluSphere(irisQuadric, EYEBALL_RADIUS, 30, 30);
|
||||
glPopMatrix();
|
||||
|
||||
// left iris
|
||||
// render left iris
|
||||
glPushMatrix(); {
|
||||
glTranslatef(_leftEyePosition.x, _leftEyePosition.y, _leftEyePosition.z);
|
||||
glm::vec3 targetLookatAxis = glm::normalize(_lookatPosition - _leftEyePosition);
|
||||
|
||||
if (!_looking) {
|
||||
targetLookatAxis = _orientation.getFront();
|
||||
}
|
||||
glTranslatef(_leftEyePosition.x, _leftEyePosition.y, _leftEyePosition.z); //translate to eyeball position
|
||||
|
||||
glPushMatrix();
|
||||
glm::vec3 rotationAxis = glm::cross(targetLookatAxis, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
float angle = 180.0f - angleBetween(targetLookatAxis, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
glRotatef(angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
||||
glTranslatef( 0.0f, -0.018f, 0.0f);//push the iris out a bit (otherwise - inside of eyeball!)
|
||||
|
||||
if (_lookingAtSomething) {
|
||||
|
||||
//rotate the eyeball to aim towards the lookat position
|
||||
glm::vec3 targetLookatAxis = glm::normalize(_lookatPosition - _leftEyePosition); // the lookat direction
|
||||
glm::vec3 rotationAxis = glm::cross(targetLookatAxis, IDENTITY_UP);
|
||||
float angle = 180.0f - angleBetween(targetLookatAxis, IDENTITY_UP);
|
||||
glRotatef(angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
||||
glRotatef(180.0, 0.0f, 1.0f, 0.0f); //adjust roll to correct after previous rotations
|
||||
} else {
|
||||
|
||||
//rotate the eyeball to aim straight ahead
|
||||
glm::vec3 rotationAxisToHeadFront = glm::cross(_orientation.getFront(), IDENTITY_UP);
|
||||
float angleToHeadFront = 180.0f - angleBetween(_orientation.getFront(), IDENTITY_UP);
|
||||
glRotatef(angleToHeadFront, rotationAxisToHeadFront.x, rotationAxisToHeadFront.y, rotationAxisToHeadFront.z);
|
||||
|
||||
//set the amount of roll (for correction after previous rotations)
|
||||
float rollRotation = angleBetween(_orientation.getFront(), IDENTITY_FRONT);
|
||||
float dot = glm::dot(_orientation.getFront(), -IDENTITY_RIGHT);
|
||||
if ( dot < 0.0f ) { rollRotation = -rollRotation; }
|
||||
glRotatef(rollRotation, 0.0f, 1.0f, 0.0f); //roll the iris or correct roll about the lookat vector
|
||||
}
|
||||
|
||||
glTranslatef( 0.0f, -IRIS_PROTRUSION, 0.0f);//push the iris out a bit (otherwise - inside of eyeball!)
|
||||
glScalef( 1.0f, 0.5f, 1.0f); // flatten the iris
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
gluSphere(irisQuadric, 0.007, 15, 15);
|
||||
gluSphere(irisQuadric, IRIS_RADIUS, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glPopMatrix();
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
//right eyeball
|
||||
//render white ball of right eyeball
|
||||
glPushMatrix();
|
||||
glColor3fv(_eyeColor);
|
||||
glTranslatef(_rightEyePosition.x, _rightEyePosition.y, _rightEyePosition.z);
|
||||
gluSphere(irisQuadric, 0.02, 30, 30);
|
||||
gluSphere(irisQuadric, EYEBALL_RADIUS, 30, 30);
|
||||
glPopMatrix();
|
||||
|
||||
//right iris
|
||||
// render right iris
|
||||
glPushMatrix(); {
|
||||
glTranslatef(_rightEyePosition.x, _rightEyePosition.y, _rightEyePosition.z);
|
||||
glm::vec3 targetLookatAxis = glm::normalize(_lookatPosition - _rightEyePosition);
|
||||
|
||||
if (!_looking) {
|
||||
targetLookatAxis = _orientation.getFront();
|
||||
}
|
||||
glTranslatef(_rightEyePosition.x, _rightEyePosition.y, _rightEyePosition.z); //translate to eyeball position
|
||||
|
||||
glPushMatrix();
|
||||
glm::vec3 rotationAxis = glm::cross(targetLookatAxis, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
float angle = 180.0f - angleBetween(targetLookatAxis, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
glRotatef(angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
||||
glTranslatef( 0.0f, -0.018f, 0.0f);//push the iris out a bit (otherwise - inside of eyeball!)
|
||||
|
||||
if (_lookingAtSomething) {
|
||||
|
||||
//rotate the eyeball to aim towards the lookat position
|
||||
glm::vec3 targetLookatAxis = glm::normalize(_lookatPosition - _rightEyePosition);
|
||||
glm::vec3 rotationAxis = glm::cross(targetLookatAxis, IDENTITY_UP);
|
||||
float angle = 180.0f - angleBetween(targetLookatAxis, IDENTITY_UP);
|
||||
glRotatef(angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
||||
glRotatef(180.0f, 0.0f, 1.0f, 0.0f); //adjust roll to correct after previous rotations
|
||||
} else {
|
||||
|
||||
//rotate the eyeball to aim straight ahead
|
||||
glm::vec3 rotationAxisToHeadFront = glm::cross(_orientation.getFront(), IDENTITY_UP);
|
||||
float angleToHeadFront = 180.0f - angleBetween(_orientation.getFront(), IDENTITY_UP);
|
||||
glRotatef(angleToHeadFront, rotationAxisToHeadFront.x, rotationAxisToHeadFront.y, rotationAxisToHeadFront.z);
|
||||
|
||||
//set the amount of roll (for correction after previous rotations)
|
||||
float rollRotation = angleBetween(_orientation.getFront(), IDENTITY_FRONT);
|
||||
float dot = glm::dot(_orientation.getFront(), -IDENTITY_RIGHT);
|
||||
if ( dot < 0.0f ) { rollRotation = -rollRotation; }
|
||||
glRotatef(rollRotation, 0.0f, 1.0f, 0.0f); //roll the iris or correct roll about the lookat vector
|
||||
}
|
||||
|
||||
glTranslatef( 0.0f, -IRIS_PROTRUSION, 0.0f);//push the iris out a bit (otherwise - inside of eyeball!)
|
||||
glScalef( 1.0f, 0.5f, 1.0f); // flatten the iris
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
gluSphere(irisQuadric, 0.007, 15, 15);
|
||||
gluSphere(irisQuadric, IRIS_RADIUS, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ private:
|
|||
float _scale;
|
||||
int _eyeContact;
|
||||
float _browAudioLift;
|
||||
bool _looking;
|
||||
bool _lookingAtSomething;
|
||||
glm::vec3 _gravity;
|
||||
float _lastLoudness;
|
||||
float _averageLoudness;
|
||||
|
|
|
@ -32,11 +32,15 @@ namespace { // everything in here only exists while compiling this .cpp file
|
|||
}
|
||||
|
||||
|
||||
Oscilloscope::Oscilloscope(int w, int h, bool isEnabled) :
|
||||
_valWidth(w), _valHeight(h),
|
||||
_arrSamples(0l), _arrVertices(0l),
|
||||
_valLowpass(0.4f), _valDownsample(3),
|
||||
enabled(isEnabled), inputPaused(false) {
|
||||
Oscilloscope::Oscilloscope(int w, int h, bool isEnabled) :
|
||||
enabled(isEnabled),
|
||||
inputPaused(false),
|
||||
_valWidth(w),
|
||||
_valHeight(h),
|
||||
_arrSamples(0l),
|
||||
_arrVertices(0l),
|
||||
_valLowpass(0.4f),
|
||||
_valDownsample(3) {
|
||||
|
||||
// allocate enough space for the sample data and to turn it into
|
||||
// vertices and since they're all 'short', do so in one shot
|
||||
|
|
|
@ -9,12 +9,16 @@
|
|||
#include <sys/time.h>
|
||||
|
||||
#include "SharedUtil.h"
|
||||
#include "AgentList.h"
|
||||
#include "AgentTypes.h"
|
||||
#include "Agent.h"
|
||||
#include "PacketHeaders.h"
|
||||
|
||||
#include "AudioInjectionManager.h"
|
||||
|
||||
UDPSocket* AudioInjectionManager::_injectorSocket = NULL;
|
||||
sockaddr AudioInjectionManager::_destinationSocket;
|
||||
bool AudioInjectionManager::_isDestinationSocketExplicit = false;
|
||||
AudioInjector* AudioInjectionManager::_injectors[50] = {};
|
||||
|
||||
AudioInjector* AudioInjectionManager::injectorWithSamplesFromFile(const char* filename) {
|
||||
|
@ -39,9 +43,24 @@ AudioInjector* AudioInjectionManager::injectorWithCapacity(int capacity) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void AudioInjectionManager::setDestinationSocket(sockaddr& destinationSocket) {
|
||||
_destinationSocket = destinationSocket;
|
||||
_isDestinationSocketExplicit = true;
|
||||
}
|
||||
|
||||
void* AudioInjectionManager::injectAudioViaThread(void* args) {
|
||||
AudioInjector* injector = (AudioInjector*) args;
|
||||
|
||||
// if we don't have an injectorSocket then grab the one from the agent list
|
||||
if (!_injectorSocket) {
|
||||
_injectorSocket = AgentList::getInstance()->getAgentSocket();
|
||||
}
|
||||
|
||||
// if we don't have an explicit destination socket then pull active socket for current audio mixer from agent list
|
||||
if (!_isDestinationSocketExplicit) {
|
||||
_destinationSocket = *AgentList::getInstance()->soloAgentOfType(AGENT_TYPE_AUDIO_MIXER)->getActiveSocket();
|
||||
}
|
||||
|
||||
injector->injectAudio(_injectorSocket, &_destinationSocket);
|
||||
|
||||
// if this an injector inside the injection manager's array we're responsible for deletion
|
||||
|
|
|
@ -24,12 +24,13 @@ public:
|
|||
static void threadInjector(AudioInjector* injector);
|
||||
|
||||
static void setInjectorSocket(UDPSocket* injectorSocket) { _injectorSocket = injectorSocket;}
|
||||
static void setDestinationSocket(sockaddr& destinationSocket) { _destinationSocket = destinationSocket; }
|
||||
static void setDestinationSocket(sockaddr& destinationSocket);
|
||||
private:
|
||||
static void* injectAudioViaThread(void* args);
|
||||
|
||||
static UDPSocket* _injectorSocket;
|
||||
static sockaddr _destinationSocket;
|
||||
static bool _isDestinationSocketExplicit;
|
||||
static AudioInjector* _injectors[MAX_CONCURRENT_INJECTORS];
|
||||
};
|
||||
|
||||
|
|
|
@ -33,6 +33,35 @@ int unpackFloatAngleFromTwoByte(uint16_t* byteAnglePointer, float* destinationPo
|
|||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
AvatarData::AvatarData() :
|
||||
_handPosition(0,0,0),
|
||||
_lookatPosition(0,0,0),
|
||||
_bodyYaw(-90.0),
|
||||
_bodyPitch(0.0),
|
||||
_bodyRoll(0.0),
|
||||
_headYaw(0),
|
||||
_headPitch(0),
|
||||
_headRoll(0),
|
||||
_headLeanSideways(0),
|
||||
_headLeanForward(0),
|
||||
_audioLoudness(0),
|
||||
_handState(0),
|
||||
_cameraPosition(0,0,0),
|
||||
_cameraDirection(0,0,0),
|
||||
_cameraUp(0,0,0),
|
||||
_cameraRight(0,0,0),
|
||||
_cameraFov(0.0f),
|
||||
_cameraAspectRatio(0.0f),
|
||||
_cameraNearClip(0.0f),
|
||||
_cameraFarClip(0.0f),
|
||||
_keyState(NO_KEY_DOWN),
|
||||
_wantResIn(false),
|
||||
_wantColor(true),
|
||||
_wantDelta(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
||||
unsigned char* bufferStart = destinationBuffer;
|
||||
|
||||
|
@ -63,6 +92,10 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
// Hand Position
|
||||
memcpy(destinationBuffer, &_handPosition, sizeof(float) * 3);
|
||||
destinationBuffer += sizeof(float) * 3;
|
||||
|
||||
// Lookat Position
|
||||
memcpy(destinationBuffer, &_lookatPosition, sizeof(_lookatPosition));
|
||||
destinationBuffer += sizeof(_lookatPosition);
|
||||
|
||||
// Hand State (0 = not grabbing, 1 = grabbing)
|
||||
memcpy(destinationBuffer, &_handState, sizeof(char));
|
||||
|
@ -146,6 +179,10 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
memcpy(&_handPosition, sourceBuffer, sizeof(float) * 3);
|
||||
sourceBuffer += sizeof(float) * 3;
|
||||
|
||||
// Lookat Position
|
||||
memcpy(&_lookatPosition, sourceBuffer, sizeof(_lookatPosition));
|
||||
sourceBuffer += sizeof(_lookatPosition);
|
||||
|
||||
// Hand State
|
||||
memcpy(&_handState, sourceBuffer, sizeof(char));
|
||||
sourceBuffer += sizeof(char);
|
||||
|
|
|
@ -28,34 +28,13 @@ enum KeyState
|
|||
|
||||
class AvatarData : public AgentData {
|
||||
public:
|
||||
AvatarData() :
|
||||
_handPosition(0,0,0),
|
||||
_bodyYaw(-90.0),
|
||||
_bodyPitch(0.0),
|
||||
_bodyRoll(0.0),
|
||||
_headYaw(0),
|
||||
_headPitch(0),
|
||||
_headRoll(0),
|
||||
_headLeanSideways(0),
|
||||
_headLeanForward(0),
|
||||
_audioLoudness(0),
|
||||
_handState(0),
|
||||
_cameraPosition(0,0,0),
|
||||
_cameraDirection(0,0,0),
|
||||
_cameraUp(0,0,0),
|
||||
_cameraRight(0,0,0),
|
||||
_cameraFov(0.0f),
|
||||
_cameraAspectRatio(0.0f),
|
||||
_cameraNearClip(0.0f),
|
||||
_cameraFarClip(0.0f),
|
||||
_keyState(NO_KEY_DOWN),
|
||||
_wantResIn(false),
|
||||
_wantColor(true) { };
|
||||
AvatarData();
|
||||
|
||||
const glm::vec3& getPosition() const { return _position; }
|
||||
void setPosition(const glm::vec3 position) { _position = position; }
|
||||
|
||||
void setHandPosition(const glm::vec3 handPosition) { _handPosition = handPosition; }
|
||||
void setPosition (const glm::vec3 position ) { _position = position; }
|
||||
void setHandPosition (const glm::vec3 handPosition ) { _handPosition = handPosition; }
|
||||
void setLookatPosition(const glm::vec3 lookatPosition) { _lookatPosition = lookatPosition; }
|
||||
|
||||
int getBroadcastData(unsigned char* destinationBuffer);
|
||||
int parseData(unsigned char* sourceBuffer, int numBytes);
|
||||
|
@ -63,10 +42,8 @@ public:
|
|||
// Body Rotation
|
||||
float getBodyYaw() const { return _bodyYaw; }
|
||||
void setBodyYaw(float bodyYaw) { _bodyYaw = bodyYaw; }
|
||||
|
||||
float getBodyPitch() const { return _bodyPitch; }
|
||||
void setBodyPitch(float bodyPitch) { _bodyPitch = bodyPitch; }
|
||||
|
||||
float getBodyRoll() const {return _bodyRoll; }
|
||||
void setBodyRoll(float bodyRoll) { _bodyRoll = bodyRoll; }
|
||||
|
||||
|
@ -135,9 +112,10 @@ protected:
|
|||
// privatize the copy constructor and assignment operator so they cannot be called
|
||||
AvatarData(const AvatarData&);
|
||||
AvatarData& operator= (const AvatarData&);
|
||||
|
||||
|
||||
glm::vec3 _position;
|
||||
glm::vec3 _handPosition;
|
||||
glm::vec3 _lookatPosition;
|
||||
|
||||
// Body rotation
|
||||
float _bodyYaw;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
#include "AgentList.h"
|
||||
#include "AgentTypes.h"
|
||||
#include "PacketHeaders.h"
|
||||
|
|
Loading…
Reference in a new issue