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

Comparing ray/src/cv/mgf2rad.c (file contents):
Revision 2.1 by greg, Wed Jun 22 15:33:03 1994 UTC vs.
Revision 2.6 by greg, Fri Jul 1 18:06:36 1994 UTC

# Line 17 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17  
18   #define putv(v)         printf("%18.12g %18.12g %18.12g\n",(v)[0],(v)[1],(v)[2])
19  
20 < #define isgrey(cxy)     ((cxy)->cx > .31 && (cxy)->cx < .35 && \
21 <                        (cxy)->cy > .31 && (cxy)->cy < .35)
20 > double  glowdist = FHUGE;               /* glow test distance */
21  
23 #define is0vect(v)      ((v)[0] == 0. && (v)[1] == 0. && (v)[2] == 0.)
24
25 #define BIGFLT          1e8
26
27 double  glowdist = 1.5*BIGFLT;          /* glow test distance */
28
22   double  emult = 1.;                     /* emmitter multiplier */
23  
24   int     r_comment(), r_cone(), r_cyl(), r_face(), r_ies(), r_ring(), r_sph();
# Line 41 | Line 34 | char   *argv[];
34          mg_ehand[MG_E_COMMENT] = r_comment;
35          mg_ehand[MG_E_COLOR] = c_hcolor;
36          mg_ehand[MG_E_CONE] = r_cone;
37 +        mg_ehand[MG_E_CMIX] = c_hcolor;
38 +        mg_ehand[MG_E_CSPEC] = c_hcolor;
39          mg_ehand[MG_E_CXY] = c_hcolor;
40          mg_ehand[MG_E_CYL] = r_cyl;
41          mg_ehand[MG_E_ED] = c_hmaterial;
# Line 53 | Line 48 | char   *argv[];
48          mg_ehand[MG_E_RD] = c_hmaterial;
49          mg_ehand[MG_E_RING] = r_ring;
50          mg_ehand[MG_E_RS] = c_hmaterial;
51 +        mg_ehand[MG_E_SIDES] = c_hmaterial;
52          mg_ehand[MG_E_SPH] = r_sph;
53          mg_ehand[MG_E_TD] = c_hmaterial;
54          mg_ehand[MG_E_TS] = c_hmaterial;
# Line 280 | Line 276 | char   **av;
276                  return(MG_EARGC);
277          if ((mat = material()) == NULL)
278                  return(MG_EBADMAT);
279 <        if (ac < 5) {                           /* check for surface normals */
279 >        if (ac <= 5) {                          /* check for surface normals */
280                  for (i = 1; i < ac; i++) {
281                          if ((cv = c_getvert(av[i])) == NULL)
282                                  return(MG_EUNDEF);
# Line 344 | Line 340 | char   **av;
340                                          /* put out xform command */
341          printf("\n!xform");
342          oname = object();
343 <        if (*oname)
344 <                printf(" -n %s", oname);
343 >        if (*oname) {
344 >                printf(" -n ");
345 >                for (op = oname; op[1]; op++)   /* remove trailing separator */
346 >                        putchar(*op);
347 >        }
348          for (i = xa0; i < ac; i++)
349                  printf(" %s", av[i]);
350          if (ac > xa0 && xf_argc > 0)
# Line 361 | Line 360 | do_tri(mat, vn1, vn2, vn3)             /* put out smoothed triang
360   char    *mat, *vn1, *vn2, *vn3;
361   {
362          static int      ntris;
364        char    *mod = mat;
363          BARYCCM bvecs;
364          FLOAT   bcoor[3][3];
365          C_VERTEX        *cv1, *cv2, *cv3;
# Line 375 | Line 373 | char   *mat, *vn1, *vn2, *vn3;
373          xf_xfmpoint(v1, cv1->p);
374          xf_xfmpoint(v2, cv2->p);
375          xf_xfmpoint(v3, cv3->p);
376 <        if (comp_baryc(&bvecs, v1, v2, v3) == 0) {
377 <                printf("\n%s texfunc T-nor\n", mod);
378 <                mod = "T-nor";
379 <                printf("4 dx dy dz %s\n0\n", TCALNAME);
380 <                xf_rotvect(n1, cv1->n);
381 <                xf_rotvect(n2, cv2->n);
382 <                xf_rotvect(n3, cv3->n);
383 <                for (i = 0; i < 3; i++) {
384 <                        bcoor[i][0] = n1[i];
385 <                        bcoor[i][1] = n2[i];
386 <                        bcoor[i][2] = n3[i];
389 <                }
390 <                put_baryc(&bvecs, bcoor, 3);
376 >        if (comp_baryc(&bvecs, v1, v2, v3) < 0)
377 >                return;                         /* degenerate triangle! */
378 >        printf("\n%s texfunc T-nor\n", mat);
379 >        printf("4 dx dy dz %s\n0\n", TCALNAME);
380 >        xf_rotvect(n1, cv1->n);
381 >        xf_rotvect(n2, cv2->n);
382 >        xf_rotvect(n3, cv3->n);
383 >        for (i = 0; i < 3; i++) {
384 >                bcoor[i][0] = n1[i];
385 >                bcoor[i][1] = n2[i];
386 >                bcoor[i][2] = n3[i];
387          }
388 <        printf("\n%s polygon %st%d\n", mod, object(), ++ntris);
388 >        put_baryc(&bvecs, bcoor, 3);
389 >        printf("\nT-nor polygon %st%d\n", object(), ++ntris);
390          printf("0\n0\n9\n");
391          putv(v1);
392          putv(v2);
# Line 405 | Line 402 | material()                     /* get (and print) current material */
402          double  d;
403          register int    i;
404  
405 <        if (c_cmaterial->name != NULL)
406 <                mname = c_cmaterial->name;
405 >        if (c_cmname != NULL)
406 >                mname = c_cmname;
407          if (!c_cmaterial->clock)
408                  return(mname);          /* already current */
409                                  /* else update output */
# Line 414 | Line 411 | material()                     /* get (and print) current material */
411          if (c_cmaterial->ed > .1) {     /* emitter */
412                  cvtcolor(radrgb, &c_cmaterial->ed_c,
413                                  emult*c_cmaterial->ed/WHTEFFICACY);
414 <                if (glowdist < BIGFLT) {        /* do a glow */
414 >                if (glowdist < FHUGE) {         /* do a glow */
415                          printf("\nvoid glow %s\n0\n0\n", mname);
416                          printf("4 %f %f %f %f\n", colval(radrgb,RED),
417                                          colval(radrgb,GRN),
# Line 431 | Line 428 | material()                     /* get (and print) current material */
428                          c_cmaterial->rs + c_cmaterial->ts;
429          if (d <= 0. | d >= 1.)
430                  return(NULL);
431 <        if (c_cmaterial->td > .01 || c_cmaterial->ts > .01) {   /* trans */
431 >                                        /* check for trans */
432 >        if (c_cmaterial->td > .01 || c_cmaterial->ts > .01) {
433                  double  ts, a5, a6;
434  
435 <                ts = sqrt(c_cmaterial->ts);     /* because we use 2 sides */
435 >                if (c_cmaterial->sided) {
436 >                        ts = sqrt(c_cmaterial->ts);     /* approximate */
437 >                        a5 = .5;
438 >                } else
439 >                        a5 = 1.;
440                                                  /* average colors */
441                  d = c_cmaterial->rd + c_cmaterial->td + ts;
442                  cvtcolor(radrgb, &c_cmaterial->rd_c, c_cmaterial->rd/d);
# Line 444 | Line 446 | material()                     /* get (and print) current material */
446                  addcolor(radrgb, c2);
447                  if (c_cmaterial->rs + ts > .0001)
448                          a5 = (c_cmaterial->rs*c_cmaterial->rs_a +
449 <                                        ts*.5*c_cmaterial->ts_a) /
449 >                                        ts*a5*c_cmaterial->ts_a) /
450                                          (c_cmaterial->rs + ts);
451                  a6 = (c_cmaterial->td + ts) /
452                                  (c_cmaterial->rd + c_cmaterial->td + ts);
# Line 459 | Line 461 | material()                     /* get (and print) current material */
461                                  ts/(ts + c_cmaterial->td));
462                  return(mname);
463          }
464 <        if (c_cmaterial->rs < .01 || isgrey(&c_cmaterial->rs_c)) { /* plastic */
464 >                                        /* check for plastic */
465 >        if (c_cmaterial->rs < .01 || c_isgrey(&c_cmaterial->rs_c)) {
466                  if (c_cmaterial->rs > .999)
467                          cvtcolor(radrgb, &c_cmaterial->rd_c, 1.);
468                  else
# Line 495 | Line 498 | double intensity;
498   {
499          static COLOR    ciexyz;
500  
501 +        c_ccvt(ciec, C_CSXY);           /* get xy representation */
502          ciexyz[1] = intensity;
503          ciexyz[0] = ciec->cx/ciec->cy*ciexyz[1];
504          ciexyz[2] = ciexyz[1]*(1./ciec->cy - 1.) - ciexyz[0];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines