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 |
– |
|
29 |
|
const char frpref[] = "frefl"; |
30 |
|
const char ftpref[] = "ftrans"; |
31 |
|
const char brpref[] = "brefl"; |
64 |
|
static RREAL * |
65 |
|
cvt_sposition(FVECT sp, const FVECT iv, int inc_side) |
66 |
|
{ |
67 |
< |
sp[0] = -iv[0]*sph_rad - inc_side*sph_xoffset; |
67 |
> |
sp[0] = -iv[0]*sph_rad + inc_side*sph_xoffset; |
68 |
|
sp[1] = -iv[1]*sph_rad; |
69 |
|
sp[2] = iv[2]*sph_rad; |
70 |
|
|
371 |
|
put_BSDFs(void) |
372 |
|
{ |
373 |
|
const double scalef = bsdf_rad/(log10(overall_max) - min_log10); |
374 |
< |
FVECT ivec, sorg; |
374 |
> |
FVECT ivec, sorg, upv; |
375 |
|
RREAL vMtx[3][3]; |
376 |
|
char *fname; |
377 |
|
char cmdbuf[256]; |
383 |
|
NINCIDENT); |
384 |
|
|
385 |
|
printf("\nvoid glow arrow_glow\n0\n0\n4 1 0 1 0\n"); |
386 |
< |
printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void .5 .\n0\n0\n"); |
386 |
> |
printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void 0.25 .\n0\n0\n"); |
387 |
|
|
388 |
|
if (front_comp & SDsampR) /* front reflection */ |
389 |
|
for (i = 0; i < NINCIDENT; i++) { |
391 |
|
put_mirror_arrow(ivec, 1); |
392 |
|
cvt_sposition(sorg, ivec, 1); |
393 |
|
ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */ |
394 |
+ |
upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.); |
395 |
+ |
upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2]; |
396 |
+ |
upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]); |
397 |
|
sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad, |
398 |
|
sorg[0], sorg[1], sorg[2]); |
399 |
|
nxfa = 6; |
401 |
|
printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n", |
402 |
|
4+nxfa, xfargs); |
403 |
|
printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n"); |
404 |
< |
SDcompXform(vMtx, ivec, Yaxis); |
404 |
> |
if (SDcompXform(vMtx, ivec, upv) != SDEnone) |
405 |
> |
continue; |
406 |
|
nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]); |
407 |
|
sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f", |
408 |
|
scalef, sorg[0], sorg[1], sorg[2]); |
409 |
|
nxfa += 6; |
410 |
|
fname = tfile_name(frpref, dsuffix, i); |
411 |
|
sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform %s", |
412 |
< |
frpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
412 |
> |
frpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
413 |
|
xfargs); |
414 |
|
if (!run_cmd(cmdbuf)) |
415 |
|
return(0); |
420 |
|
put_trans_arrow(ivec, 1); |
421 |
|
cvt_sposition(sorg, ivec, 1); |
422 |
|
ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */ |
423 |
+ |
upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.); |
424 |
+ |
upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2]; |
425 |
+ |
upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]); |
426 |
|
sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad, |
427 |
|
sorg[0], sorg[1], sorg[2]); |
428 |
|
nxfa = 6; |
430 |
|
printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n", |
431 |
|
4+nxfa, xfargs); |
432 |
|
printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n"); |
433 |
< |
SDcompXform(vMtx, ivec, Yaxis); |
433 |
> |
if (SDcompXform(vMtx, ivec, upv) != SDEnone) |
434 |
> |
continue; |
435 |
|
nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]); |
436 |
|
sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f", |
437 |
|
scalef, sorg[0], sorg[1], sorg[2]); |
438 |
|
nxfa += 6; |
439 |
|
fname = tfile_name(ftpref, dsuffix, i); |
440 |
|
sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -I %s", |
441 |
< |
ftpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
441 |
> |
ftpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
442 |
|
xfargs); |
443 |
|
if (!run_cmd(cmdbuf)) |
444 |
|
return(0); |
449 |
|
put_mirror_arrow(ivec, -1); |
450 |
|
cvt_sposition(sorg, ivec, -1); |
451 |
|
ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */ |
452 |
+ |
upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.); |
453 |
+ |
upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2]; |
454 |
+ |
upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]); |
455 |
|
sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad, |
456 |
|
sorg[0], sorg[1], sorg[2]); |
457 |
|
nxfa = 6; |
459 |
|
printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n", |
460 |
|
4+nxfa, xfargs); |
461 |
|
printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n"); |
462 |
< |
SDcompXform(vMtx, ivec, Yaxis); |
462 |
> |
if (SDcompXform(vMtx, ivec, upv) != SDEnone) |
463 |
> |
continue; |
464 |
|
nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]); |
465 |
|
sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f", |
466 |
|
scalef, sorg[0], sorg[1], sorg[2]); |
467 |
|
nxfa += 6; |
468 |
|
fname = tfile_name(brpref, dsuffix, i); |
469 |
|
sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -I -ry 180 %s", |
470 |
< |
brpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
470 |
> |
brpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
471 |
|
xfargs); |
472 |
|
if (!run_cmd(cmdbuf)) |
473 |
|
return(0); |
478 |
|
put_trans_arrow(ivec, -1); |
479 |
|
cvt_sposition(sorg, ivec, -1); |
480 |
|
ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */ |
481 |
+ |
upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.); |
482 |
+ |
upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2]; |
483 |
+ |
upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]); |
484 |
|
sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad, |
485 |
|
sorg[0], sorg[1], sorg[2]); |
486 |
|
nxfa = 6; |
488 |
|
printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n", |
489 |
|
4+nxfa, xfargs); |
490 |
|
printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n"); |
491 |
< |
SDcompXform(vMtx, ivec, Yaxis); |
491 |
> |
if (SDcompXform(vMtx, ivec, upv) != SDEnone) |
492 |
> |
continue; |
493 |
|
nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]); |
494 |
|
sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f", |
495 |
|
scalef, sorg[0], sorg[1], sorg[2]); |
496 |
|
nxfa += 6; |
497 |
|
fname = tfile_name(btpref, dsuffix, i); |
498 |
|
sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -ry 180 %s", |
499 |
< |
btpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
499 |
> |
btpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
500 |
|
xfargs); |
501 |
|
if (!run_cmd(cmdbuf)) |
502 |
|
return(0); |
514 |
|
printf("\n# Simplified material because we have no XML input\n"); |
515 |
|
printf("\nvoid brightfunc latlong\n2 latlong bsdf2rad.cal\n0\n0\n"); |
516 |
|
if ((front_comp|back_comp) & SDsampT) |
517 |
< |
printf("\nlatlong trans %s\n0\n0\n7 .75 .75 .75 0 0 .5 .8\n", |
517 |
> |
printf("\nlatlong trans %s\n0\n0\n7 .75 .75 .75 0 .04 .5 .8\n", |
518 |
|
sph_mat); |
519 |
|
else |
520 |
|
printf("\nlatlong plastic %s\n0\n0\n5 .5 .5 .5 0 0\n", |
532 |
|
break; |
533 |
|
} |
534 |
|
printf("\n# Actual BSDF material for rendering the hemispheres\n"); |
535 |
< |
printf("\nvoid BSDF BSDFmat\n6 0 \"%s%s\" 0 1 0 .\n0\n0\n", |
535 |
> |
printf("\nvoid BSDF BSDFmat\n6 0 \"%s%s\" upx upy upz bsdf2rad.cal\n0\n0\n", |
536 |
|
curdir, XMLfile); |
537 |
|
printf("\nvoid plastic black\n0\n0\n5 0 0 0 0 0\n"); |
538 |
|
printf("\nvoid mixfunc %s\n4 BSDFmat black latlong bsdf2rad.cal\n0\n0\n", |
544 |
|
put_source(void) |
545 |
|
{ |
546 |
|
printf("\n# Overhead parallel light source\n"); |
547 |
< |
printf("\nvoid light bright\n0\n0\n3 2000 2000 2000\n"); |
547 |
> |
printf("\nvoid light bright\n0\n0\n3 2500 2500 2500\n"); |
548 |
|
printf("\nbright source light\n0\n0\n4 0 0 1 2\n"); |
549 |
|
printf("\n# Material used for labels\n"); |
550 |
|
printf("\nvoid trans vellum\n0\n0\n7 1 1 1 0 0 .5 0\n"); |
554 |
|
static void |
555 |
|
put_hemispheres(void) |
556 |
|
{ |
557 |
+ |
const int nsegs = 131; |
558 |
+ |
|
559 |
|
printf("\n# Hemisphere(s) for showing BSDF appearance (if XML file)\n"); |
546 |
– |
printf("\nvoid antimatter anti_sph\n2 void %s\n0\n0\n", sph_mat); |
560 |
|
if (front_comp) { |
561 |
< |
printf("\n%s sphere Front\n0\n0\n4 %f 0 0 %f\n", |
562 |
< |
sph_mat, -sph_xoffset, sph_rad); |
563 |
< |
printf("\n!genbox anti_sph sph_eraser %f %f %f | xform -t %f %f %f\n", |
551 |
< |
2.02*sph_rad, 2.02*sph_rad, 1.02*sph_rad, |
552 |
< |
-1.01*sph_rad - sph_xoffset, -1.01*sph_rad, -1.01*sph_rad); |
561 |
> |
printf( |
562 |
> |
"\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", |
563 |
> |
sph_mat, nsegs, sph_rad, 0.495*PI, sph_xoffset); |
564 |
|
printf("\nvoid brighttext front_text\n3 helvet.fnt . FRONT\n0\n"); |
565 |
|
printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n", |
566 |
< |
-.22*sph_rad - sph_xoffset, -1.4*sph_rad, |
566 |
> |
-.22*sph_rad + sph_xoffset, -1.4*sph_rad, |
567 |
|
.35/5.*sph_rad, -1.6*.35/5.*sph_rad); |
568 |
|
printf("\nfront_text alias front_label_mat vellum\n"); |
569 |
|
printf("\nfront_label_mat polygon front_label\n0\n0\n12"); |
570 |
|
printf("\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n", |
571 |
< |
-.25*sph_rad - sph_xoffset, -1.3*sph_rad, |
572 |
< |
-.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad, |
573 |
< |
.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad, |
574 |
< |
.25*sph_rad - sph_xoffset, -1.3*sph_rad ); |
571 |
> |
-.25*sph_rad + sph_xoffset, -1.3*sph_rad, |
572 |
> |
-.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad, |
573 |
> |
.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad, |
574 |
> |
.25*sph_rad + sph_xoffset, -1.3*sph_rad ); |
575 |
|
} |
576 |
|
if (back_comp) { |
577 |
< |
printf("\n%s bubble Back\n0\n0\n4 %f 0 0 %f\n", |
578 |
< |
sph_mat, sph_xoffset, sph_rad); |
579 |
< |
printf("\n!genbox anti_sph sph_eraser %f %f %f | xform -t %f %f %f\n", |
569 |
< |
2.02*sph_rad, 2.02*sph_rad, 1.02*sph_rad, |
570 |
< |
-1.01*sph_rad + sph_xoffset, -1.01*sph_rad, -1.01*sph_rad); |
577 |
> |
printf( |
578 |
> |
"\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", |
579 |
> |
sph_mat, nsegs, sph_rad, 0.495*PI, -sph_xoffset); |
580 |
|
printf("\nvoid brighttext back_text\n3 helvet.fnt . BACK\n0\n"); |
581 |
|
printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n", |
582 |
< |
-.22*sph_rad + sph_xoffset, -1.4*sph_rad, |
582 |
> |
-.22*sph_rad - sph_xoffset, -1.4*sph_rad, |
583 |
|
.35/4.*sph_rad, -1.6*.35/4.*sph_rad); |
584 |
|
printf("\nback_text alias back_label_mat vellum\n"); |
585 |
|
printf("\nback_label_mat polygon back_label\n0\n0\n12"); |
586 |
|
printf("\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n", |
587 |
< |
-.25*sph_rad + sph_xoffset, -1.3*sph_rad, |
588 |
< |
-.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad, |
589 |
< |
.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad, |
590 |
< |
.25*sph_rad + sph_xoffset, -1.3*sph_rad ); |
587 |
> |
-.25*sph_rad - sph_xoffset, -1.3*sph_rad, |
588 |
> |
-.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad, |
589 |
> |
.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad, |
590 |
> |
.25*sph_rad - sph_xoffset, -1.3*sph_rad ); |
591 |
|
} |
592 |
|
} |
593 |
|
|
596 |
|
put_scale(void) |
597 |
|
{ |
598 |
|
const double max_log10 = log10(overall_max); |
599 |
< |
const double leg_width = 2.*.75*(sph_xoffset - sph_rad); |
599 |
> |
const double leg_width = 2.*.75*(fabs(sph_xoffset) - sph_rad); |
600 |
|
const double leg_height = 2.*sph_rad; |
601 |
|
const int text_lines = 6; |
602 |
|
const int text_digits = 8; |
695 |
|
sprintf(cmdbuf, "xform -t %f %f %f -s %f -t %f %f 0 %s", |
696 |
|
-.5*(xmin+xmax), -.5*(ymin+ymax), -zmax, |
697 |
|
1.5*sph_rad/max_dim, |
698 |
< |
-sph_xoffset, -2.5*sph_rad, |
698 |
> |
sph_xoffset, -2.5*sph_rad, |
699 |
|
radfn); |
700 |
|
if (!run_cmd(cmdbuf)) |
701 |
|
return; |
705 |
|
sprintf(cmdbuf, "xform -t %f %f %f -s %f -ry 180 -t %f %f 0 %s", |
706 |
|
-.5*(xmin+xmax), -.5*(ymin+ymax), -zmin, |
707 |
|
1.5*sph_rad/max_dim, |
708 |
< |
sph_xoffset, -2.5*sph_rad, |
708 |
> |
-sph_xoffset, -2.5*sph_rad, |
709 |
|
radfn); |
710 |
|
if (!run_cmd(cmdbuf)) |
711 |
|
return; |