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.17 by greg, Sun Apr 9 22:06:07 2017 UTC vs.
Revision 2.27 by greg, Wed Apr 12 04:15:08 2017 UTC

# Line 13 | Line 13 | static const char RCSid[] = "$Id$";
13   #include "resolu.h"
14   #include "bsdfrep.h"
15  
16 < #define NINCIDENT       25              /* number of samples/hemisphere */
16 > #define NINCIDENT       37              /* number of samples/hemisphere */
17  
18   #define GRIDSTEP        2               /* our grid step size */
19   #define SAMPRES         (GRIDRES/GRIDSTEP)
# 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   {
56        const double    zstep = 1./(2*NINCIDENT-1);
53          const double    phistep = PI*(3. - 2.236067978);
54          double          r;
55  
56 <        iv[2] = 1. - (i+.5)*zstep;
56 >        iv[2] = 1. - (i+.5)*(1./NINCIDENT);
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 249 | 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 261 | 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  
274        refl[0] = 2.*ivec[2]*ivec[0];
275        refl[1] = 2.*ivec[2]*ivec[1];
276        refl[2] = 2.*ivec[2]*ivec[2] - 1.;
277
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 301 | 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;
308        FVECT           origin;
314          int             i;
315  
311        for (i = 3; i--; ) origin[i] = ivec[i]*sph_rad;
312        origin[0] -= inc_side*sph_xoffset;
313
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 365 | 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",
397 <                                        scalef, ivec[0]*sph_rad - sph_xoffset,
398 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
399 <                        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++) {
409 <                        get_ivector(ivec, i);
410 <                        put_trans_arrow(ivec, 1);
411 <                        sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
412 <                                        ivec[0]*sph_rad - sph_xoffset,
413 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
414 <                        nxfa = 6;
415 <                        printf("\nvoid colorfunc scale_pat\n");
416 <                        printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
417 <                                        4+nxfa, xfargs);
418 <                        printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
419 <                        SDcompXform(vMtx, ivec, Yaxis);
420 <                        nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
421 <                        sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
422 <                                        scalef, ivec[0]*sph_rad - sph_xoffset,
423 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
424 <                        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++) {
434 <                        get_ivector(ivec, i);
435 <                        put_mirror_arrow(ivec, -1);
436 <                        fname = tfile_name(brpref, dsuffix, i);
437 <                        sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad,
438 <                                        ivec[0]*sph_rad + sph_xoffset,
439 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
440 <                        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",
448 <                                        scalef, ivec[0]*sph_rad + sph_xoffset,
449 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
450 <                        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++) {
460 <                        get_ivector(ivec, i);
461 <                        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;
467 <                        printf("\nvoid colorfunc scale_pat\n");
468 <                        printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n",
469 <                                        4+nxfa, xfargs);
470 <                        printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n");
471 <                        SDcompXform(vMtx, ivec, Yaxis);
472 <                        nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]);
473 <                        sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f",
474 <                                        scalef, ivec[0]*sph_rad + sph_xoffset,
475 <                                        ivec[1]*sph_rad, ivec[2]*sph_rad);
476 <                        nxfa += 6;
477 <                        fname = tfile_name(btpref, dsuffix, i);
478 <                        sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -ry 180 -mx -my %s",
479 <                                        btpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1,
480 <                                        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 494 | 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 */
# Line 511 | Line 478 | put_matBSDF(const char *XMLfile)
478                  exit(1);
479                  break;
480          }
481 <        printf("\n# Actual BSDF material for rendering the hemispheres\n");
482 <        printf("\nvoid BSDF BSDFmat\n6 0 \"%s%s\" 0 1 0 .\n0\n0\n",
481 >        printf("\n# Actual BSDF materials for rendering the hemispheres\n");
482 >        printf("\nvoid BSDF BSDF_f\n6 0 \"%s%s\" upx upy upz bsdf2rad.cal\n0\n0\n",
483                          curdir, XMLfile);
484          printf("\nvoid plastic black\n0\n0\n5 0 0 0 0 0\n");
485 <        printf("\nvoid mixfunc %s\n4 BSDFmat black latlong bsdf2rad.cal\n0\n0\n",
486 <                        sph_mat);
485 >        printf("\nvoid mixfunc %s\n4 BSDF_f black latlong bsdf2rad.cal\n0\n0\n",
486 >                        sph_fmat);
487 >        printf("\nvoid BSDF BSDF_b\n8 0 \"%s%s\" upx upy upz bsdf2rad.cal -ry 180\n0\n0\n",
488 >                        curdir, XMLfile);
489 >        printf("\nvoid mixfunc %s\n4 BSDF_b black latlong bsdf2rad.cal\n0\n0\n",
490 >                        sph_bmat);
491   }
492  
493   /* Put out overhead parallel light source */
# Line 524 | Line 495 | static void
495   put_source(void)
496   {
497          printf("\n# Overhead parallel light source\n");
498 <        printf("\nvoid light bright\n0\n0\n3 2000 2000 2000\n");
498 >        printf("\nvoid light bright\n0\n0\n3 2500 2500 2500\n");
499          printf("\nbright source light\n0\n0\n4 0 0 1 2\n");
500          printf("\n# Material used for labels\n");
501          printf("\nvoid trans vellum\n0\n0\n7 1 1 1 0 0 .5 0\n");
# Line 534 | Line 505 | put_source(void)
505   static void
506   put_hemispheres(void)
507   {
508 +        const int       nsegs = 131;
509 +
510          printf("\n# Hemisphere(s) for showing BSDF appearance (if XML file)\n");
538        printf("\nvoid antimatter anti_sph\n2 void %s\n0\n0\n", sph_mat);
511          if (front_comp) {
512 <                printf("\n%s sphere Front\n0\n0\n4 %f 0 0 %f\n",
513 <                                sph_mat, -sph_xoffset, sph_rad);
514 <                printf("\n!genbox anti_sph sph_eraser %f %f %f | xform -t %f %f %f\n",
543 <                                2.02*sph_rad, 2.02*sph_rad, 1.02*sph_rad,
544 <                                -1.01*sph_rad - sph_xoffset, -1.01*sph_rad, -1.01*sph_rad);
512 >                printf(
513 > "\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",
514 >                                sph_fmat, nsegs, sph_rad, 0.495*PI, sph_xoffset);
515                  printf("\nvoid brighttext front_text\n3 helvet.fnt . FRONT\n0\n");
516                  printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n",
517 <                                -.22*sph_rad - sph_xoffset, -1.2*sph_rad,
517 >                                -.22*sph_rad + sph_xoffset, -1.4*sph_rad,
518                                  .35/5.*sph_rad, -1.6*.35/5.*sph_rad);
519                  printf("\nfront_text alias front_label_mat vellum\n");
520                  printf("\nfront_label_mat polygon front_label\n0\n0\n12");
521                  printf("\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n",
522 <                                -.25*sph_rad - sph_xoffset, -1.1*sph_rad,
523 <                                -.25*sph_rad - sph_xoffset, (-1.2-1.6*.35/5.-.1)*sph_rad,
524 <                                .25*sph_rad - sph_xoffset, (-1.2-1.6*.35/5.-.1)*sph_rad,
525 <                                .25*sph_rad - sph_xoffset, -1.1*sph_rad );
522 >                                -.25*sph_rad + sph_xoffset, -1.3*sph_rad,
523 >                                -.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad,
524 >                                .25*sph_rad + sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad,
525 >                                .25*sph_rad + sph_xoffset, -1.3*sph_rad );
526          }
527          if (back_comp) {
528 <                printf("\n%s bubble Back\n0\n0\n4 %f 0 0 %f\n",
529 <                                sph_mat, sph_xoffset, sph_rad);
530 <                printf("\n!genbox anti_sph sph_eraser %f %f %f | xform -t %f %f %f\n",
561 <                                2.02*sph_rad, 2.02*sph_rad, 1.02*sph_rad,
562 <                                -1.01*sph_rad + sph_xoffset, -1.01*sph_rad, -1.01*sph_rad);
528 >                printf(
529 > "\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",
530 >                                sph_bmat, nsegs, sph_rad, 0.495*PI, -sph_xoffset);
531                  printf("\nvoid brighttext back_text\n3 helvet.fnt . BACK\n0\n");
532                  printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n",
533 <                                -.22*sph_rad + sph_xoffset, -1.2*sph_rad,
533 >                                -.22*sph_rad - sph_xoffset, -1.4*sph_rad,
534                                  .35/4.*sph_rad, -1.6*.35/4.*sph_rad);
535                  printf("\nback_text alias back_label_mat vellum\n");
536                  printf("\nback_label_mat polygon back_label\n0\n0\n12");
537                  printf("\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n",
538 <                                -.25*sph_rad + sph_xoffset, -1.1*sph_rad,
539 <                                -.25*sph_rad + sph_xoffset, (-1.2-1.6*.35/4.-.1)*sph_rad,
540 <                                .25*sph_rad + sph_xoffset, (-1.2-1.6*.35/4.-.1)*sph_rad,
541 <                                .25*sph_rad + sph_xoffset, -1.1*sph_rad );
538 >                                -.25*sph_rad - sph_xoffset, -1.3*sph_rad,
539 >                                -.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad,
540 >                                .25*sph_rad - sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad,
541 >                                .25*sph_rad - sph_xoffset, -1.3*sph_rad );
542          }
543   }
544  
# Line 579 | Line 547 | static void
547   put_scale(void)
548   {
549          const double    max_log10 = log10(overall_max);
550 <        const double    leg_width = 2.*.75*(sph_xoffset - sph_rad);
550 >        const double    leg_width = 2.*.75*(fabs(sph_xoffset) - sph_rad);
551          const double    leg_height = 2.*sph_rad;
552          const int       text_lines = 6;
553          const int       text_digits = 8;
# Line 623 | Line 591 | put_scale(void)
591                  return;
592          printf("\nvoid brighttext BSDFname\n3 helvet.fnt . \"%s\"\n0\n12\n", bsdf_name);
593          printf("\t%f %f 0\n", -.95*leg_width, -.6*leg_height);
594 <        printf("\t%f 0 0\n", .4/strlen(bsdf_name)*leg_width);
594 >        printf("\t%f 0 0\n", 1.8/strlen(bsdf_name)*leg_width);
595          printf("\t0 %f 0\n", -.1*leg_height);
596          printf("\t.01 1 -.1\n");
597          printf("\nBSDFname alias name_mat vellum\n");
# Line 678 | Line 646 | convert_mgf(const char *mgfdata)
646                  sprintf(cmdbuf, "xform -t %f %f %f -s %f -t %f %f 0 %s",
647                                  -.5*(xmin+xmax), -.5*(ymin+ymax), -zmax,
648                                  1.5*sph_rad/max_dim,
649 <                                -sph_xoffset, -2.5*sph_rad,
649 >                                sph_xoffset, -2.5*sph_rad,
650                                  radfn);
651                  if (!run_cmd(cmdbuf))
652                          return;
# Line 688 | Line 656 | convert_mgf(const char *mgfdata)
656                  sprintf(cmdbuf, "xform -t %f %f %f -s %f -ry 180 -t %f %f 0 %s",
657                                  -.5*(xmin+xmax), -.5*(ymin+ymax), -zmin,
658                                  1.5*sph_rad/max_dim,
659 <                                sph_xoffset, -2.5*sph_rad,
659 >                                -sph_xoffset, -2.5*sph_rad,
660                                  radfn);
661                  if (!run_cmd(cmdbuf))
662                          return;
# Line 781 | Line 749 | main(int argc, char *argv[])
749                  strcpy(bsdf_manuf, myBSDF.makr);
750                  put_matBSDF(argv[1]);
751          } else {
752 <                FILE    *fp;
752 >                FILE    *fp[4];
753 >                if (argc > 5) {
754 >                        fprintf(stderr, "%s: too many input files\n", progname);
755 >                        return(1);
756 >                }
757                  for (n = 1; n < argc; n++) {
758 <                        fp = fopen(argv[n], "rb");
759 <                        if (fp == NULL) {
758 >                        fp[n-1] = fopen(argv[n], "rb");
759 >                        if (fp[n-1] == NULL) {
760                                  fprintf(stderr, "%s: cannot open BSDF interpolant '%s'\n",
761                                                  progname, argv[n]);
762                                  return(1);
763                          }
764 <                        if (getheader(fp, rbf_headline, NULL) < 0) {
764 >                        if (getheader(fp[n-1], rbf_headline, NULL) < 0) {
765                                  fprintf(stderr, "%s: bad BSDF interpolant '%s'\n",
766                                                  progname, argv[n]);
767                                  return(1);
768                          }
797                        fclose(fp);
769                  }
770                  set_minlog();
771                  for (n = 1; n < argc; n++) {
772 <                        fp = fopen(argv[n], "rb");
773 <                        if (!load_bsdf_rep(fp))
772 >                        if (fseek(fp[n-1], 0L, SEEK_SET) < 0) {
773 >                                fprintf(stderr, "%s: cannot seek on '%s'\n",
774 >                                                progname, argv[n]);
775                                  return(1);
776 <                        fclose(fp);
776 >                        }
777 >                        if (!load_bsdf_rep(fp[n-1]))
778 >                                return(1);
779 >                        fclose(fp[n-1]);
780                          if (!build_wRBF())
781                                  return(1);
782                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines