#include "fileutil.h" #include #include #define PI 3.14159265358979323846264 og_mutex_t read_mutex; og_thread_t read_thread; double read_hmdAngles[NUM_SWEEP][NUM_HMD]; int read_hmdAngleViewed[NUM_SWEEP][NUM_HMD]; int read_frameno=0; static FILE *fopen_orDie(const char *path, const char *flag) { FILE *f = fopen(path, flag); if (f == NULL) { printf("ERROR could not oepn %s for %s\n", path, flag); exit(1); } return f; } static void SeekToken(FILE *f, const char *keyword) { char token[4096]; do { fscanf(f, "%s", token); } while( strcmp(token,keyword)!=0 && !feof(f) ); } void LoadLighthousePos( const char *path, float *x, float *y, float *z, float *qi, float *qj, float *qk, float *qreal) { FILE *f = fopen_orDie(path,"r"); SeekToken(f, "POS:"); fscanf(f, "%f %f %f\n", x, y, z); SeekToken(f, "QUAT:"); fscanf(f, "%f %f %f %f\n", qreal, qi, qj, qk); fclose (f); } void LoadHmdProcessedDataAngles( const char *path, double angles[NUM_SWEEP][NUM_HMD]) { int i,j; char type[256]; char sweep[256]; int id; int nSweep; double ang; double d1,d2,d3; // revisit these numbers later // Initialize all of the angles to -9999 for (i=0; iNUM_HMD) { continue; } OGLockMutex (read_mutex); read_hmdAngles[sweepId][id] = angle; OGUnlockMutex(read_mutex); read_hmdAngleViewed[sweepId][id] = read_frameno; } }