mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:56:25 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
c1a3478954
5 changed files with 44 additions and 73 deletions
|
@ -80,10 +80,6 @@ timeval firstPlaybackTimer;
|
||||||
int packetsReceivedThisPlayback = 0;
|
int packetsReceivedThisPlayback = 0;
|
||||||
float usecsAtStartup = 0;
|
float usecsAtStartup = 0;
|
||||||
|
|
||||||
#define LOG_SAMPLE_DELAY 0
|
|
||||||
|
|
||||||
std::ofstream logFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Audio callback used by portaudio.
|
* Audio callback used by portaudio.
|
||||||
* Communicates with Audio via a shared pointer to Audio::data.
|
* Communicates with Audio via a shared pointer to Audio::data.
|
||||||
|
@ -315,34 +311,12 @@ void *receiveAudioViaUDP(void *args) {
|
||||||
|
|
||||||
stdev.reset();
|
stdev.reset();
|
||||||
|
|
||||||
if (LOG_SAMPLE_DELAY) {
|
|
||||||
|
|
||||||
char *directory = new char[50];
|
|
||||||
char *filename = new char[50];
|
|
||||||
|
|
||||||
sprintf(directory, "%s/Desktop/echo_tests", getenv("HOME"));
|
|
||||||
|
|
||||||
mkdir(directory, S_IRWXU | S_IRWXG | S_IRWXO);
|
|
||||||
sprintf(filename, "%s/%ld.csv", directory, previousReceiveTime.tv_sec);
|
|
||||||
|
|
||||||
logFile.open(filename, std::ios::out);
|
|
||||||
|
|
||||||
delete[] directory;
|
|
||||||
delete[] filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!stopAudioReceiveThread) {
|
while (!stopAudioReceiveThread) {
|
||||||
|
|
||||||
if (sharedAudioData->audioSocket->receive((void *)receivedData, &receivedBytes)) {
|
if (sharedAudioData->audioSocket->receive((void *)receivedData, &receivedBytes)) {
|
||||||
|
|
||||||
gettimeofday(¤tReceiveTime, NULL);
|
gettimeofday(¤tReceiveTime, NULL);
|
||||||
totalPacketsReceived++;
|
totalPacketsReceived++;
|
||||||
|
|
||||||
if (LOG_SAMPLE_DELAY) {
|
|
||||||
// write time difference (in microseconds) between packet receipts to file
|
|
||||||
double timeDiff = diffclock(&previousReceiveTime, ¤tReceiveTime);
|
|
||||||
logFile << timeDiff << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
double tDiff = diffclock(&previousReceiveTime, ¤tReceiveTime);
|
double tDiff = diffclock(&previousReceiveTime, ¤tReceiveTime);
|
||||||
//printLog("tDiff %4.1f\n", tDiff);
|
//printLog("tDiff %4.1f\n", tDiff);
|
||||||
|
@ -562,8 +536,7 @@ void Audio::render(int screenWidth, int screenHeight)
|
||||||
* @return Returns true if the initialization was successful, or false if an error occured.
|
* @return Returns true if the initialization was successful, or false if an error occured.
|
||||||
The error code may be retrieved by Audio::getError().
|
The error code may be retrieved by Audio::getError().
|
||||||
*/
|
*/
|
||||||
bool Audio::terminate ()
|
bool Audio::terminate() {
|
||||||
{
|
|
||||||
stopAudioReceiveThread = true;
|
stopAudioReceiveThread = true;
|
||||||
pthread_join(audioReceiveThread, NULL);
|
pthread_join(audioReceiveThread, NULL);
|
||||||
|
|
||||||
|
@ -577,7 +550,6 @@ bool Audio::terminate ()
|
||||||
if (paError != paNoError) goto error;
|
if (paError != paNoError) goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
logFile.close();
|
|
||||||
delete audioData;
|
delete audioData;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1539,3 +1539,23 @@ glm::vec3 Avatar::getGravity(glm::vec3 pos) {
|
||||||
return glm::vec3(0.f, 0.f, 0.f);
|
return glm::vec3(0.f, 0.f, 0.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char AVATAR_DATA_FILENAME[] = "avatar.ifd";
|
||||||
|
|
||||||
|
void Avatar::writeAvatarDataToFile() {
|
||||||
|
// write the avatar position and yaw to a local file
|
||||||
|
FILE* avatarFile = fopen(AVATAR_DATA_FILENAME, "w");
|
||||||
|
|
||||||
|
if (avatarFile) {
|
||||||
|
fprintf(avatarFile, "%f,%f,%f %f", _position.x, _position.y, _position.z, _bodyYaw);
|
||||||
|
fclose(avatarFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Avatar::readAvatarDataFromFile() {
|
||||||
|
FILE* avatarFile = fopen(AVATAR_DATA_FILENAME, "r");
|
||||||
|
|
||||||
|
if (avatarFile) {
|
||||||
|
fscanf(avatarFile, "%f,%f,%f %f", &_position.x, &_position.y, &_position.z, &_bodyYaw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -145,6 +145,9 @@ public:
|
||||||
|
|
||||||
// Find out what the local gravity vector is at this location
|
// Find out what the local gravity vector is at this location
|
||||||
glm::vec3 getGravity(glm::vec3 pos);
|
glm::vec3 getGravity(glm::vec3 pos);
|
||||||
|
|
||||||
|
void writeAvatarDataToFile();
|
||||||
|
void readAvatarDataFromFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ using namespace std;
|
||||||
// no clue which versions are affected...
|
// no clue which versions are affected...
|
||||||
#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
|
||||||
static float MONO_STROKE_WIDTH_GLUT = 104.76;
|
|
||||||
|
|
||||||
void eulerToOrthonormals(glm::vec3 * angles, glm::vec3 * front, glm::vec3 * right, glm::vec3 * up) {
|
void eulerToOrthonormals(glm::vec3 * angles, glm::vec3 * front, glm::vec3 * right, glm::vec3 * up) {
|
||||||
//
|
//
|
||||||
|
@ -172,7 +171,6 @@ void drawtext(int x, int y, float scale, float rotate, float thick, int mono,
|
||||||
//
|
//
|
||||||
// Draws text on screen as stroked so it can be resized
|
// Draws text on screen as stroked so it can be resized
|
||||||
//
|
//
|
||||||
int len, i;
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef( static_cast<float>(x), static_cast<float>(y), 0.0f);
|
glTranslatef( static_cast<float>(x), static_cast<float>(y), 0.0f);
|
||||||
glColor3f(r,g,b);
|
glColor3f(r,g,b);
|
||||||
|
|
|
@ -344,7 +344,9 @@ void init(void)
|
||||||
|
|
||||||
void terminate () {
|
void terminate () {
|
||||||
// Close serial port
|
// Close serial port
|
||||||
//close(serial_fd);
|
// close(serial_fd);
|
||||||
|
|
||||||
|
myAvatar.writeAvatarDataToFile();
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
audio.terminate();
|
audio.terminate();
|
||||||
|
@ -1290,7 +1292,6 @@ int doRandomizeVoxelColors(int state) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int doFalseRandomizeVoxelColors(int state) {
|
int doFalseRandomizeVoxelColors(int state) {
|
||||||
if (state == MENU_ROW_PICKED) {
|
if (state == MENU_ROW_PICKED) {
|
||||||
::voxels.falseColorizeRandom();
|
::voxels.falseColorizeRandom();
|
||||||
|
@ -1322,7 +1323,6 @@ int doFalseColorizeInView(int state) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* modeAll = " - All ";
|
const char* modeAll = " - All ";
|
||||||
const char* modeVectors = " - Vectors ";
|
const char* modeVectors = " - Vectors ";
|
||||||
const char* modePlanes = " - Planes ";
|
const char* modePlanes = " - Planes ";
|
||||||
|
@ -1396,8 +1396,7 @@ void testPointToVoxel()
|
||||||
float y=0;
|
float y=0;
|
||||||
float z=0;
|
float z=0;
|
||||||
float s=0.1;
|
float s=0.1;
|
||||||
for (float x=0; x<=1; x+= 0.05)
|
for (float x=0; x<=1; x+= 0.05) {
|
||||||
{
|
|
||||||
printLog(" x=%f");
|
printLog(" x=%f");
|
||||||
|
|
||||||
unsigned char red = 200; //randomColorValue(65);
|
unsigned char red = 200; //randomColorValue(65);
|
||||||
|
@ -1486,11 +1485,9 @@ void specialkeyUp(int k, int x, int y) {
|
||||||
myAvatar.setDriveKeys(RIGHT, 0);
|
myAvatar.setDriveKeys(RIGHT, 0);
|
||||||
myAvatar.setDriveKeys(ROT_RIGHT, 0);
|
myAvatar.setDriveKeys(ROT_RIGHT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void specialkey(int k, int x, int y)
|
void specialkey(int k, int x, int y) {
|
||||||
{
|
|
||||||
if (::chatEntryOn) {
|
if (::chatEntryOn) {
|
||||||
chatEntry.specialKey(k);
|
chatEntry.specialKey(k);
|
||||||
return;
|
return;
|
||||||
|
@ -1532,7 +1529,6 @@ void keyUp(unsigned char k, int x, int y) {
|
||||||
if (k == 's') myAvatar.setDriveKeys(BACK, 0);
|
if (k == 's') myAvatar.setDriveKeys(BACK, 0);
|
||||||
if (k == 'a') myAvatar.setDriveKeys(ROT_LEFT, 0);
|
if (k == 'a') myAvatar.setDriveKeys(ROT_LEFT, 0);
|
||||||
if (k == 'd') myAvatar.setDriveKeys(ROT_RIGHT, 0);
|
if (k == 'd') myAvatar.setDriveKeys(ROT_RIGHT, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void key(unsigned char k, int x, int y)
|
void key(unsigned char k, int x, int y)
|
||||||
|
@ -1624,8 +1620,7 @@ void key(unsigned char k, int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive packets from other agents/servers and decide what to do with them!
|
// Receive packets from other agents/servers and decide what to do with them!
|
||||||
void* networkReceive(void* args)
|
void* networkReceive(void* args) {
|
||||||
{
|
|
||||||
sockaddr senderAddress;
|
sockaddr senderAddress;
|
||||||
ssize_t bytesReceived;
|
ssize_t bytesReceived;
|
||||||
|
|
||||||
|
@ -1697,9 +1692,7 @@ void idle(void) {
|
||||||
handControl.stop();
|
handControl.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Sample hardware, update view frustum if needed, Lsend avatar data to mixer/agents
|
// Sample hardware, update view frustum if needed, Lsend avatar data to mixer/agents
|
||||||
//
|
|
||||||
updateAvatar(deltaTime);
|
updateAvatar(deltaTime);
|
||||||
|
|
||||||
// read incoming packets from network
|
// read incoming packets from network
|
||||||
|
@ -1730,9 +1723,7 @@ void idle(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reshape(int width, int height) {
|
||||||
void reshape(int width, int height)
|
|
||||||
{
|
|
||||||
WIDTH = width;
|
WIDTH = width;
|
||||||
HEIGHT = height;
|
HEIGHT = height;
|
||||||
aspectRatio = ((float)width/(float)height); // based on screen resize
|
aspectRatio = ((float)width/(float)height); // based on screen resize
|
||||||
|
@ -1758,17 +1749,12 @@ void reshape(int width, int height)
|
||||||
camera.setFieldOfView(fov = 60);
|
camera.setFieldOfView(fov = 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
//printLog("reshape() width=%d, height=%d, aspectRatio=%f fov=%f near=%f far=%f \n",
|
|
||||||
// width,height,aspectRatio,fov,nearClip,farClip);
|
|
||||||
|
|
||||||
// Tell our viewFrustum about this change
|
// Tell our viewFrustum about this change
|
||||||
::viewFrustum.setAspectRatio(aspectRatio);
|
::viewFrustum.setAspectRatio(aspectRatio);
|
||||||
|
|
||||||
|
|
||||||
glViewport(0, 0, width, height); // shouldn't this account for the menu???
|
glViewport(0, 0, width, height); // shouldn't this account for the menu???
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION); //hello
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
// XXXBHG - If we're in view frustum mode, then we need to do this little bit of hackery so that
|
// XXXBHG - If we're in view frustum mode, then we need to do this little bit of hackery so that
|
||||||
|
@ -1785,42 +1771,32 @@ void reshape(int width, int height)
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseFunc( int button, int state, int x, int y )
|
void mouseFunc(int button, int state, int x, int y) {
|
||||||
{
|
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ) {
|
||||||
if( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN )
|
if (state == GLUT_DOWN && !menu.mouseClick(x, y)) {
|
||||||
{
|
|
||||||
if (!menu.mouseClick(x, y)) {
|
|
||||||
mouseX = x;
|
mouseX = x;
|
||||||
mouseY = y;
|
mouseY = y;
|
||||||
mousePressed = 1;
|
mousePressed = 1;
|
||||||
|
} else if (state == GLUT_UP) {
|
||||||
|
mouseX = x;
|
||||||
|
mouseY = y;
|
||||||
|
mousePressed = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( button == GLUT_LEFT_BUTTON && state == GLUT_UP ) {
|
|
||||||
mouseX = x;
|
|
||||||
mouseY = y;
|
|
||||||
mousePressed = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void motionFunc( int x, int y)
|
void motionFunc(int x, int y) {
|
||||||
{
|
|
||||||
mouseX = x;
|
mouseX = x;
|
||||||
mouseY = y;
|
mouseY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouseoverFunc( int x, int y)
|
void mouseoverFunc(int x, int y){
|
||||||
{
|
|
||||||
menu.mouseOver(x, y);
|
menu.mouseOver(x, y);
|
||||||
|
|
||||||
mouseX = x;
|
mouseX = x;
|
||||||
mouseY = y;
|
mouseY = y;
|
||||||
if (mousePressed == 0)
|
|
||||||
{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void attachNewHeadToAgent(Agent *newAgent) {
|
void attachNewHeadToAgent(Agent *newAgent) {
|
||||||
|
@ -1944,6 +1920,8 @@ int main(int argc, const char * argv[])
|
||||||
printLog("Network receive thread created.\n");
|
printLog("Network receive thread created.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myAvatar.readAvatarDataFromFile();
|
||||||
|
|
||||||
glutTimerFunc(1000, Timer, 0);
|
glutTimerFunc(1000, Timer, 0);
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue