| 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"; |
| 32 |
|
const char btpref[] = "btrans"; |
| 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 |
|
|
| 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; |
| 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 |
|
|
| 372 |
|
put_BSDFs(void) |
| 373 |
|
{ |
| 374 |
|
const double scalef = bsdf_rad/(log10(overall_max) - min_log10); |
| 375 |
< |
FVECT ivec, sorg; |
| 375 |
> |
FVECT ivec, sorg, upv; |
| 376 |
|
RREAL vMtx[3][3]; |
| 377 |
|
char *fname; |
| 378 |
|
char cmdbuf[256]; |
| 384 |
|
NINCIDENT); |
| 385 |
|
|
| 386 |
|
printf("\nvoid glow arrow_glow\n0\n0\n4 1 0 1 0\n"); |
| 387 |
< |
printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void .5 .\n0\n0\n"); |
| 387 |
> |
printf("\nvoid mixfunc arrow_mat\n4 arrow_glow void 0.25 .\n0\n0\n"); |
| 388 |
|
|
| 389 |
|
if (front_comp & SDsampR) /* front reflection */ |
| 390 |
|
for (i = 0; i < NINCIDENT; i++) { |
| 392 |
|
put_mirror_arrow(ivec, 1); |
| 393 |
|
cvt_sposition(sorg, ivec, 1); |
| 394 |
|
ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */ |
| 395 |
+ |
upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.); |
| 396 |
+ |
upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2]; |
| 397 |
+ |
upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]); |
| 398 |
|
sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad, |
| 399 |
|
sorg[0], sorg[1], sorg[2]); |
| 400 |
|
nxfa = 6; |
| 402 |
|
printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n", |
| 403 |
|
4+nxfa, xfargs); |
| 404 |
|
printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n"); |
| 405 |
< |
SDcompXform(vMtx, ivec, Yaxis); |
| 405 |
> |
if (SDcompXform(vMtx, ivec, upv) != SDEnone) |
| 406 |
> |
continue; |
| 407 |
|
nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]); |
| 408 |
|
sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f", |
| 409 |
|
scalef, sorg[0], sorg[1], sorg[2]); |
| 410 |
|
nxfa += 6; |
| 411 |
|
fname = tfile_name(frpref, dsuffix, i); |
| 412 |
|
sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform %s", |
| 413 |
< |
frpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
| 413 |
> |
frpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
| 414 |
|
xfargs); |
| 415 |
|
if (!run_cmd(cmdbuf)) |
| 416 |
|
return(0); |
| 421 |
|
put_trans_arrow(ivec, 1); |
| 422 |
|
cvt_sposition(sorg, ivec, 1); |
| 423 |
|
ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */ |
| 424 |
+ |
upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.); |
| 425 |
+ |
upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2]; |
| 426 |
+ |
upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]); |
| 427 |
|
sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad, |
| 428 |
|
sorg[0], sorg[1], sorg[2]); |
| 429 |
|
nxfa = 6; |
| 431 |
|
printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n", |
| 432 |
|
4+nxfa, xfargs); |
| 433 |
|
printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n"); |
| 434 |
< |
SDcompXform(vMtx, ivec, Yaxis); |
| 434 |
> |
if (SDcompXform(vMtx, ivec, upv) != SDEnone) |
| 435 |
> |
continue; |
| 436 |
|
nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]); |
| 437 |
|
sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f", |
| 438 |
|
scalef, sorg[0], sorg[1], sorg[2]); |
| 439 |
|
nxfa += 6; |
| 440 |
|
fname = tfile_name(ftpref, dsuffix, i); |
| 441 |
|
sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -I %s", |
| 442 |
< |
ftpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
| 442 |
> |
ftpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
| 443 |
|
xfargs); |
| 444 |
|
if (!run_cmd(cmdbuf)) |
| 445 |
|
return(0); |
| 450 |
|
put_mirror_arrow(ivec, -1); |
| 451 |
|
cvt_sposition(sorg, ivec, -1); |
| 452 |
|
ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */ |
| 453 |
+ |
upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.); |
| 454 |
+ |
upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2]; |
| 455 |
+ |
upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]); |
| 456 |
|
sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad, |
| 457 |
|
sorg[0], sorg[1], sorg[2]); |
| 458 |
|
nxfa = 6; |
| 460 |
|
printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n", |
| 461 |
|
4+nxfa, xfargs); |
| 462 |
|
printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n"); |
| 463 |
< |
SDcompXform(vMtx, ivec, Yaxis); |
| 463 |
> |
if (SDcompXform(vMtx, ivec, upv) != SDEnone) |
| 464 |
> |
continue; |
| 465 |
|
nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]); |
| 466 |
|
sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f", |
| 467 |
|
scalef, sorg[0], sorg[1], sorg[2]); |
| 468 |
|
nxfa += 6; |
| 469 |
|
fname = tfile_name(brpref, dsuffix, i); |
| 470 |
|
sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -I -ry 180 %s", |
| 471 |
< |
brpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
| 471 |
> |
brpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
| 472 |
|
xfargs); |
| 473 |
|
if (!run_cmd(cmdbuf)) |
| 474 |
|
return(0); |
| 479 |
|
put_trans_arrow(ivec, -1); |
| 480 |
|
cvt_sposition(sorg, ivec, -1); |
| 481 |
|
ivec[0] = -ivec[0]; ivec[1] = -ivec[1]; /* normal */ |
| 482 |
+ |
upv[0] = ivec[0]*ivec[1]*(ivec[2] - 1.); |
| 483 |
+ |
upv[1] = ivec[0]*ivec[0] + ivec[1]*ivec[1]*ivec[2]; |
| 484 |
+ |
upv[2] = -ivec[1]*(ivec[0]*ivec[0] + ivec[1]*ivec[1]); |
| 485 |
|
sprintf(xfargs, "-s %f -t %f %f %f", bsdf_rad, |
| 486 |
|
sorg[0], sorg[1], sorg[2]); |
| 487 |
|
nxfa = 6; |
| 489 |
|
printf("%d bsdf_red bsdf_grn bsdf_blu bsdf2rad.cal\n\t%s\n0\n0\n", |
| 490 |
|
4+nxfa, xfargs); |
| 491 |
|
printf("\nscale_pat glow scale_mat\n0\n0\n4 1 1 1 0\n"); |
| 492 |
< |
SDcompXform(vMtx, ivec, Yaxis); |
| 492 |
> |
if (SDcompXform(vMtx, ivec, upv) != SDEnone) |
| 493 |
> |
continue; |
| 494 |
|
nxfa = addrot(xfargs, vMtx[0], vMtx[1], vMtx[2]); |
| 495 |
|
sprintf(xfargs+strlen(xfargs), " -s %f -t %f %f %f", |
| 496 |
|
scalef, sorg[0], sorg[1], sorg[2]); |
| 497 |
|
nxfa += 6; |
| 498 |
|
fname = tfile_name(btpref, dsuffix, i); |
| 499 |
|
sprintf(cmdbuf, "gensurf scale_mat %s%d %s %s %s %d %d | xform -ry 180 %s", |
| 500 |
< |
btpref, i+1, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
| 500 |
> |
btpref, i, fname, fname, fname, SAMPRES-1, SAMPRES-1, |
| 501 |
|
xfargs); |
| 502 |
|
if (!run_cmd(cmdbuf)) |
| 503 |
|
return(0); |
| 515 |
|
printf("\n# Simplified material because we have no XML input\n"); |
| 516 |
|
printf("\nvoid brightfunc latlong\n2 latlong bsdf2rad.cal\n0\n0\n"); |
| 517 |
|
if ((front_comp|back_comp) & SDsampT) |
| 518 |
< |
printf("\nlatlong trans %s\n0\n0\n7 .75 .75 .75 0 0 .5 .8\n", |
| 519 |
< |
sph_mat); |
| 518 |
> |
printf("\nlatlong trans %s\n0\n0\n7 .75 .75 .75 0 .04 .5 .8\n", |
| 519 |
> |
sph_fmat); |
| 520 |
|
else |
| 521 |
|
printf("\nlatlong plastic %s\n0\n0\n5 .5 .5 .5 0 0\n", |
| 522 |
< |
sph_mat); |
| 522 |
> |
sph_fmat); |
| 523 |
> |
printf("\ninherit alias %s %s\n", sph_bmat, sph_fmat); |
| 524 |
|
return; |
| 525 |
|
} |
| 526 |
|
switch (XMLfile[0]) { /* avoid RAYPATH search */ |
| 533 |
|
exit(1); |
| 534 |
|
break; |
| 535 |
|
} |
| 536 |
< |
printf("\n# Actual BSDF material for rendering the hemispheres\n"); |
| 537 |
< |
printf("\nvoid BSDF BSDFmat\n6 0 \"%s%s\" 0 1 0 .\n0\n0\n", |
| 536 |
> |
printf("\n# Actual BSDF materials for rendering the hemispheres\n"); |
| 537 |
> |
printf("\nvoid BSDF BSDF_f\n6 0 \"%s%s\" upx upy upz bsdf2rad.cal\n0\n0\n", |
| 538 |
|
curdir, XMLfile); |
| 539 |
|
printf("\nvoid plastic black\n0\n0\n5 0 0 0 0 0\n"); |
| 540 |
< |
printf("\nvoid mixfunc %s\n4 BSDFmat black latlong bsdf2rad.cal\n0\n0\n", |
| 541 |
< |
sph_mat); |
| 540 |
> |
printf("\nvoid mixfunc %s\n4 BSDF_f black latlong bsdf2rad.cal\n0\n0\n", |
| 541 |
> |
sph_fmat); |
| 542 |
> |
printf("\nvoid BSDF BSDF_b\n8 0 \"%s%s\" upx upy upz bsdf2rad.cal -ry 180\n0\n0\n", |
| 543 |
> |
curdir, XMLfile); |
| 544 |
> |
printf("\nvoid mixfunc %s\n4 BSDF_b black latlong bsdf2rad.cal\n0\n0\n", |
| 545 |
> |
sph_bmat); |
| 546 |
|
} |
| 547 |
|
|
| 548 |
|
/* Put out overhead parallel light source */ |
| 550 |
|
put_source(void) |
| 551 |
|
{ |
| 552 |
|
printf("\n# Overhead parallel light source\n"); |
| 553 |
< |
printf("\nvoid light bright\n0\n0\n3 2000 2000 2000\n"); |
| 553 |
> |
printf("\nvoid light bright\n0\n0\n3 2500 2500 2500\n"); |
| 554 |
|
printf("\nbright source light\n0\n0\n4 0 0 1 2\n"); |
| 555 |
|
printf("\n# Material used for labels\n"); |
| 556 |
|
printf("\nvoid trans vellum\n0\n0\n7 1 1 1 0 0 .5 0\n"); |
| 560 |
|
static void |
| 561 |
|
put_hemispheres(void) |
| 562 |
|
{ |
| 563 |
+ |
const int nsegs = 131; |
| 564 |
+ |
|
| 565 |
|
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); |
| 566 |
|
if (front_comp) { |
| 567 |
< |
printf("\n%s sphere Front\n0\n0\n4 %f 0 0 %f\n", |
| 568 |
< |
sph_mat, -sph_xoffset, sph_rad); |
| 569 |
< |
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); |
| 567 |
> |
printf( |
| 568 |
> |
"\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", |
| 569 |
> |
sph_fmat, nsegs, sph_rad, 0.495*PI, sph_xoffset); |
| 570 |
|
printf("\nvoid brighttext front_text\n3 helvet.fnt . FRONT\n0\n"); |
| 571 |
|
printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n", |
| 572 |
< |
-.22*sph_rad - sph_xoffset, -1.4*sph_rad, |
| 572 |
> |
-.22*sph_rad + sph_xoffset, -1.4*sph_rad, |
| 573 |
|
.35/5.*sph_rad, -1.6*.35/5.*sph_rad); |
| 574 |
|
printf("\nfront_text alias front_label_mat vellum\n"); |
| 575 |
|
printf("\nfront_label_mat polygon front_label\n0\n0\n12"); |
| 576 |
|
printf("\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n", |
| 577 |
< |
-.25*sph_rad - sph_xoffset, -1.3*sph_rad, |
| 578 |
< |
-.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad, |
| 579 |
< |
.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad, |
| 580 |
< |
.25*sph_rad - sph_xoffset, -1.3*sph_rad ); |
| 577 |
> |
-.25*sph_rad + sph_xoffset, -1.3*sph_rad, |
| 578 |
> |
-.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad, |
| 579 |
> |
.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/5.-.1)*sph_rad, |
| 580 |
> |
.25*sph_rad + sph_xoffset, -1.3*sph_rad ); |
| 581 |
|
} |
| 582 |
|
if (back_comp) { |
| 583 |
< |
printf("\n%s bubble Back\n0\n0\n4 %f 0 0 %f\n", |
| 584 |
< |
sph_mat, sph_xoffset, sph_rad); |
| 585 |
< |
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); |
| 583 |
> |
printf( |
| 584 |
> |
"\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", |
| 585 |
> |
sph_bmat, nsegs, sph_rad, 0.495*PI, -sph_xoffset); |
| 586 |
|
printf("\nvoid brighttext back_text\n3 helvet.fnt . BACK\n0\n"); |
| 587 |
|
printf("12\n\t%f %f 0\n\t%f 0 0\n\t0 %f 0\n\t.01 1 -.1\n", |
| 588 |
< |
-.22*sph_rad + sph_xoffset, -1.4*sph_rad, |
| 588 |
> |
-.22*sph_rad - sph_xoffset, -1.4*sph_rad, |
| 589 |
|
.35/4.*sph_rad, -1.6*.35/4.*sph_rad); |
| 590 |
|
printf("\nback_text alias back_label_mat vellum\n"); |
| 591 |
|
printf("\nback_label_mat polygon back_label\n0\n0\n12"); |
| 592 |
|
printf("\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n\t%f %f 0\n", |
| 593 |
< |
-.25*sph_rad + sph_xoffset, -1.3*sph_rad, |
| 594 |
< |
-.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad, |
| 595 |
< |
.25*sph_rad + sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad, |
| 596 |
< |
.25*sph_rad + sph_xoffset, -1.3*sph_rad ); |
| 593 |
> |
-.25*sph_rad - sph_xoffset, -1.3*sph_rad, |
| 594 |
> |
-.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad, |
| 595 |
> |
.25*sph_rad - sph_xoffset, (-1.4-1.6*.35/4.-.1)*sph_rad, |
| 596 |
> |
.25*sph_rad - sph_xoffset, -1.3*sph_rad ); |
| 597 |
|
} |
| 598 |
|
} |
| 599 |
|
|
| 602 |
|
put_scale(void) |
| 603 |
|
{ |
| 604 |
|
const double max_log10 = log10(overall_max); |
| 605 |
< |
const double leg_width = 2.*.75*(sph_xoffset - sph_rad); |
| 605 |
> |
const double leg_width = 2.*.75*(fabs(sph_xoffset) - sph_rad); |
| 606 |
|
const double leg_height = 2.*sph_rad; |
| 607 |
|
const int text_lines = 6; |
| 608 |
|
const int text_digits = 8; |
| 701 |
|
sprintf(cmdbuf, "xform -t %f %f %f -s %f -t %f %f 0 %s", |
| 702 |
|
-.5*(xmin+xmax), -.5*(ymin+ymax), -zmax, |
| 703 |
|
1.5*sph_rad/max_dim, |
| 704 |
< |
-sph_xoffset, -2.5*sph_rad, |
| 704 |
> |
sph_xoffset, -2.5*sph_rad, |
| 705 |
|
radfn); |
| 706 |
|
if (!run_cmd(cmdbuf)) |
| 707 |
|
return; |
| 711 |
|
sprintf(cmdbuf, "xform -t %f %f %f -s %f -ry 180 -t %f %f 0 %s", |
| 712 |
|
-.5*(xmin+xmax), -.5*(ymin+ymax), -zmin, |
| 713 |
|
1.5*sph_rad/max_dim, |
| 714 |
< |
sph_xoffset, -2.5*sph_rad, |
| 714 |
> |
-sph_xoffset, -2.5*sph_rad, |
| 715 |
|
radfn); |
| 716 |
|
if (!run_cmd(cmdbuf)) |
| 717 |
|
return; |