/** * @brief ProcessBBox * @param dst * @param src * @param box */ void ProcessBBox(Image *dst, ImageVec src, BBox *box) { float *vSrc1 = new float[dst->channels]; float height1f = float(box->height - 1); float width1f = float(box->width - 1); for(int j = box->y0; j < box->y1; j++) { float y = float(j) / height1f; for(int i = box->x0; i < box->x1; i++) { float x = float(i) / width1f; float *out = (*dst )(i, j); isb->SampleImage(src[0], x, y, out); isb->SampleImage(src[1], x, y, vSrc1); for(int k = 0; k < dst->channels; k++) { out[k] -= vSrc1[k]; } } } delete[] vSrc1; }
void FilterSampler3D::ProcessBBox(Image *dst, ImageVec src, BBox *box) { Image *source = src[0]; for(int p = box->z0; p < box->z1; p++) { float t = float(p) / float(box->frames - 1); for(int j = box->y0; j < box->y1; j++) { float y = float(j) / float(box->height - 1); for(int i = box->x0; i < box->x1; i++) { float x = float(i) / float(box->width - 1); int c = p * source->tstride + j * source->ystride + i * source->xstride; isb->SampleImage(source, x, y, t, &dst->data[c]); } } } }
int main(int argc, char* argv[]) { char* density = ""; char* land = ""; char* elevation = ""; char* input = ""; if(argc == 1) { cout << "Using default parameters" << endl; density = "density.png"; land = "legality.png"; elevation = "elevation.png"; input = "input.txt"; } else if(argc < 9) { cout << "Not enough args" << endl; exit(1); } else { for(int i = 1; i <= 8; i=i+2) { if(strcmp(argv[i],"-f") == 0) { input = argv[i+1]; } else if(strcmp(argv[i],"-d") == 0) { density = argv[i+1]; } else if(strcmp(argv[i],"-l") == 0) { land = argv[i+1]; } else if(strcmp(argv[i],"-e") == 0) { elevation = argv[i+1]; } } if(strcmp(input,"") == 0 || strcmp(density,"") == 0 || strcmp(land,"") == 0 || strcmp(elevation,"") == 0) { cout << "Failed to initialize all args" << endl; exit(1); } } parser = InputParser(input); is = ImageSampler(density, elevation, land); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); viewport.w = 600; viewport.h = 600; glutInitWindowSize(viewport.w, viewport.h); glutInitWindowPosition(0, 0); glutCreateWindow("City Generator"); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); initScene(argc, argv); glutDisplayFunc(myDisplay); glutReshapeFunc(myReshape); glutIdleFunc(myFrameMove); glutKeyboardFunc(keyboard); glutSpecialFunc(mySpecial); glutMainLoop(); is.done(); return 0; }