ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/bsdf2rad.c
(Generate patch)

Comparing ray/src/cv/bsdf2rad.c (file contents):
Revision 2.18 by greg, Sun Apr 9 22:51:19 2017 UTC vs.
Revision 2.28 by greg, Wed Apr 12 04:27:04 2017 UTC

# Line 26 | Line 26 | double overall_max = .0;               /* overall maximum BSDF valu
26  
27   char    ourTempDir[TEMPLEN] = "";       /* our temporary directory */
28  
29 < const FVECT     Xaxis = {1., 0., 0.};
30 < const FVECT     Yaxis = {0., 1., 0.};
31 < const FVECT     Zaxis = {0., 0., 1.};
32 <
33 < const char      frpref[] = "frefl";
34 < const char      ftpref[] = "ftrans";
35 < const char      brpref[] = "brefl";
36 < const char      btpref[] = "btrans";
29 > const char      frpref[] = "rf";
30 > const char      ftpref[] = "tf";
31 > const char      brpref[] = "rb";
32 > const char      btpref[] = "tb";
33   const char      dsuffix[] = ".txt";
34  
35 < const char      sph_mat[] = "BSDFmat";
35 > const char      sph_fmat[] = "fBSDFmat";
36 > const char      sph_bmat[] = "bBSDFmat";
37   const double    sph_rad = 10.;
38   const double    sph_xoffset = 15.;
39  
# Line 50 | Line 47 | const double   sph_xoffset = 15.;
47   char    *progname;
48  
49   /* Get Fibonacci sphere vector (0 to NINCIDENT-1) */
50 < static void
50 > static RREAL *
51   get_ivector(FVECT iv, int i)
52   {
53          const double    phistep = PI*(3. - 2.236067978);
# Line 60 | Line 57 | get_ivector(FVECT iv, int i)
57          r = sqrt(1. - iv[2]*iv[2]);
58          iv[0] = r * cos((i+1.)*phistep);
59          iv[1] = r * sin((i+1.)*phistep);
60 +
61 +        return(iv);
62   }
63  
64 + /* Convert incident vector into sphere position */
65 + static RREAL *
66 + cvt_sposition(FVECT sp, const FVECT iv, int inc_side)
67 + {
68 +        sp[0] = -iv[0]*sph_rad + inc_side*sph_xoffset;
69 +        sp[1] = -iv[1]*sph_rad;
70 +        sp[2] = iv[2]*sph_rad;
71 +
72 +        return(sp);
73 + }
74 +
75   /* Get temporary file name */
76   static char *
77   tfile_name(const char *prefix, const char *suffix, int i)
# Line 248 | Line 258 | build_wRBF(void)
258                  RBFNODE *rbf;
259                  get_ivector(ivec, i);
260                  if (input_orient < 0) {
261 <                        ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; ivec[2] = -ivec[2];
261 >                        ivec[0] = -ivec[0]; ivec[2] = -ivec[2];
262                  }
263                  rbf = advect_rbf(ivec, 15000);
264                  if (!plotRBF(tfile_name(pref, dsuffix, i), rbf))
# Line 260 | Line 270 | build_wRBF(void)
270  
271   /* Put out mirror arrow for the given incident vector */
272   static void
273 < put_mirror_arrow(const FVECT ivec, int inc_side)
273 > put_mirror_arrow(const FVECT origin, const FVECT nrm)
274   {
275          const double    arrow_len = 1.2*bsdf_rad;
276          const double    tip_len = 0.2*bsdf_rad;
277 <        FVECT           origin, refl;
277 >        FVECT           refl;
278          int             i;
279  
280 <        for (i = 3; i--; ) origin[i] = ivec[i]*sph_rad;
281 <        origin[0] -= inc_side*sph_xoffset;
280 >        refl[0] = 2.*nrm[2]*nrm[0];
281 >        refl[1] = 2.*nrm[2]*nrm[1];
282 >        refl[2] = 2.*nrm[2]*nrm[2] - 1.;
283  
273        refl[0] = 2.*ivec[2]*ivec[0];
274        refl[1] = 2.*ivec[2]*ivec[1];
275        refl[2] = 2.*ivec[2]*ivec[2] - 1.;
276
284          printf("\n# Mirror arrow\n");
285          printf("\narrow_mat cylinder inc_dir\n0\n0\n7");
286          printf("\n\t%f %f %f\n\t%f %f %f\n\t%f\n",
# Line 300 | Line 307 | put_mirror_arrow(const FVECT ivec, int inc_side)
307  
308   /* Put out transmitted direction arrow for the given incident vector */
309   static void
310 < put_trans_arrow(const FVECT ivec, int inc_side)
310 > put_trans_arrow(const FVECT origin)
311   {
312          const double    arrow_len = 1.2*bsdf_rad;
313          const double    tip_len = 0.2*bsdf_rad;
307        FVECT           origin;
314          int             i;
315  
310        for (i = 3; i--; ) origin[i] = ivec[i]*sph_rad;
311        origin[0] -= inc_side*sph_xoffset;
312
316          printf("\n# Transmission arrow\n");
317          printf("\narrow_mat cylinder trans_dir\n0\n0\n7");
318          printf("\n\t%f %f %f\n\t%f %f %f\n\t%f\n",
# Line 364 | Line 367 | static int
367   put_BSDFs(void)
368   {
369          const double    scalef = bsdf_rad/(log10(overall_max) - min_log10);
370 <        FVECT           ivec;
370 >        FVECT           ivec, sorg, nrm, upv;
371          RREAL           vMtx[3][3];
372          char            *fname;
373          char            cmdbuf[256];
374 <        char            xfargs[128];
375 <        int             nxfa;
374 >        char            rotargs[64];
375 >        int             nrota;
376          int             i;
377  
378          printf("\n# Gensurf output corresponding to %d incident directions\n",
379                          NINCIDENT);
380  
381          printf("\nvoid glow arrow_glow\n0\n0\n4 1 0 1 0\n");
382 <        printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void .5 .\n0\n0\n");
382 >        printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void 0.25 .\n0\n0\n");
383  
384 <        if (front_comp & SDsampR)
385 <                for (i = 0; i < NINCIDENT; i++) {
386 <                        get_ivector(ivec, i);
387 <                        put_mirror_arrow(ivec, 1);
388 <                        sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
389 <                                        ivec[0]*sph_rad - sph_xoffset,
390 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
391 <                        nxfa = 6;
384 >        for (i = 0; i < NINCIDENT; i++) {
385 >                get_ivector(ivec, i);
386 >                nrm[0] = -ivec[0]; nrm[1] = -ivec[1]; nrm[2] = ivec[2];
387 >                upv[0] = nrm[0]*nrm[1]*(nrm[2] - 1.);
388 >                upv[1] = nrm[0]*nrm[0] + nrm[1]*nrm[1]*nrm[2];
389 >                upv[2] = -nrm[1]*(nrm[0]*nrm[0] + nrm[1]*nrm[1]);
390 >                if (SDcompXform(vMtx, nrm, upv) != SDEnone)
391 >                        continue;
392 >                nrota = addrot(rotargs, vMtx[0], vMtx[1], vMtx[2]);
393 >                if (front_comp) {
394 >                        cvt_sposition(sorg, ivec, 1);
395                          printf("\nvoid colorfunc scale_pat\n");
396 <                        printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
397 <                                        4+nxfa, xfargs);
396 >                        printf("10 bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n");
397 >                        printf("\t-s %f -t %f %f %f\n0\n0\n",
398 >                                        bsdf_rad, sorg[0], sorg[1], sorg[2]);
399                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
400 <                        SDcompXform(vMtx, ivec, Yaxis);
401 <                        nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
402 <                        sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
396 <                                        scalef, ivec[0]*sph_rad - sph_xoffset,
397 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
398 <                        nxfa += 6;
400 >                }
401 >                if (front_comp & SDsampR) {
402 >                        put_mirror_arrow(sorg, nrm);
403                          fname = tfile_name(frpref, dsuffix, i);
404 <                        sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -mx -my %s",
405 <                                        frpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1,
406 <                                        xfargs);
404 >                        sprintf(cmdbuf,
405 >                "gensurf scale_mat %s%d %s %s %s %d %d | xform %s -s %f -t %f %f %f",
406 >                                        frpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1,
407 >                                        rotargs, scalef, sorg[0], sorg[1], sorg[2]);
408                          if (!run_cmd(cmdbuf))
409                                  return(0);
410                  }
411 <        if (front_comp & SDsampT)
412 <                for (i = 0; i < NINCIDENT; i++) {
408 <                        get_ivector(ivec, i);
409 <                        put_trans_arrow(ivec, 1);
410 <                        sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
411 <                                        ivec[0]*sph_rad - sph_xoffset,
412 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
413 <                        nxfa = 6;
414 <                        printf("\nvoid colorfunc scale_pat\n");
415 <                        printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
416 <                                        4+nxfa, xfargs);
417 <                        printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
418 <                        SDcompXform(vMtx, ivec, Yaxis);
419 <                        nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
420 <                        sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
421 <                                        scalef, ivec[0]*sph_rad - sph_xoffset,
422 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
423 <                        nxfa += 6;
411 >                if (front_comp & SDsampT) {
412 >                        put_trans_arrow(sorg);
413                          fname = tfile_name(ftpref, dsuffix, i);
414 <                        sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -I -mx -my %s",
415 <                                        ftpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1,
416 <                                        xfargs);
414 >                        sprintf(cmdbuf,
415 >                "gensurf scale_mat %s%d %s %s %s %d %d | xform -I %s -s %f -t %f %f %f",
416 >                                        ftpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1,
417 >                                        rotargs, scalef, sorg[0], sorg[1], sorg[2]);
418                          if (!run_cmd(cmdbuf))
419                                  return(0);
420                  }
421 <        if (back_comp & SDsampR)
422 <                for (i = 0; i < NINCIDENT; i++) {
433 <                        get_ivector(ivec, i);
434 <                        put_mirror_arrow(ivec, -1);
435 <                        fname = tfile_name(brpref, dsuffix, i);
436 <                        sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
437 <                                        ivec[0]*sph_rad + sph_xoffset,
438 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
439 <                        nxfa = 6;
421 >                if (back_comp) {
422 >                        cvt_sposition(sorg, ivec, -1);
423                          printf("\nvoid colorfunc scale_pat\n");
424 <                        printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
425 <                                        4+nxfa, xfargs);
424 >                        printf("10 bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n");
425 >                        printf("\t-s %f -t %f %f %f\n0\n0\n",
426 >                                        bsdf_rad, sorg[0], sorg[1], sorg[2]);
427                          printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
428 <                        SDcompXform(vMtx, ivec, Yaxis);
429 <                        nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
430 <                        sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
447 <                                        scalef, ivec[0]*sph_rad + sph_xoffset,
448 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
449 <                        nxfa += 6;
428 >                }
429 >                if (back_comp & SDsampR) {
430 >                        put_mirror_arrow(sorg, nrm);
431                          fname = tfile_name(brpref, dsuffix, i);
432 <                        sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -I -ry 180 -mx -my %s",
433 <                                        brpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1,
434 <                                        xfargs);
432 >                        sprintf(cmdbuf,
433 >                "gensurf scale_mat %s%d %s %s %s %d %d | xform -I -ry 180 %s -s %f -t %f %f %f",
434 >                                        brpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1,
435 >                                        rotargs, scalef, sorg[0], sorg[1], sorg[2]);
436                          if (!run_cmd(cmdbuf))
437                                  return(0);
438                  }
439 <        if (back_comp & SDsampT)
440 <                for (i = 0; i < NINCIDENT; i++) {
459 <                        get_ivector(ivec, i);
460 <                        put_trans_arrow(ivec, -1);
439 >                if (back_comp & SDsampT) {
440 >                        put_trans_arrow(sorg);
441                          fname = tfile_name(btpref, dsuffix, i);
442 <                        sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
443 <                                        ivec[0]*sph_rad + sph_xoffset,
444 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
445 <                        nxfa = 6;
466 <                        printf("\nvoid colorfunc scale_pat\n");
467 <                        printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
468 <                                        4+nxfa, xfargs);
469 <                        printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
470 <                        SDcompXform(vMtx, ivec, Yaxis);
471 <                        nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
472 <                        sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
473 <                                        scalef, ivec[0]*sph_rad + sph_xoffset,
474 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
475 <                        nxfa += 6;
476 <                        fname = tfile_name(btpref, dsuffix, i);
477 <                        sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -ry 180 -mx -my %s",
478 <                                        btpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1,
479 <                                        xfargs);
442 >                        sprintf(cmdbuf,
443 >                "gensurf scale_mat %s%d %s %s %s %d %d | xform -ry 180 %s -s %f -t %f %f %f",
444 >                                        btpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1,
445 >                                        rotargs, scalef, sorg[0], sorg[1], sorg[2]);
446                          if (!run_cmd(cmdbuf))
447                                  return(0);
448                  }
449 +        }
450          return(1);
451   }
452  
# Line 493 | Line 460 | put_matBSDF(const char *XMLfile)
460                  printf("\n# Simplified material because we have no XML input\n");
461                  printf("\nvoid brightfunc latlong\n2 latlong bsdf2rad.cal\n0\n0\n");
462                  if ((front_comp|back_comp) & SDsampT)
463 <                        printf("\nlatlong trans %s\n0\n0\n7 .75 .75 .75 0 0 .5 .8\n",
464 <                                        sph_mat);
463 >                        printf("\nlatlong trans %s\n0\n0\n7 .75 .75 .75 0 .04 .5 .8\n",
464 >                                        sph_fmat);
465                  else
466                          printf("\nlatlong plastic %s\n0\n0\n5 .5 .5 .5 0 0\n",
467 <                                        sph_mat);
467 >                                        sph_fmat);
468 >                printf("\ninherit alias %s %s\n", sph_bmat, sph_fmat);
469                  return;
470          }
471          switch (XMLfile[0]) {           /* avoid RAYPATH search */
472          case '.':
473 +        case '~':
474          CASEDIRSEP:
475                  curdir = "";
476                  break;
# Line 510 | Line 479 | put_matBSDF(const char *XMLfile)
479                  exit(1);
480                  break;
481          }
482 <        printf("\n# Actual BSDF material for rendering the hemispheres\n");
483 <        printf("\nvoid BSDF BSDFmat\n6 0 \"%s%s\" 0 1 0 .\n0\n0\n",
482 >        printf("\n# Actual BSDF materials for rendering the hemispheres\n");
483 >        printf("\nvoid BSDF BSDF_f\n6 0 \"%s%s\" upx upy upz bsdf2rad.cal\n0\n0\n",
484                          curdir, XMLfile);
485          printf("\nvoid plastic black\n0\n0\n5 0 0 0 0 0\n");
486 <        printf("\nvoid mixfunc %s\n4 BSDFmat black latlong bsdf2rad.cal\n0\n0\n",
487 <                        sph_mat);
486 >        printf("\nvoid mixfunc %s\n4 BSDF_f black latlong bsdf2rad.cal\n0\n0\n",
487 >                        sph_fmat);
488 >        printf("\nvoid BSDF BSDF_b\n8 0 \"%s%s\" upx upy upz bsdf2rad.cal -ry 180\n0\n0\n",
489 >                        curdir, XMLfile);
490 >        printf("\nvoid mixfunc %s\n4 BSDF_b black latlong bsdf2rad.cal\n0\n0\n",
491 >                        sph_bmat);
492   }
493  
494   /* Put out overhead parallel light source */
# Line 523 | Line 496 | static void
496   put_source(void)
497   {
498          printf("\n# Overhead parallel light source\n");
499 <        printf("\nvoid light bright\n0\n0\n3 2000 2000 2000\n");
499 >        printf("\nvoid light bright\n0\n0\n3 2500 2500 2500\n");
500          printf("\nbright source light\n0\n0\n4 0 0 1 2\n");
501          printf("\n# Material used for labels\n");
502          printf("\nvoid trans vellum\n0\n0\n7 1 1 1 0 0 .5 0\n");
# Line 533 | Line 506 | put_source(void)
506   static void
507   put_hemispheres(void)
508   {
509 +        const int       nsegs = 131;
510 +
511          printf("\n# Hemisphere(s) for showing BSDF appearance (if XML file)\n");
537        printf("\nvoid antimatter anti_sph\n2 void %s\n0\n0\n", sph_mat);
512          if (front_comp) {
513 <                printf("\n%s sphere Front\n0\n0\n4 %f 0 0 %f\n",
514 <                                sph_mat, -sph_xoffset, sph_rad);
515 <                printf("\n!genbox anti_sph sph_eraser %f %f %f | xform -t %f %f %f\n",
542 <                                2.02*sph_rad, 2.02*sph_rad, 1.02*sph_rad,
543 <                                -1.01*sph_rad - sph_xoffset, -1.01*sph_rad, -1.01*sph_rad);
513 >                printf(
514 > "\n!genrev %s Front \"R*sin(A*t)\" \"R*cos(A*t)\" %d -e \"R:%g;A:%f\" -s | xform -t %g 0 0\n",
515 >                                sph_fmat, nsegs, sph_rad, 0.495*PI, sph_xoffset);
516                  printf("\nvoid brighttext front_text\n3 helvet.fnt . FRONT\n0\n");
517                  printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n",
518 <                                -.22*sph_rad - sph_xoffset, -1.4*sph_rad,
518 >                                -.22*sph_rad + sph_xoffset, -1.4*sph_rad,
519                                  .35/5.*sph_rad, -1.6*.35/5.*sph_rad);
520                  printf("\nfront_text alias front_label_mat vellum\n");
521                  printf("\nfront_label_mat polygon front_label\n0\n0\n12");
522                  printf("\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n",
523 <                                -.25*sph_rad - sph_xoffset, -1.3*sph_rad,
524 <                                -.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad,
525 <                                .25*sph_rad - sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad,
526 <                                .25*sph_rad - sph_xoffset, -1.3*sph_rad );
523 >                                -.25*sph_rad + sph_xoffset, -1.3*sph_rad,
524 >                                -.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad,
525 >                                .25*sph_rad + sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad,
526 >                                .25*sph_rad + sph_xoffset, -1.3*sph_rad );
527          }
528          if (back_comp) {
529 <                printf("\n%s bubble Back\n0\n0\n4 %f 0 0 %f\n",
530 <                                sph_mat, sph_xoffset, sph_rad);
531 <                printf("\n!genbox anti_sph sph_eraser %f %f %f | xform -t %f %f %f\n",
560 <                                2.02*sph_rad, 2.02*sph_rad, 1.02*sph_rad,
561 <                                -1.01*sph_rad + sph_xoffset, -1.01*sph_rad, -1.01*sph_rad);
529 >                printf(
530 > "\n!genrev %s Back \"R*cos(A*t)\" \"R*sin(A*t)\" %d -e \"R:%g;A:%f\" -s | xform -t %g 0 0\n",
531 >                                sph_bmat, nsegs, sph_rad, 0.495*PI, -sph_xoffset);
532                  printf("\nvoid brighttext back_text\n3 helvet.fnt . BACK\n0\n");
533                  printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n",
534 <                                -.22*sph_rad + sph_xoffset, -1.4*sph_rad,
534 >                                -.22*sph_rad - sph_xoffset, -1.4*sph_rad,
535                                  .35/4.*sph_rad, -1.6*.35/4.*sph_rad);
536                  printf("\nback_text alias back_label_mat vellum\n");
537                  printf("\nback_label_mat polygon back_label\n0\n0\n12");
538                  printf("\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n",
539 <                                -.25*sph_rad + sph_xoffset, -1.3*sph_rad,
540 <                                -.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad,
541 <                                .25*sph_rad + sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad,
542 <                                .25*sph_rad + sph_xoffset, -1.3*sph_rad );
539 >                                -.25*sph_rad - sph_xoffset, -1.3*sph_rad,
540 >                                -.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad,
541 >                                .25*sph_rad - sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad,
542 >                                .25*sph_rad - sph_xoffset, -1.3*sph_rad );
543          }
544   }
545  
# Line 578 | Line 548 | static void
548   put_scale(void)
549   {
550          const double    max_log10 = log10(overall_max);
551 <        const double    leg_width = 2.*.75*(sph_xoffset - sph_rad);
551 >        const double    leg_width = 2.*.75*(fabs(sph_xoffset) - sph_rad);
552          const double    leg_height = 2.*sph_rad;
553          const int       text_lines = 6;
554          const int       text_digits = 8;
# Line 677 | Line 647 | convert_mgf(const char *mgfdata)
647                  sprintf(cmdbuf, "xform -t %f %f %f -s %f -t %f %f 0 %s",
648                                  -.5*(xmin+xmax), -.5*(ymin+ymax), -zmax,
649                                  1.5*sph_rad/max_dim,
650 <                                -sph_xoffset, -2.5*sph_rad,
650 >                                sph_xoffset, -2.5*sph_rad,
651                                  radfn);
652                  if (!run_cmd(cmdbuf))
653                          return;
# Line 687 | Line 657 | convert_mgf(const char *mgfdata)
657                  sprintf(cmdbuf, "xform -t %f %f %f -s %f -ry 180 -t %f %f 0 %s",
658                                  -.5*(xmin+xmax), -.5*(ymin+ymax), -zmin,
659                                  1.5*sph_rad/max_dim,
660 <                                sph_xoffset, -2.5*sph_rad,
660 >                                -sph_xoffset, -2.5*sph_rad,
661                                  radfn);
662                  if (!run_cmd(cmdbuf))
663                          return;
# Line 780 | Line 750 | main(int argc, char *argv[])
750                  strcpy(bsdf_manuf, myBSDF.makr);
751                  put_matBSDF(argv[1]);
752          } else {
753 <                FILE    *fp;
753 >                FILE    *fp[4];
754 >                if (argc > 5) {
755 >                        fprintf(stderr, "%s: more than 4 hemispheres!\n", progname);
756 >                        return(1);
757 >                }
758                  for (n = 1; n < argc; n++) {
759 <                        fp = fopen(argv[n], "rb");
760 <                        if (fp == NULL) {
759 >                        fp[n-1] = fopen(argv[n], "rb");
760 >                        if (fp[n-1] == NULL) {
761                                  fprintf(stderr, "%s: cannot open BSDF interpolant '%s'\n",
762                                                  progname, argv[n]);
763                                  return(1);
764                          }
765 <                        if (getheader(fp, rbf_headline, NULL) < 0) {
765 >                        if (getheader(fp[n-1], rbf_headline, NULL) < 0) {
766                                  fprintf(stderr, "%s: bad BSDF interpolant '%s'\n",
767                                                  progname, argv[n]);
768                                  return(1);
769                          }
796                        fclose(fp);
770                  }
771                  set_minlog();
772                  for (n = 1; n < argc; n++) {
773 <                        fp = fopen(argv[n], "rb");
774 <                        if (!load_bsdf_rep(fp))
773 >                        if (fseek(fp[n-1], 0L, SEEK_SET) < 0) {
774 >                                fprintf(stderr, "%s: cannot seek on '%s'\n",
775 >                                                progname, argv[n]);
776                                  return(1);
777 <                        fclose(fp);
777 >                        }
778 >                        if (!load_bsdf_rep(fp[n-1]))
779 >                                return(1);
780 >                        fclose(fp[n-1]);
781                          if (!build_wRBF())
782                                  return(1);
783                  }
# Line 811 | Line 788 | main(int argc, char *argv[])
788          put_scale();
789          if (inpXML && myBSDF.mgf)
790                  convert_mgf(myBSDF.mgf);
791 <        if (!put_BSDFs())
791 >        if (!put_BSDFs())               /* most of the output happens here */
792                  return(1);
793          cleanup_tmp();
794          return(0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines