home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume21 / sipp / part08 < prev    next >
Text File  |  1991-07-23  |  37KB  |  1,497 lines

  1. Newsgroups: comp.sources.misc
  2. From: Jonas Yngvesson <jonas-y@isy.liu.se>
  3. Subject:  v21i033:  sipp - A 3D rendering library v2.1, Part08/08
  4. Message-ID: <1991Jul23.181823.28068@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 6aefb07c5af503a76b4069ecfc14c3ae
  6. Date: Tue, 23 Jul 1991 18:18:23 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Jonas Yngvesson <jonas-y@isy.liu.se>
  10. Posting-number: Volume 21, Issue 33
  11. Archive-name: sipp/part08
  12. Supersedes: sipp2.0: Volume 16, Issue 5-10
  13. Environment: UNIX
  14.  
  15. #!/bin/sh
  16. # This is part 08 of sipp-2.1
  17. # ============= demo/conetest.c ==============
  18. if test ! -d 'demo'; then
  19.     echo 'x - creating directory demo'
  20.     mkdir 'demo'
  21. fi
  22. if test -f 'demo/conetest.c' -a X"$1" != X"-c"; then
  23.     echo 'x - skipping demo/conetest.c (File already exists)'
  24. else
  25. echo 'x - extracting demo/conetest.c (Text)'
  26. sed 's/^X//' << 'SHAR_EOF' > 'demo/conetest.c' &&
  27. #include <stdio.h>
  28. #include <math.h>
  29. X
  30. #include <sipp.h>
  31. #include <primitives.h>
  32. X
  33. X
  34. #define RESOLUTION 20
  35. X
  36. extern char *optarg;
  37. X
  38. main(argc, argv)
  39. X    int    argc;
  40. X    char **argv;
  41. {
  42. X    FILE      *fp ;
  43. X    Object    *cone;
  44. X    Object    *trunc_cone;
  45. X    Surf_desc   surf;
  46. X
  47. X    char    *imfile_name;
  48. X    int      mode;
  49. X    char     c;
  50. X    int      size;
  51. X
  52. X    imfile_name = "cone.ppm";
  53. X    mode = PHONG;
  54. X    size = 256;
  55. X
  56. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  57. X        switch (c) {
  58. X          case 'p':
  59. X            mode = PHONG;
  60. X            imfile_name = "cone.ppm";
  61. X            break;
  62. X
  63. X          case 'g':
  64. X            mode = GOURAUD;
  65. X            imfile_name = "cone.ppm";
  66. X            break;
  67. X
  68. X          case 'f':
  69. X            mode = FLAT;
  70. X            imfile_name = "cone.ppm";
  71. X            break;
  72. X
  73. X          case 'l':
  74. X            mode = LINE;
  75. X            imfile_name = "cone.pbm";
  76. X            break;
  77. X
  78. X          case 's':
  79. X            size = atoi(optarg);
  80. X            break;
  81. X        }
  82. X    }
  83. X
  84. X    sipp_init();
  85. X
  86. X    lightsource_push(1.0, 1.0, 1.0, 0.9);
  87. X    lightsource_push(-1.0, -1.0, 0.5, 0.4);
  88. X
  89. X    surf.ambient = 0.5;
  90. X    surf.color.red = 1.0000;    /* light salmon */
  91. X    surf.color.grn = 0.6275;
  92. X    surf.color.blu = 0.4784;
  93. X    surf.specular = 0.6;
  94. X    surf.c3 = 0.2;
  95. X
  96. X    /* The ordinary cone */
  97. X    cone = sipp_cone(1.0, 0.0, 4.0, RESOLUTION, &surf, basic_shader);
  98. X    object_move(cone, -3.0, 0.0, 0.0);
  99. X    object_install(cone);
  100. X
  101. X    /* The truncated cone */
  102. X    trunc_cone = sipp_cone(1.0, 0.4, 5.0, RESOLUTION, &surf, basic_shader);
  103. X    object_move(trunc_cone, 3.0, 0.0, 0.0);
  104. X    object_install(trunc_cone);
  105. X
  106. X    /* The cylinder (a trucated cone with equal top and bottom radii */
  107. X    object_install(sipp_cylinder(1.0, 3.0, RESOLUTION, &surf, basic_shader)); 
  108. X
  109. X    viewpoint(5.0, -10.0, 6.0,  0.0, 0.0, 0.0,  0.0, 0.0, 1.0,  0.4);
  110. X
  111. X    printf("Rendering, wait...");
  112. X    fflush(stdout);
  113. X
  114. X    fp = fopen(imfile_name, "w");
  115. X    render_image_file(size, size, fp, mode, 2);
  116. X    printf("Done.\n");
  117. X
  118. X    exit(0);
  119. }
  120. SHAR_EOF
  121. chmod 0664 demo/conetest.c ||
  122. echo 'restore of demo/conetest.c failed'
  123. Wc_c="`wc -c < 'demo/conetest.c'`"
  124. test 2027 -eq "$Wc_c" ||
  125.     echo 'demo/conetest.c: original size 2027, current size' "$Wc_c"
  126. fi
  127. # ============= demo/ellipsoid.c ==============
  128. if test -f 'demo/ellipsoid.c' -a X"$1" != X"-c"; then
  129.     echo 'x - skipping demo/ellipsoid.c (File already exists)'
  130. else
  131. echo 'x - extracting demo/ellipsoid.c (Text)'
  132. sed 's/^X//' << 'SHAR_EOF' > 'demo/ellipsoid.c' &&
  133. #include <stdio.h>
  134. #include <math.h>
  135. X
  136. #include <sipp.h>
  137. #include <primitives.h>
  138. X
  139. X
  140. X
  141. #define RESOLUTION 15
  142. X
  143. extern char *optarg;
  144. X
  145. main(argc, argv)
  146. X    int    argc;
  147. X    char **argv;
  148. {
  149. X    FILE    *fp ;
  150. X    Surf_desc surf;
  151. X
  152. X    char    *imfile_name;
  153. X    int      mode;
  154. X    char     c;
  155. X    int      size;
  156. X
  157. X    imfile_name = "ellipsoid.ppm";
  158. X    mode = PHONG;
  159. X    size = 256;
  160. X
  161. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  162. X        switch (c) {
  163. X          case 'p':
  164. X            mode = PHONG;
  165. X            imfile_name = "ellipsoid.ppm";
  166. X            break;
  167. X
  168. X          case 'g':
  169. X            mode = GOURAUD;
  170. X            imfile_name = "ellipsoid.ppm";
  171. X            break;
  172. X
  173. X          case 'f':
  174. X            mode = FLAT;
  175. X            imfile_name = "ellipsoid.ppm";
  176. X            break;
  177. X
  178. X          case 'l':
  179. X            mode = LINE;
  180. X            imfile_name = "ellipsoid.pbm";
  181. X            break;
  182. X
  183. X          case 's':
  184. X            size = atoi(optarg);
  185. X            break;
  186. X        }
  187. X    }
  188. X
  189. X    sipp_init();
  190. X
  191. X    lightsource_push(1.0, 1.0, 1.0, 0.9);
  192. X    lightsource_push(-1.0, -1.0, 0.5, 0.4);
  193. X
  194. X    surf.ambient = 0.5;
  195. X    surf.color.red = 0.6;
  196. X    surf.color.grn = 0.3;
  197. X    surf.color.blu = 0.5;
  198. X    surf.specular = 0.6;
  199. X    surf.c3 = 0.2;
  200. X    
  201. X    object_install(sipp_ellipsoid(1.0, 2.0, 3.0, RESOLUTION,
  202. X                                  &surf, basic_shader)); 
  203. X
  204. X    viewpoint(10.0, 0.0, 0.0,  0.0, 0.0, 0.0,  0.0, 0.0, 1.0,  0.4);
  205. X
  206. X    printf("Rendering, wait...");
  207. X    fflush(stdout);
  208. X
  209. X    fp = fopen(imfile_name, "w");
  210. X    render_image_file(size, size, fp, mode, 2);
  211. X    printf("Done.\n");
  212. X
  213. X    exit(0);
  214. }
  215. SHAR_EOF
  216. chmod 0664 demo/ellipsoid.c ||
  217. echo 'restore of demo/ellipsoid.c failed'
  218. Wc_c="`wc -c < 'demo/ellipsoid.c'`"
  219. test 1595 -eq "$Wc_c" ||
  220.     echo 'demo/ellipsoid.c: original size 1595, current size' "$Wc_c"
  221. fi
  222. # ============= demo/isy90.c ==============
  223. if test -f 'demo/isy90.c' -a X"$1" != X"-c"; then
  224.     echo 'x - skipping demo/isy90.c (File already exists)'
  225. else
  226. echo 'x - extracting demo/isy90.c (Text)'
  227. sed 's/^X//' << 'SHAR_EOF' > 'demo/isy90.c' &&
  228. #include <math.h>
  229. #include <stdio.h>
  230. X
  231. #include <sipp.h>
  232. #include <shaders.h>
  233. #include <primitives.h>
  234. X
  235. X
  236. #define BEZ_RES        9
  237. #define CYL_RES        40
  238. #define LID_ROT        1.5
  239. #define BLOCK_SIZE     1.2
  240. #define NCYL           16
  241. #define CYL_LEN        5.0
  242. #define SMALL_CYL_RAD  ((BLOCK_SIZE * M_PI) / (NCYL * 2))
  243. #define BIG_CYL_RAD    (0.5 * BLOCK_SIZE - 1.1 * SMALL_CYL_RAD)
  244. X
  245. X
  246. Marble_desc teapot_surf = {
  247. X    0.4, 
  248. X    0.5,
  249. X    0.05,
  250. X    8.0, 
  251. X    {0.90, 0.80, 0.65}, 
  252. X    {0.30, 0.08, 0.08}
  253. };
  254. X
  255. Granite_desc column_surf = {
  256. X    0.4,
  257. X    0.1,
  258. X    0.4,
  259. X    20.0,
  260. X    {0.647, 0.565, 0.5},
  261. X    {0.15, 0.12, 0.10}
  262. };
  263. X
  264. extern char *optarg;
  265. X
  266. main(argc, argv)
  267. X    int argc;
  268. X    char **argv;
  269. {
  270. X    Object  *column;
  271. X    Object  *teapot;
  272. X    Object  *handle;
  273. X    Object  *spout;
  274. X    Object  *body;
  275. X    Object  *lid;
  276. X    Object  *tmp;
  277. X    FILE    *infile;
  278. X    FILE    *image;
  279. X    int      i;
  280. X
  281. X    char    *imfile_name;
  282. X    int      mode;
  283. X    char     c;
  284. X    int      size;
  285. X
  286. X    imfile_name = "isy90.ppm";
  287. X    mode = PHONG;
  288. X    size = 256;
  289. X
  290. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  291. X        switch (c) {
  292. X          case 'p':
  293. X            mode = PHONG;
  294. X            imfile_name = "isy90.ppm";
  295. X            break;
  296. X
  297. X          case 'g':
  298. X            mode = GOURAUD;
  299. X            imfile_name = "isy90.ppm";
  300. X            break;
  301. X
  302. X          case 'f':
  303. X            mode = FLAT;
  304. X            imfile_name = "isy90.ppm";
  305. X            break;
  306. X
  307. X          case 'l':
  308. X            mode = LINE;
  309. X            imfile_name = "isy90.pbm";
  310. X            break;
  311. X
  312. X          case 's':
  313. X            size = atoi(optarg);
  314. X            break;
  315. X        }
  316. X    }
  317. X
  318. X    sipp_init();
  319. X
  320. X    infile = fopen("tpt_handle.bez", "r");
  321. X    handle = sipp_bezier(infile, BEZ_RES, &teapot_surf, marble_shader);
  322. X    fclose(infile);
  323. X
  324. X    infile = fopen("tpt_spout.bez", "r");
  325. X    spout = sipp_bezier(infile, BEZ_RES, &teapot_surf, marble_shader);
  326. X    fclose(infile);
  327. X
  328. X    infile = fopen("tpt_body.bez", "r");
  329. X    body = sipp_bezier(infile, BEZ_RES, &teapot_surf, marble_shader);
  330. X    fclose(infile);
  331. X
  332. X    infile = fopen("tpt_lid.bez", "r");
  333. X    lid = sipp_bezier(infile, BEZ_RES, &teapot_surf, marble_shader);
  334. X    fclose(infile);
  335. X
  336. X    object_rot_y(lid, LID_ROT);
  337. X
  338. X    teapot = object_create();
  339. X    object_add_subobj(teapot, body);
  340. X    object_add_subobj(teapot, lid);
  341. X    object_add_subobj(teapot, handle);
  342. X    object_add_subobj(teapot, spout);
  343. X
  344. X    object_install(teapot);
  345. X
  346. X    column = object_create();
  347. X    tmp = sipp_block(BLOCK_SIZE, BLOCK_SIZE / 4.0, BLOCK_SIZE,
  348. X                     &column_surf, granite_shader);
  349. X    object_move(tmp, 0.0, -BLOCK_SIZE / 8.0, 0.0);
  350. X    object_add_subobj(column, tmp);
  351. X
  352. X    for (i = 0; i < NCYL; i++) {
  353. X        if (i == 0) {
  354. X            tmp = sipp_cylinder(SMALL_CYL_RAD, CYL_LEN, CYL_RES,
  355. X                                &column_surf, granite_shader); 
  356. X        } else {
  357. X            tmp = object_instance(tmp);
  358. X        }
  359. X        object_rot_x(tmp, M_PI / 2.0);
  360. X        object_move(tmp, BIG_CYL_RAD * cos(i * 2.0 * M_PI / NCYL), 
  361. X                    -0.5 * (CYL_LEN + BLOCK_SIZE / 4.0), 
  362. X                    BIG_CYL_RAD * sin(i * 2.0 * M_PI / NCYL));
  363. X        object_add_subobj(column, tmp);
  364. X    }
  365. X
  366. X    object_install(column);
  367. X        
  368. X    
  369. X    lightsource_push(1.0, 1.0, 0.5, 0.85);
  370. X    lightsource_push(-1.0, 0.5, 0.5, 0.25);
  371. X
  372. X    view_from(2.0, 1.5, 4.0);
  373. X    view_at(0.0, 0.1, 0.0);
  374. X    view_up(0.0, 1.0, 0.0);
  375. X    view_focal(0.2);
  376. X
  377. X    printf("Rendering, wait...");
  378. X    fflush(stdout);
  379. X
  380. X    image = fopen(imfile_name, "w");
  381. X    render_image_file(size, size, image, mode, 2);
  382. X    printf("Done.\n");
  383. X
  384. X    exit(0);
  385. }
  386. SHAR_EOF
  387. chmod 0664 demo/isy90.c ||
  388. echo 'restore of demo/isy90.c failed'
  389. Wc_c="`wc -c < 'demo/isy90.c'`"
  390. test 3595 -eq "$Wc_c" ||
  391.     echo 'demo/isy90.c: original size 3595, current size' "$Wc_c"
  392. fi
  393. # ============= demo/planettest.c ==============
  394. if test -f 'demo/planettest.c' -a X"$1" != X"-c"; then
  395.     echo 'x - skipping demo/planettest.c (File already exists)'
  396. else
  397. echo 'x - extracting demo/planettest.c (Text)'
  398. sed 's/^X//' << 'SHAR_EOF' > 'demo/planettest.c' &&
  399. #include <stdio.h>
  400. #include <math.h>
  401. X
  402. #include <sipp.h>
  403. #include <primitives.h>
  404. #include <shaders.h>
  405. X
  406. X
  407. X
  408. #define SUBDIVS  20
  409. X
  410. extern char *optarg;
  411. X
  412. main(argc, argv)
  413. X    int    argc;
  414. X    char **argv;
  415. {
  416. X    Surf_desc   planet_surface;
  417. X    Object     *planet;
  418. X    FILE       *outfile;
  419. X
  420. X    char    *imfile_name;
  421. X    int      mode;
  422. X    char     c;
  423. X    int      size;
  424. X
  425. X    imfile_name = "planet.ppm";
  426. X    mode = PHONG;
  427. X    size = 256;
  428. X
  429. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  430. X        switch (c) {
  431. X          case 'p':
  432. X            mode = PHONG;
  433. X            imfile_name = "planet.ppm";
  434. X            break;
  435. X
  436. X          case 'g':
  437. X            mode = GOURAUD;
  438. X            imfile_name = "planet.ppm";
  439. X            break;
  440. X
  441. X          case 'f':
  442. X            mode = FLAT;
  443. X            imfile_name = "planet.ppm";
  444. X            break;
  445. X
  446. X          case 'l':
  447. X            mode = LINE;
  448. X            imfile_name = "planet.pbm";
  449. X            break;
  450. X
  451. X          case 's':
  452. X            size = atoi(optarg);
  453. X            break;
  454. X        }
  455. X    }
  456. X    
  457. X    planet_surface.ambient = 0.4;
  458. X    planet_surface.specular = 0.0;
  459. X    planet_surface.c3 = 0.5;
  460. X    planet_surface.color.red = 1.0;
  461. X    planet_surface.color.grn = 0.0;
  462. X    planet_surface.color.blu = 0.0;
  463. X
  464. X    sipp_init();
  465. X
  466. X    lightsource_push(1.0, 1.0, 1.0, 1.0);
  467. X
  468. X    object_install(sipp_sphere(1.0, SUBDIVS, &planet_surface, planet_shader)); 
  469. X
  470. X    viewpoint(0.0, 2.0, 0.0,  0.0, 0.0, 0.0,  0.0, 0.0, 1.0,  0.75);
  471. X
  472. X    printf("Rendering, wait...");
  473. X    fflush(stdout);
  474. X
  475. X    outfile = fopen(imfile_name, "w");
  476. X    render_image_file(size, size, outfile, mode, 2);
  477. X    printf("Done.\n");
  478. X    
  479. X    exit(0);
  480. }
  481. SHAR_EOF
  482. chmod 0664 demo/planettest.c ||
  483. echo 'restore of demo/planettest.c failed'
  484. Wc_c="`wc -c < 'demo/planettest.c'`"
  485. test 1633 -eq "$Wc_c" ||
  486.     echo 'demo/planettest.c: original size 1633, current size' "$Wc_c"
  487. fi
  488. # ============= demo/prismtest.c ==============
  489. if test -f 'demo/prismtest.c' -a X"$1" != X"-c"; then
  490.     echo 'x - skipping demo/prismtest.c (File already exists)'
  491. else
  492. echo 'x - extracting demo/prismtest.c (Text)'
  493. sed 's/^X//' << 'SHAR_EOF' > 'demo/prismtest.c' &&
  494. #include <stdio.h>
  495. #include <math.h>
  496. X
  497. #include <sipp.h>
  498. #include <primitives.h>
  499. X
  500. X
  501. /* The XY coordinats for a 3-sided prism. */
  502. Vector   prism3[3] = {
  503. X    { 1.0  -1.0, 0.0}, 
  504. X    {-1.0,  2.0, 0.0}, 
  505. X    {-2.0, -1.0, 0.0}
  506. };
  507. X
  508. /* The XY coordinats for a 5-sided prism. */
  509. Vector   prism5[5] = {
  510. X    { 0.5  -1.0, 0.0}, 
  511. X    {-1.0,  0.5, 0.0}, 
  512. X    { 1.0,  1.0, 0.0}, 
  513. X    {-1.0,  2.0, 0.0}, 
  514. X    {-2.0,  0.5, 0.0}
  515. };
  516. X
  517. extern char *optarg;
  518. X
  519. main(argc, argv)
  520. X    int    argc;
  521. X    char **argv;
  522. {
  523. X    FILE      * fp ;
  524. X    Object    * prism3_obj;
  525. X    Object    * prism5_obj;
  526. X    Surf_desc   surf;
  527. X
  528. X    char    *imfile_name;
  529. X    int      mode;
  530. X    char     c;
  531. X    int      size;
  532. X
  533. X    imfile_name = "prism.ppm";
  534. X    mode = PHONG;
  535. X    size = 256;
  536. X
  537. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  538. X        switch (c) {
  539. X          case 'p':
  540. X            mode = PHONG;
  541. X            imfile_name = "prism.ppm";
  542. X            break;
  543. X
  544. X          case 'g':
  545. X            mode = GOURAUD;
  546. X            imfile_name = "prism.ppm";
  547. X            break;
  548. X
  549. X          case 'f':
  550. X            mode = FLAT;
  551. X            imfile_name = "prism.ppm";
  552. X            break;
  553. X
  554. X          case 'l':
  555. X            mode = LINE;
  556. X            imfile_name = "prism.pbm";
  557. X            break;
  558. X
  559. X          case 's':
  560. X            size = atoi(optarg);
  561. X            break;
  562. X        }
  563. X    }
  564. X
  565. X    sipp_init();
  566. X
  567. X    lightsource_push(1.0, 1.0, 1.0, 0.9);
  568. X    lightsource_push(-1.0, -1.0, 0.5, 0.4);
  569. X
  570. X    surf.ambient = 0.5;
  571. X    surf.color.red = 1.0000;    /* light salmon */
  572. X    surf.color.grn = 0.6275;
  573. X    surf.color.blu = 0.4784;
  574. X    surf.specular = 0.6;
  575. X    surf.c3 = 0.2;
  576. X
  577. X    /* The 3-sided prism */
  578. X    prism3_obj = sipp_prism(3, &prism3[0], 4.0, &surf, basic_shader);
  579. X    object_move(prism3_obj, -3.0, 0.0, 0.0);
  580. X    object_install(prism3_obj);
  581. X
  582. X    /* The 5-sided prism */
  583. X    prism5_obj = sipp_prism(5, &prism5[0], 5.0, &surf, basic_shader);
  584. X    object_move(prism5_obj, 3.0, 0.0, 0.0);
  585. X    object_install(prism5_obj);
  586. X
  587. X    /* The block (a 4 sided prism)  */
  588. X    object_install(sipp_block(1.0, 2.0, 3.0, &surf, basic_shader)); 
  589. X
  590. X    viewpoint(5.0, -10.0, 6.0,  0.0, 0.0, 0.0,  0.0, 0.0, 1.0,  0.4);
  591. X
  592. X    printf("Rendering, wait...");
  593. X    fflush(stdout);
  594. X
  595. X    fp = fopen(imfile_name, "w");
  596. X    render_image_file(size, size, fp, mode, 2);
  597. X    printf("Done.\n");
  598. X
  599. X    exit(0);
  600. }
  601. SHAR_EOF
  602. chmod 0664 demo/prismtest.c ||
  603. echo 'restore of demo/prismtest.c failed'
  604. Wc_c="`wc -c < 'demo/prismtest.c'`"
  605. test 2312 -eq "$Wc_c" ||
  606.     echo 'demo/prismtest.c: original size 2312, current size' "$Wc_c"
  607. fi
  608. # ============= demo/strausstest.c ==============
  609. if test -f 'demo/strausstest.c' -a X"$1" != X"-c"; then
  610.     echo 'x - skipping demo/strausstest.c (File already exists)'
  611. else
  612. echo 'x - extracting demo/strausstest.c (Text)'
  613. sed 's/^X//' << 'SHAR_EOF' > 'demo/strausstest.c' &&
  614. /*
  615. X * Demo of the strauss shader. Four spheres are rendered, 
  616. X * all with the same base color, but different smoothness
  617. X * and metalness.
  618. X */
  619. X
  620. #include <stdio.h>
  621. #include <math.h>
  622. X
  623. #include <sipp.h>
  624. #include <shaders.h>
  625. #include <primitives.h>
  626. X
  627. X
  628. /*
  629. X * Surface description of the spheres.
  630. X */
  631. Strauss_desc non_metal_dull = {
  632. X    0.4,                        /* Ambient */
  633. X    0.2,                        /* Smoothness */
  634. X    0.1,                        /* Metalness */
  635. X    {0.6, 0.33, 0.27}           /* Color */
  636. };
  637. X
  638. Strauss_desc non_metal_shiny = {
  639. X    0.4, 
  640. X    0.7, 
  641. X    0.1, 
  642. X    {0.6, 0.33, 0.27}
  643. };
  644. X
  645. Strauss_desc metal_dull = {
  646. X    0.4, 
  647. X    0.2, 
  648. X    0.9, 
  649. X    {0.6, 0.33, 0.27}
  650. };
  651. X
  652. Strauss_desc metal_shiny = {
  653. X    0.4, 
  654. X    0.7, 
  655. X    0.9, 
  656. X    {0.6, 0.33, 0.27}
  657. };
  658. X
  659. X
  660. /*
  661. X * White surface as background.
  662. X */
  663. Surf_desc bg_surf = {
  664. X    0.4,
  665. X    0.0,
  666. X    0.99,
  667. X    {0.9804,  0.9216,  0.8431} /* Antique white */
  668. };
  669. X
  670. X
  671. X
  672. #define RESOLUTION 30
  673. X
  674. extern char *optarg;
  675. X
  676. main(argc, argv)
  677. X    int    argc;
  678. X    char **argv;
  679. {
  680. X    Object *nmd;     /* Non metallic, dull sphere */
  681. X    Object *nms;     /* Non metallic, shiny sphere */
  682. X    Object *md;      /* Metallic, dull sphere */
  683. X    Object *ms;      /* Metallic, shiny sphere */
  684. X    Object *bg;      /* Background */
  685. X    FILE   *fp;
  686. X
  687. X    char    *imfile_name;
  688. X    int      mode;
  689. X    char     c;
  690. X    int      size;
  691. X
  692. X    imfile_name = "strauss.ppm";
  693. X    mode = PHONG;
  694. X    size = 256;
  695. X
  696. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  697. X        switch (c) {
  698. X          case 'p':
  699. X            mode = PHONG;
  700. X            imfile_name = "strauss.ppm";
  701. X            break;
  702. X
  703. X          case 'g':
  704. X            mode = GOURAUD;
  705. X            imfile_name = "strauss.ppm";
  706. X            break;
  707. X
  708. X          case 'f':
  709. X            mode = FLAT;
  710. X            imfile_name = "strauss.ppm";
  711. X            break;
  712. X
  713. X          case 'l':
  714. X            mode = LINE;
  715. X            imfile_name = "strauss.pbm";
  716. X            break;
  717. X
  718. X          case 's':
  719. X            size = atoi(optarg);
  720. X            break;
  721. X        }
  722. X    }
  723. X
  724. X    sipp_init();
  725. X
  726. X    lightsource_push(-1.0, -1.0, 1.0, 1.0);
  727. X    lightsource_push(0.0, -1.0, 2.0, 0.6);
  728. X
  729. X    /*
  730. X     * Non metal, dull. Upper left.
  731. X     */
  732. X    nmd = sipp_sphere(1.0, RESOLUTION, &non_metal_dull, strauss_shader);
  733. X    object_move(nmd, -1.1, 0.0, 1.1);
  734. X    object_install(nmd); 
  735. X
  736. X    /*
  737. X     * Non metal, shiny. Upper right.
  738. X     */
  739. X    nms = sipp_sphere(1.0, RESOLUTION, &non_metal_shiny, strauss_shader);
  740. X    object_move(nms, 1.1, 0.0, 1.1);
  741. X    object_install(nms); 
  742. X
  743. X    /*
  744. X     * Metal, dull. Lower left.
  745. X     */
  746. X    md = sipp_sphere(1.0, RESOLUTION, &metal_dull, strauss_shader);
  747. X    object_move(md, -1.1, 0.0, -1.1);
  748. X    object_install(md); 
  749. X    /*
  750. X     * Metal, shiny. Lower right.
  751. X     */
  752. X    ms = sipp_sphere(1.0, RESOLUTION, &metal_shiny, strauss_shader);
  753. X    object_move(ms, 1.1, 0.0, -1.1);
  754. X    object_install(ms);
  755. X
  756. X    /*
  757. X     * Background.
  758. X     */
  759. X    bg = sipp_block(10.0, 0.5, 10.0, bg_surf, basic_shader);
  760. X    object_move(bg, 0.0, 1.5, 0.0);
  761. X    object_install(bg);
  762. X
  763. X    viewpoint(0.0, -10.0, 0.0,  0.0, 0.0, 0.0,  0.0, 0.0, 1.0,  0.25);
  764. X
  765. X    printf("Rendering, wait...");
  766. X    fflush(stdout);
  767. X
  768. X    fp = fopen(imfile_name, "w");
  769. X    render_image_file(size, size, fp, mode, 2);
  770. X    printf("Done.\n");
  771. X
  772. X    exit(0);
  773. }
  774. SHAR_EOF
  775. chmod 0644 demo/strausstest.c ||
  776. echo 'restore of demo/strausstest.c failed'
  777. Wc_c="`wc -c < 'demo/strausstest.c'`"
  778. test 3272 -eq "$Wc_c" ||
  779.     echo 'demo/strausstest.c: original size 3272, current size' "$Wc_c"
  780. fi
  781. # ============= demo/structure.c ==============
  782. if test -f 'demo/structure.c' -a X"$1" != X"-c"; then
  783.     echo 'x - skipping demo/structure.c (File already exists)'
  784. else
  785. echo 'x - extracting demo/structure.c (Text)'
  786. sed 's/^X//' << 'SHAR_EOF' > 'demo/structure.c' &&
  787. #include <stdio.h>
  788. #include <math.h>
  789. X
  790. #include <sipp.h>
  791. #include <primitives.h>
  792. #include <shaders.h>
  793. X
  794. X
  795. #define SPHERERES 40
  796. #define CYLRES    40
  797. X
  798. #define SIGNBIT(bit, i)   (((i >> bit) & 1) ? -1.0 : 1.0)
  799. X
  800. Surf_desc surf = {
  801. X    0.4,
  802. X    0.7, 
  803. X    0.1, 
  804. X    {0.8, 0.6, 0.3}
  805. X    };
  806. X    
  807. Bumpy_desc bumpy_surf = {
  808. X    basic_shader, 
  809. X    &surf, 
  810. X    14.0, 
  811. X    FALSE, 
  812. X    TRUE
  813. };
  814. X
  815. extern char *optarg;
  816. X
  817. main(argc, argv)
  818. X    int    argc;
  819. X    char **argv;
  820. {
  821. X    Object  *sphere;
  822. X    Object  *cyl;
  823. X    Object  *structure;
  824. X    FILE    *fp ;
  825. X    Surf_desc cyl_surf;
  826. X    int      i;
  827. X
  828. X    char    *imfile_name;
  829. X    int      mode;
  830. X    char     c;
  831. X    int      size;
  832. X
  833. X    imfile_name = "structure.ppm";
  834. X    mode = PHONG;
  835. X    size = 256;
  836. X
  837. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  838. X        switch (c) {
  839. X          case 'p':
  840. X            mode = PHONG;
  841. X            imfile_name = "structure.ppm";
  842. X            break;
  843. X
  844. X          case 'g':
  845. X            mode = GOURAUD;
  846. X            imfile_name = "structure.ppm";
  847. X            break;
  848. X
  849. X          case 'f':
  850. X            mode = FLAT;
  851. X            imfile_name = "structure.ppm";
  852. X            break;
  853. X
  854. X          case 'l':
  855. X            mode = LINE;
  856. X            imfile_name = "structure.pbm";
  857. X            break;
  858. X
  859. X          case 's':
  860. X            size = atoi(optarg);
  861. X            break;
  862. X        }
  863. X    }
  864. X
  865. X    sipp_init();
  866. X
  867. X    lightsource_push(1.0, 1.0, 1.0, 0.9);
  868. X    lightsource_push(-1.0, -1.0, 0.5, 0.4);
  869. X
  870. X    cyl_surf.ambient = 0.5;
  871. X    cyl_surf.color.red = 0.5;
  872. X    cyl_surf.color.grn = 0.6;
  873. X    cyl_surf.color.blu = 0.8;
  874. X    cyl_surf.specular = 0.4;
  875. X    cyl_surf.c3 = 0.3;
  876. X    
  877. X    structure = object_create();
  878. X
  879. X    sphere = sipp_sphere(1.0, SPHERERES, &bumpy_surf, bumpy_shader);
  880. X    for (i = 0; i < 8; i++) {
  881. X        if (i) {
  882. X            sphere = object_instance(sphere);
  883. X        }
  884. X        object_move(sphere, 2.0 * SIGNBIT(2, i), 2.0 * SIGNBIT(1, i), 
  885. X                    2.0 * SIGNBIT(0, i));
  886. X        object_add_subobj(structure, sphere);
  887. X    }
  888. X
  889. X    cyl = sipp_cylinder(0.25, 4.0, CYLRES, &cyl_surf, basic_shader);
  890. X    for (i = 0; i < 4; i++) {
  891. X        if (i) {
  892. X            cyl = object_instance(cyl);
  893. X        }
  894. X        object_move(cyl, 2.0 * SIGNBIT(1, i), 2.0 * SIGNBIT(0, i), 0.0);
  895. X        object_add_subobj(structure, cyl);
  896. X    }
  897. X    for (i = 0; i < 4; i++) {
  898. X        cyl = object_instance(cyl);
  899. X        object_rot_x(cyl, M_PI / 2.0);
  900. X        object_move(cyl, 2.0 * SIGNBIT(1, i), 0.0, 2.0 * SIGNBIT(0, i));
  901. X        object_add_subobj(structure, cyl);
  902. X    }
  903. X    for (i = 0; i < 4; i++) {
  904. X        cyl = object_instance(cyl);
  905. X        object_rot_y(cyl, M_PI / 2.0);
  906. X        object_move(cyl, 0.0, 2.0 * SIGNBIT(1, i), 2.0 * SIGNBIT(0, i));
  907. X        object_add_subobj(structure, cyl);
  908. X    }
  909. X    
  910. X    object_install(structure);
  911. X
  912. X    view_from(10.0, -5.0, 15.0);
  913. X    view_at(0.0, 0.0, 0.0);
  914. X    view_up(0.0, 0.0, 1.0);
  915. X    view_focal(0.25);
  916. X
  917. X    printf("Rendering, wait...");
  918. X    fflush(stdout);
  919. X
  920. X    fp = fopen(imfile_name, "w");
  921. X    render_image_file(size, size, fp, mode, 2);
  922. X    printf("Done.\n");
  923. X
  924. X    exit(0);
  925. }
  926. SHAR_EOF
  927. chmod 0664 demo/structure.c ||
  928. echo 'restore of demo/structure.c failed'
  929. Wc_c="`wc -c < 'demo/structure.c'`"
  930. test 3047 -eq "$Wc_c" ||
  931.     echo 'demo/structure.c: original size 3047, current size' "$Wc_c"
  932. fi
  933. # ============= demo/teapot.c ==============
  934. if test -f 'demo/teapot.c' -a X"$1" != X"-c"; then
  935.     echo 'x - skipping demo/teapot.c (File already exists)'
  936. else
  937. echo 'x - extracting demo/teapot.c (Text)'
  938. sed 's/^X//' << 'SHAR_EOF' > 'demo/teapot.c' &&
  939. #include <stdio.h>
  940. X
  941. #include <sipp.h>
  942. #include <primitives.h>
  943. X
  944. X
  945. #define RESOLUTION 9
  946. X
  947. Surf_desc teapot_surf = {
  948. X    0.4, 
  949. X    0.5,
  950. X    0.1, 
  951. X    {0.9, 0.6, 0.6}
  952. };
  953. X
  954. extern char *optarg;
  955. X
  956. main(argc, argv)
  957. X    int argc;
  958. X    char **argv;
  959. {
  960. X    Object  *teapot;
  961. X    Object  *handle;
  962. X    Object  *spout;
  963. X    Object  *body;
  964. X    Object  *lid;
  965. X    FILE    *infile;
  966. X    FILE    *image;
  967. X
  968. X    char    *imfile_name;
  969. X    int      mode;
  970. X    char     c;
  971. X    int      size;
  972. X
  973. X    imfile_name = "teapot.ppm";
  974. X    mode = PHONG;
  975. X    size = 256;
  976. X
  977. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  978. X        switch (c) {
  979. X          case 'p':
  980. X            mode = PHONG;
  981. X            imfile_name = "teapot.ppm";
  982. X            break;
  983. X
  984. X          case 'g':
  985. X            mode = GOURAUD;
  986. X            imfile_name = "teapot.ppm";
  987. X            break;
  988. X
  989. X          case 'f':
  990. X            mode = FLAT;
  991. X            imfile_name = "teapot.ppm";
  992. X            break;
  993. X
  994. X          case 'l':
  995. X            mode = LINE;
  996. X            imfile_name = "teapot.pbm";
  997. X            break;
  998. X
  999. X          case 's':
  1000. X            size = atoi(optarg);
  1001. X            break;
  1002. X        }
  1003. X    }
  1004. X
  1005. X    sipp_init();
  1006. X
  1007. X    infile = fopen("tpt_handle.bez", "r");
  1008. X    handle = sipp_bezier(infile, RESOLUTION, &teapot_surf, basic_shader);
  1009. X    fclose(infile);
  1010. X
  1011. X    infile = fopen("tpt_spout.bez", "r");
  1012. X    spout = sipp_bezier(infile, RESOLUTION, &teapot_surf, basic_shader);
  1013. X    fclose(infile);
  1014. X
  1015. X    infile = fopen("tpt_body.bez", "r");
  1016. X    body = sipp_bezier(infile, RESOLUTION, &teapot_surf, basic_shader);
  1017. X    fclose(infile);
  1018. X
  1019. X    infile = fopen("tpt_lid.bez", "r");
  1020. X    lid = sipp_bezier(infile, RESOLUTION, &teapot_surf, basic_shader);
  1021. X    fclose(infile);
  1022. X
  1023. X    teapot = object_create();
  1024. X    object_add_subobj(teapot, body);
  1025. X    object_add_subobj(teapot, lid);
  1026. X    object_add_subobj(teapot, handle);
  1027. X    object_add_subobj(teapot, spout);
  1028. X
  1029. X    object_install(teapot);
  1030. X
  1031. X    lightsource_push(1.0, 1.0, 1.0, 1.0);
  1032. X    lightsource_push(-1.0, 1.0, -1.0, 0.4);
  1033. X
  1034. X    view_from(0.75, 1.5, 3.5);
  1035. X    view_at(0.0, 0.4, 0.0);
  1036. X    view_up(0.0, 1.0, 0.0);
  1037. X    view_focal(0.25);
  1038. X
  1039. X    printf("Rendering, wait...");
  1040. X    fflush(stdout);
  1041. X
  1042. X    image = fopen(imfile_name, "w");
  1043. X    render_image_file(size, size, image, mode, 2);
  1044. X    printf("Done.\n");
  1045. X
  1046. X    exit(0);
  1047. }
  1048. SHAR_EOF
  1049. chmod 0664 demo/teapot.c ||
  1050. echo 'restore of demo/teapot.c failed'
  1051. Wc_c="`wc -c < 'demo/teapot.c'`"
  1052. test 2263 -eq "$Wc_c" ||
  1053.     echo 'demo/teapot.c: original size 2263, current size' "$Wc_c"
  1054. fi
  1055. # ============= demo/torustest.c ==============
  1056. if test -f 'demo/torustest.c' -a X"$1" != X"-c"; then
  1057.     echo 'x - skipping demo/torustest.c (File already exists)'
  1058. else
  1059. echo 'x - extracting demo/torustest.c (Text)'
  1060. sed 's/^X//' << 'SHAR_EOF' > 'demo/torustest.c' &&
  1061. #include <stdio.h>
  1062. #include <math.h>
  1063. X
  1064. #include <sipp.h>
  1065. #include <primitives.h>
  1066. X
  1067. X
  1068. X
  1069. #define SMALLRES 15
  1070. #define BIGRES   40
  1071. X
  1072. extern char *optarg;
  1073. X
  1074. main(argc, argv)
  1075. X    int    argc;
  1076. X    char **argv;
  1077. {
  1078. X    FILE    *fp ;
  1079. X    Surf_desc surf;
  1080. X
  1081. X    char    *imfile_name;
  1082. X    int      mode;
  1083. X    char     c;
  1084. X    int      size;
  1085. X
  1086. X    imfile_name = "torus.ppm";
  1087. X    mode = PHONG;
  1088. X    size = 256;
  1089. X
  1090. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  1091. X        switch (c) {
  1092. X          case 'p':
  1093. X            mode = PHONG;
  1094. X            imfile_name = "torus.ppm";
  1095. X            break;
  1096. X
  1097. X          case 'g':
  1098. X            mode = GOURAUD;
  1099. X            imfile_name = "torus.ppm";
  1100. X            break;
  1101. X
  1102. X          case 'f':
  1103. X            mode = FLAT;
  1104. X            imfile_name = "torus.ppm";
  1105. X            break;
  1106. X
  1107. X          case 'l':
  1108. X            mode = LINE;
  1109. X            imfile_name = "torus.pbm";
  1110. X            break;
  1111. X
  1112. X          case 's':
  1113. X            size = atoi(optarg);
  1114. X            break;
  1115. X        }
  1116. X    }
  1117. X
  1118. X    sipp_init();
  1119. X
  1120. X    lightsource_push(1.0, 1.0, 1.0, 0.9);
  1121. X    lightsource_push(-1.0, -1.0, 0.5, 0.4);
  1122. X
  1123. X    surf.ambient = 0.5;
  1124. X    surf.color.red = 0.6;
  1125. X    surf.color.grn = 0.3;
  1126. X    surf.color.blu = 0.5;
  1127. X    surf.specular = 0.6;
  1128. X    surf.c3 = 0.2;
  1129. X    
  1130. X    object_install(sipp_torus(1.0, 0.4, BIGRES, SMALLRES, &surf,
  1131. X                              basic_shader)); 
  1132. X
  1133. X    viewpoint(2.0, 0.0, 7.0,  0.5, 0.0, 0.0,  0.0, 0.0, 1.0,  0.4);
  1134. X
  1135. X    printf("Rendering, wait...");
  1136. X    fflush(stdout);
  1137. X
  1138. X    fp = fopen(imfile_name, "w");
  1139. X    render_image_file(size, size, fp, mode, 2);
  1140. X    printf("Done.\n");
  1141. X
  1142. X    exit(0);
  1143. }
  1144. SHAR_EOF
  1145. chmod 0664 demo/torustest.c ||
  1146. echo 'restore of demo/torustest.c failed'
  1147. Wc_c="`wc -c < 'demo/torustest.c'`"
  1148. test 1585 -eq "$Wc_c" ||
  1149.     echo 'demo/torustest.c: original size 1585, current size' "$Wc_c"
  1150. fi
  1151. # ============= demo/tpt_body.bez ==============
  1152. if test -f 'demo/tpt_body.bez' -a X"$1" != X"-c"; then
  1153.     echo 'x - skipping demo/tpt_body.bez (File already exists)'
  1154. else
  1155. echo 'x - extracting demo/tpt_body.bez (Text)'
  1156. sed 's/^X//' << 'SHAR_EOF' > 'demo/tpt_body.bez' &&
  1157. # Bezier curves (rotational body) for teapot body.
  1158. X
  1159. bezier_curves:
  1160. X
  1161. vertices: 10
  1162. vertex_list:
  1163. X    3.500000E-01    5.625000E-01    0.000000E+00
  1164. X    3.343750E-01    5.953125E-01    0.000000E+00
  1165. X    3.593750E-01    5.953125E-01    0.000000E+00
  1166. X    3.750000E-01    5.625000E-01    0.000000E+00
  1167. X    4.375000E-01    4.312500E-01    0.000000E+00
  1168. X    5.000000E-01    3.000000E-01    0.000000E+00
  1169. X    5.000000E-01    1.875000E-01    0.000000E+00
  1170. X    5.000000E-01    7.500000E-02    0.000000E+00
  1171. X    3.750000E-01    1.875000E-02    0.000000E+00
  1172. X    3.750000E-01    0.000000E+00    0.000000E+00
  1173. X
  1174. curves:    3
  1175. curve_list:
  1176. X
  1177. X  1 2 3 4
  1178. X
  1179. X  4 5 6 7
  1180. X
  1181. X  7 8 9 10
  1182. SHAR_EOF
  1183. chmod 0664 demo/tpt_body.bez ||
  1184. echo 'restore of demo/tpt_body.bez failed'
  1185. Wc_c="`wc -c < 'demo/tpt_body.bez'`"
  1186. test 644 -eq "$Wc_c" ||
  1187.     echo 'demo/tpt_body.bez: original size 644, current size' "$Wc_c"
  1188. fi
  1189. # ============= demo/tpt_handle.bez ==============
  1190. if test -f 'demo/tpt_handle.bez' -a X"$1" != X"-c"; then
  1191.     echo 'x - skipping demo/tpt_handle.bez (File already exists)'
  1192. else
  1193. echo 'x - extracting demo/tpt_handle.bez (Text)'
  1194. sed 's/^X//' << 'SHAR_EOF' > 'demo/tpt_handle.bez' &&
  1195. # Bezier patches defining the teapot handle.
  1196. X
  1197. bezier_patches:
  1198. X
  1199. X
  1200. vertices: 42
  1201. vertex_list:
  1202. X
  1203. X   -3.750000E-01    5.250000E-01    0.000000E+00
  1204. X   -6.250000E-01    5.250000E-01    0.000000E+00
  1205. X   -7.500000E-01    5.250000E-01    0.000000E+00
  1206. X   -7.500000E-01    4.125000E-01    0.000000E+00
  1207. X   -7.500000E-01    3.000000E-01    0.000000E+00
  1208. X   -6.625000E-01    1.968750E-01    0.000000E+00
  1209. X   -4.750000E-01    1.125000E-01    0.000000E+00
  1210. X   -3.750000E-01    5.250000E-01   -7.500000E-02
  1211. X   -6.250000E-01    5.250000E-01   -7.500000E-02
  1212. X   -7.500000E-01    5.250000E-01   -7.500000E-02
  1213. X   -7.500000E-01    4.125000E-01   -7.500000E-02
  1214. X   -7.500000E-01    3.000000E-01   -7.500000E-02
  1215. X   -6.625000E-01    1.968750E-01   -7.500000E-02
  1216. X   -4.750000E-01    1.125000E-01   -7.500000E-02
  1217. X   -4.000000E-01    4.687500E-01   -7.500000E-02
  1218. X   -5.750000E-01    4.687500E-01   -7.500000E-02
  1219. X   -6.750000E-01    4.687500E-01   -7.500000E-02
  1220. X   -6.750000E-01    4.125000E-01   -7.500000E-02
  1221. X   -6.750000E-01    3.562500E-01   -7.500000E-02
  1222. X   -6.250000E-01    2.437500E-01   -7.500000E-02
  1223. X   -5.000000E-01    1.875000E-01   -7.500000E-02
  1224. X   -4.000000E-01    4.687500E-01    0.000000E+00
  1225. X   -5.750000E-01    4.687500E-01    0.000000E+00
  1226. X   -6.750000E-01    4.687500E-01    0.000000E+00
  1227. X   -6.750000E-01    4.125000E-01    0.000000E+00
  1228. X   -6.750000E-01    3.562500E-01    0.000000E+00
  1229. X   -6.250000E-01    2.437500E-01    0.000000E+00
  1230. X   -5.000000E-01    1.875000E-01    0.000000E+00
  1231. X   -4.000000E-01    4.687500E-01    7.500000E-02
  1232. X   -5.750000E-01    4.687500E-01    7.500000E-02
  1233. X   -6.750000E-01    4.687500E-01    7.500000E-02
  1234. X   -6.750000E-01    4.125000E-01    7.500000E-02
  1235. X   -6.750000E-01    3.562500E-01    7.500000E-02
  1236. X   -6.250000E-01    2.437500E-01    7.500000E-02
  1237. X   -5.000000E-01    1.875000E-01    7.500000E-02
  1238. X   -3.750000E-01    5.250000E-01    7.500000E-02
  1239. X   -6.250000E-01    5.250000E-01    7.500000E-02
  1240. X   -7.500000E-01    5.250000E-01    7.500000E-02
  1241. X   -7.500000E-01    4.125000E-01    7.500000E-02
  1242. X   -7.500000E-01    3.000000E-01    7.500000E-02
  1243. X   -6.625000E-01    1.968750E-01    7.500000E-02
  1244. X   -4.750000E-01    1.125000E-01    7.500000E-02
  1245. X
  1246. patches:   4
  1247. patch_list:
  1248. X
  1249. X 1  2  3  4
  1250. 36 37 38 39
  1251. 29 30 31 32
  1252. 22 23 24 25
  1253. X
  1254. 22 23 24 25
  1255. 15 16 17 18
  1256. X 8  9 10 11
  1257. X 1  2  3  4
  1258. X
  1259. X 4  5  6  7
  1260. 39 40 41 42
  1261. 32 33 34 35
  1262. 25 26 27 28
  1263. X
  1264. X 7  6  5  4
  1265. 14 13 12 11
  1266. 21 20 19 18
  1267. 28 27 26 25
  1268. SHAR_EOF
  1269. chmod 0664 demo/tpt_handle.bez ||
  1270. echo 'restore of demo/tpt_handle.bez failed'
  1271. Wc_c="`wc -c < 'demo/tpt_handle.bez'`"
  1272. test 2371 -eq "$Wc_c" ||
  1273.     echo 'demo/tpt_handle.bez: original size 2371, current size' "$Wc_c"
  1274. fi
  1275. # ============= demo/tpt_lid.bez ==============
  1276. if test -f 'demo/tpt_lid.bez' -a X"$1" != X"-c"; then
  1277.     echo 'x - skipping demo/tpt_lid.bez (File already exists)'
  1278. else
  1279. echo 'x - extracting demo/tpt_lid.bez (Text)'
  1280. sed 's/^X//' << 'SHAR_EOF' > 'demo/tpt_lid.bez' &&
  1281. # Bezier curves (rotational body) for teapot lid.
  1282. X
  1283. bezier_curves:
  1284. X
  1285. vertices: 7
  1286. vertex_list:
  1287. X
  1288. X    0.000000e+00    7.500000e-01    0.000000e+00
  1289. X    2.000000E-01    7.500000E-01    0.000000E+00
  1290. X    0.000000E+00    6.750000E-01    0.000000E+00
  1291. X    5.000000E-02    6.375000E-01    0.000000E+00
  1292. X    1.000000E-01    6.000000E-01    0.000000E+00
  1293. X    3.250000E-01    6.000000E-01    0.000000E+00
  1294. X    3.500000E-01    5.625000E-01    0.000000E+00
  1295. X
  1296. X
  1297. curves:   2
  1298. curve_list:
  1299. X
  1300. X 1 2 3 4
  1301. X
  1302. X 4 5 6 7
  1303. SHAR_EOF
  1304. chmod 0664 demo/tpt_lid.bez ||
  1305. echo 'restore of demo/tpt_lid.bez failed'
  1306. Wc_c="`wc -c < 'demo/tpt_lid.bez'`"
  1307. test 482 -eq "$Wc_c" ||
  1308.     echo 'demo/tpt_lid.bez: original size 482, current size' "$Wc_c"
  1309. fi
  1310. # ============= demo/tpt_spout.bez ==============
  1311. if test -f 'demo/tpt_spout.bez' -a X"$1" != X"-c"; then
  1312.     echo 'x - skipping demo/tpt_spout.bez (File already exists)'
  1313. else
  1314. echo 'x - extracting demo/tpt_spout.bez (Text)'
  1315. sed 's/^X//' << 'SHAR_EOF' > 'demo/tpt_spout.bez' &&
  1316. # Bezier patches for teapot spout
  1317. X
  1318. bezier_patches:
  1319. X
  1320. vertices: 42
  1321. vertex_list:
  1322. X    4.250000E-01    3.187500E-01    0.000000E+00
  1323. X    6.500000E-01    3.187500E-01    0.000000E+00
  1324. X    5.750000E-01    4.875000E-01    0.000000E+00
  1325. X    6.750000E-01    5.625000E-01    0.000000E+00
  1326. X    7.000000E-01    5.812500E-01    0.000000E+00
  1327. X    7.250000E-01    5.812500E-01    0.000000E+00
  1328. X    7.000000E-01    5.625000E-01    0.000000E+00
  1329. X    4.250000E-01    3.187500E-01    1.650000E-01
  1330. X    6.500000E-01    3.187500E-01    1.650000E-01
  1331. X    5.750000E-01    4.875000E-01    6.250000E-02
  1332. X    6.750000E-01    5.625000E-01    6.250000E-02
  1333. X    7.000000E-01    5.812500E-01    6.250000E-02
  1334. X    7.250000E-01    5.812500E-01    3.750000E-02
  1335. X    7.000000E-01    5.625000E-01    3.750000E-02
  1336. X    4.250000E-01    1.125000E-01    1.650000E-01
  1337. X    7.750000E-01    1.687500E-01    1.650000E-01
  1338. X    6.000000E-01    4.687500E-01    6.250000E-02
  1339. X    8.250000E-01    5.625000E-01    6.250000E-02
  1340. X    8.812500E-01    5.859375E-01    6.250000E-02
  1341. X    8.625000E-01    5.906250E-01    3.750000E-02
  1342. X    8.000000E-01    5.625000E-01    3.750000E-02
  1343. X    4.250000E-01    1.125000E-01    0.000000E+00
  1344. X    7.750000E-01    1.687500E-01    0.000000E+00
  1345. X    6.000000E-01    4.687500E-01    0.000000E+00
  1346. X    8.250000E-01    5.625000E-01    0.000000E+00
  1347. X    8.812500E-01    5.859375E-01    0.000000E+00
  1348. X    8.625000E-01    5.906250E-01    0.000000E+00
  1349. X    8.000000E-01    5.625000E-01    0.000000E+00
  1350. X    4.250000E-01    1.125000E-01   -1.650000E-01
  1351. X    7.750000E-01    1.687500E-01   -1.650000E-01
  1352. X    6.000000E-01    4.687500E-01   -6.250000E-02
  1353. X    8.250000E-01    5.625000E-01   -6.250000E-02
  1354. X    8.812500E-01    5.859375E-01   -6.250000E-02
  1355. X    8.625000E-01    5.906250E-01   -3.750000E-02
  1356. X    8.000000E-01    5.625000E-01   -3.750000E-02
  1357. X    4.250000E-01    3.187500E-01   -1.650000E-01
  1358. X    6.500000E-01    3.187500E-01   -1.650000E-01
  1359. X    5.750000E-01    4.875000E-01   -6.250000E-02
  1360. X    6.750000E-01    5.625000E-01   -6.250000E-02
  1361. X    7.000000E-01    5.812500E-01   -6.250000E-02
  1362. X    7.250000E-01    5.812500E-01   -3.750000E-02
  1363. X    7.000000E-01    5.625000E-01   -3.750000E-02
  1364. X
  1365. patches:   4
  1366. patch_list:
  1367. X
  1368. 22 23 24 25
  1369. 15 16 17 18
  1370. X 8  9 10 11
  1371. X 1  2  3  4
  1372. X
  1373. X 1  2  3  4
  1374. 36 37 38 39
  1375. 29 30 31 32
  1376. 22 23 24 25
  1377. X
  1378. 25 26 27 28
  1379. 18 19 20 21
  1380. 11 12 13 14
  1381. X 4  5  6  7
  1382. X
  1383. X 4  5  6  7
  1384. 39 40 41 42
  1385. 32 33 34 35
  1386. 25 26 27 28
  1387. SHAR_EOF
  1388. chmod 0664 demo/tpt_spout.bez ||
  1389. echo 'restore of demo/tpt_spout.bez failed'
  1390. Wc_c="`wc -c < 'demo/tpt_spout.bez'`"
  1391. test 2358 -eq "$Wc_c" ||
  1392.     echo 'demo/tpt_spout.bez: original size 2358, current size' "$Wc_c"
  1393. fi
  1394. # ============= demo/woodtest.c ==============
  1395. if test -f 'demo/woodtest.c' -a X"$1" != X"-c"; then
  1396.     echo 'x - skipping demo/woodtest.c (File already exists)'
  1397. else
  1398. echo 'x - extracting demo/woodtest.c (Text)'
  1399. sed 's/^X//' << 'SHAR_EOF' > 'demo/woodtest.c' &&
  1400. #include <stdio.h>
  1401. #include <math.h>
  1402. X
  1403. #include <sipp.h>
  1404. #include <shaders.h>
  1405. #include <primitives.h>
  1406. X
  1407. X
  1408. Wood_desc wood_surf = {
  1409. X    0.5, 
  1410. X    0.0, 
  1411. X    0.99, 
  1412. X    10.0, 
  1413. X    {0.770,  0.568,  0.405}, 
  1414. X    {0.468,  0.296,  0.156}, 
  1415. };
  1416. X
  1417. X
  1418. extern char *optarg;
  1419. X
  1420. main(argc, argv)
  1421. X    int    argc;
  1422. X    char **argv;
  1423. {
  1424. X    FILE    *fp ;
  1425. X
  1426. X    char    *imfile_name;
  1427. X    int      mode;
  1428. X    char     c;
  1429. X    int      size;
  1430. X
  1431. X    imfile_name = "wood.ppm";
  1432. X    mode = PHONG;
  1433. X    size = 256;
  1434. X
  1435. X    while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  1436. X        switch (c) {
  1437. X          case 'p':
  1438. X            mode = PHONG;
  1439. X            imfile_name = "wood.ppm";
  1440. X            break;
  1441. X
  1442. X          case 'g':
  1443. X            mode = GOURAUD;
  1444. X            imfile_name = "wood.ppm";
  1445. X            break;
  1446. X
  1447. X          case 'f':
  1448. X            mode = FLAT;
  1449. X            imfile_name = "wood.ppm";
  1450. X            break;
  1451. X
  1452. X          case 'l':
  1453. X            mode = LINE;
  1454. X            imfile_name = "wood.pbm";
  1455. X            break;
  1456. X
  1457. X          case 's':
  1458. X            size = atoi(optarg);
  1459. X            break;
  1460. X        }
  1461. X    }
  1462. X
  1463. X    sipp_init();
  1464. X
  1465. X    lightsource_push(1.0, 1.0, 1.0, 0.9);
  1466. X
  1467. X    object_install(sipp_block(4.0, 3.0, 3.0, &wood_surf, wood_shader)); 
  1468. X
  1469. X    viewpoint(10.0, 10.0, 20.0,  0.0, 0.0, 0.0,  0.0, 1.0, 0.0,  0.125);
  1470. X
  1471. X    printf("Rendering, wait...");
  1472. X    fflush(stdout);
  1473. X
  1474. X    fp = fopen(imfile_name, "w");
  1475. X    render_image_file(size, size, fp, mode, 2);
  1476. X    printf("Done.\n");
  1477. X
  1478. X    exit(0);
  1479. }
  1480. SHAR_EOF
  1481. chmod 0644 demo/woodtest.c ||
  1482. echo 'restore of demo/woodtest.c failed'
  1483. Wc_c="`wc -c < 'demo/woodtest.c'`"
  1484. test 1441 -eq "$Wc_c" ||
  1485.     echo 'demo/woodtest.c: original size 1441, current size' "$Wc_c"
  1486. fi
  1487. exit 0
  1488.  
  1489. -- 
  1490. ------------------------------------------------------------------------------
  1491.  J o n a s   Y n g v e s s o n
  1492. Dept. of Electrical Engineering                             jonas-y@isy.liu.se
  1493. University of Linkoping, Sweden                   ...!uunet!isy.liu.se!jonas-y
  1494.  
  1495. exit 0 # Just in case...
  1496.