#include "BasicGlCamera.h" #include #include #include #include #include #include "src/tools.h" //Coordinates of an hexagon of radius 1 and center 0 GLfloat hexcoords[6][2] = {{-1./sqrt(3.), 1}, { 1./sqrt(3.), 1}, { 2./sqrt(3.), 0}, { 1./sqrt(3.), -1}, {-1./sqrt(3.), -1}, {-2./sqrt(3.), 0}}; BasicGlCamera::BasicGlCamera(QWidget* cParent) : QGLWidget(cParent) { setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer)); hexRadius = 0.015f; hexTolerance = hexRadius/100.0f; viewSize = 1.0f; calculatePixelsCoords(); ifstream fin2("MasterList-v3.txt"); if (!fin2.is_open()) { cout << "Error: file \"MasterList-v3\" missing. aborting." << endl; exit(-1); } int l = 0; string buf; while (getline(fin2, buf, '\n')) { buf = Tools::Trim(buf); if (buf[0]=='#') continue; unsigned int softid, hardid, dummy; stringstream str(buf); str >> softid; str >> dummy; str >> hardid; if (softid>=1440) continue; hardwareMapping[softid] = hardid; softwareMapping[hardid] = softid; l++; } // GLfloat tempPixelsCoords[MAX_NUM_PIXELS][3]; // for (int i=0;i<1440;i++) // for (int j=0;j<3;j++) // tempPixelsCoords[hardwareMapping[i]][j] = pixelsCoords[i][j]; // for (int i=0;i<1440;i++) // for (int j=0;j<3;j++) // pixelsCoords[i][j] = tempPixelsCoords[i][j]; buildVerticesList(); ifstream fin1("Trigger-Patches.txt"); if (!fin1.is_open()) { cout << "Error: file \"Trigger-Patches.txt\" missing. Aborting." << endl; exit(-1); } l=0; while (getline(fin1, buf, '\n')) { buf = Tools::Trim(buf); if (buf[0]=='#') continue; stringstream str(buf); for (int i=0; i<9; i++) { unsigned int n; str >> n; if (n>=1440) continue; patches[l][i] = hardwareMapping[n]; } l++; } buildPatchesIndices(); for (int i=0;i<1440;i++) updateNeighbors(i); ss[0] = 0; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f; rr[0] = 0.15; rr[1] = rr[2] = 0; rr[3] = 1.0f; rr[4] = 0.85f; gg[0] = 0.15; gg[1] = 0; gg[2] = 1; gg[3] = 0; gg[4] = 0.85f; bb[0] = 0.15; bb[1] = 1; bb[2] = bb[3] = 0; bb[4] = 0.85f; fPixelStride = 1; fcSlice = 0; fData.resize(1440); for (int i=0;i pixelsCoords[currentPixel][1]){//bottom neighbors[i][3] = currentPixel; neighbors[currentPixel][0] = i; continue;} if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] && pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top right neighbors[i][4] = currentPixel; neighbors[currentPixel][1] = i; continue;} if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] && pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom right neighbors[i][5] = currentPixel; neighbors[currentPixel][2] = i; continue;} if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] && pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top left neighbors[i][2] = currentPixel; neighbors[currentPixel][5] = i; continue;} if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] && pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom left neighbors[i][1] = currentPixel; neighbors[currentPixel][4] = i; continue;} } } } void BasicGlCamera::skipPixels(int start, int howMany) { for (int i=start;i= 0) { toSide--; if (toSide < 0) toSide = 5; } fromSide = toSide + 3; if (fromSide > 5) fromSide -= 6; //ok. now we now in which direction we're heading pixelsCoords[i][0] = pixelsCoords[i-1][0]; pixelsCoords[i][1] = pixelsCoords[i-1][1]; pixelsCoords[i][2] = pixelsCoords[i-1][2]; switch (toSide) { case 0: pixelsCoords[i][1] += 2*hexRadius; break; case 1: pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0); pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0); break; case 2: pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0); pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0); break; case 3: pixelsCoords[i][1] -= 2*hexRadius; break; case 4: pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0); pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0); break; case 5: pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0); pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0); break; }; updateNeighbors(i); } //Ok. So now we've circled around all the way to MAX_NUM_PIXELS //do the required shifts so that it matches the fact camera up to ACTUAL_NUM_PIXELS pixels skipPixels(1200, 1); skipPixels(1218, 3); skipPixels(1236, 1); skipPixels(1256, 1); skipPixels(1274, 3); skipPixels(1292, 3); skipPixels(1309, 6); skipPixels(1323, 7); skipPixels(1337, 6); skipPixels(1354, 6); skipPixels(1368, 7); skipPixels(1382, 9); skipPixels(1394, 12); skipPixels(1402, 15); skipPixels(1410, 12); skipPixels(1422, 12); skipPixels(1430, 15); } void BasicGlCamera::buildVerticesList() { numVertices = 0; GLfloat cVertex[2]; for (int i=0;i::iterator it; bool erased = false; for (int i=0;i