home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume16 / sipp2.0 / part01 next >
Encoding:
Internet Message Format  |  1991-01-02  |  51.2 KB

  1. From: kent@sparky.IMD.Sterling.COM (Kent Landfield)
  2. Newsgroups: comp.sources.misc
  3. Subject: v16i005:  sipp 2.0 - a library for 3D graphics, Part01/06
  4. Message-ID: <1991Jan3.065459.4991@sparky.IMD.Sterling.COM>
  5. Date: 3 Jan 91 06:54:59 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: c73dc831 0ea7b816 cf160ca9 668afaed
  8.  
  9. Submitted-by: ingwa@isy.liu.se (Inge Wallin)
  10. Posting-number: Volume 16, Issue 5
  11. Archive-name: sipp2.0/part01
  12.  
  13. This is an excerpt from the README file:
  14.  
  15. *******************************************************************
  16.              sipp 2.0  --  3d rendering package
  17.  
  18.              by         Jonas Yngvesson   jonas-y@isy.liu.se
  19.                         Inge Wallin       ingwa@isy.liu.se
  20.  
  21.              Linkoping Institute of Technology
  22.              Sweden
  23. *******************************************************************
  24.  
  25. This is the beta-test release of version 2.0 of SIPP, the SImple
  26. Polygon Processor. SIPP is a library for creating 3-dimensional
  27. scenes and rendering them using a scan-line z-buffer algorithm. A
  28. scene is built up of objects which can be transformed with rotation,
  29. translation and scaling. The objects form hierarchies where each
  30. object can have arbitrarily many subobjects and subsurfaces. A
  31. surface is a number of connected polygons which are rendered with
  32. Phong interpolation of the surface normals.
  33.  
  34. The library has an internal database for the objects that is to be
  35. rendered. Objects can be installed in, and removed from, this
  36. database at any time.
  37.  
  38. The library also provides 3-dimensional texture mapping with
  39. automatic interpolation of texture coordinates. Simple anti-aliasing
  40. is performed through double oversampling. A scene can be illuminated
  41. by an arbitrary number of light sources. A basic shading algorithm is
  42. provided with the library, but the user can also use his own shading
  43. algorithms for each surface to produce special effects. Images are
  44. produced in the Portable Pixmap format (ppm) for which many utilities
  45. exist.
  46.  
  47. -------------------------- CUT HERE --------------------------
  48. #!/bin/sh
  49. # This is sipp-2.0, a shell archive (produced by shar 3.49)
  50. # To extract the files from this archive, save it to a file, remove
  51. # everything above the "!/bin/sh" line above, and type "sh file_name".
  52. #
  53. # made 12/20/1990 14:54 UTC by jonas-y@brassie
  54. # Source directory /u1/it/jonas-y/sippuz/sipp-2.0
  55. #
  56. # existing files will NOT be overwritten unless -c is specified
  57. #
  58. # This shar contains:
  59. # length  mode       name
  60. # ------ ---------- ------------------------------------------
  61. #   2565 -rw-r--r-- Makefile
  62. #   2520 -rw-r--r-- README
  63. #   2426 -rw-r--r-- libsipp/Makefile
  64. #   3876 -rw-r--r-- libsipp/TAGS
  65. #    377 -rw-r--r-- libsipp/TODO
  66. #   1710 -rw-r--r-- libsipp/basic_shader.c
  67. #  12593 -rw-r--r-- libsipp/bezier.c
  68. #    676 -rw-r--r-- libsipp/bezier.h
  69. #  10294 -rw-r--r-- libsipp/bezier_lex.c
  70. #    964 -rw-r--r-- libsipp/bezier_lex.l
  71. #   1968 -rw-r--r-- libsipp/block.c
  72. #    895 -rw-r--r-- libsipp/bozo.c
  73. #   1027 -rw-r--r-- libsipp/bumpy.c
  74. #   1981 -rw-r--r-- libsipp/cylinder.c
  75. #   3850 -rw-r--r-- libsipp/ellipsoid.c
  76. #   9833 -rw-r--r-- libsipp/geometric.c
  77. #   4007 -rw-r--r-- libsipp/geometric.h
  78. #   1373 -rw-r--r-- libsipp/granite.c
  79. #   1607 -rw-r--r-- libsipp/marble.c
  80. #    741 -rw-r--r-- libsipp/mask.c
  81. #   9261 -rw-r--r-- libsipp/noise.c
  82. #    234 -rw-r--r-- libsipp/noise.h
  83. #   1700 -rw-r--r-- libsipp/planet.c
  84. #    211 -rw-r--r-- libsipp/primitives.h
  85. #   3024 -rw-r--r-- libsipp/shaders.h
  86. #  52154 -rw-r--r-- libsipp/sipp.c
  87. #   5119 -rw-r--r-- libsipp/sipp.h
  88. #   1885 -rw-r--r-- libsipp/sipptypes.h
  89. #   2322 -rw-r--r-- libsipp/torus.c
  90. #   5405 -rw-r--r-- libsipp/xalloca.c
  91. #    314 -rw-r--r-- libsipp/xalloca.h
  92. #   7416 -rw-r--r-- doc/primitives.man
  93. #  10071 -rw-r--r-- doc/shaders.man
  94. #  20064 -rw-r--r-- doc/sipp.man
  95. #   2518 -rw-r--r-- demo/Makefile
  96. #   1771 -rw-r--r-- demo/README
  97. #    327 -rw-r--r-- demo/TAGS
  98. #    830 -rw-r--r-- demo/blocktest.c
  99. #   1910 -rw-r--r-- demo/chain.c
  100. #    866 -rw-r--r-- demo/cylindertest.c
  101. #    908 -rw-r--r-- demo/ellipsoid.c
  102. #   2837 -rw-r--r-- demo/isy90.c
  103. #    878 -rw-r--r-- demo/planettest.c
  104. #   2360 -rw-r--r-- demo/structure.c
  105. #   1505 -rw-r--r-- demo/teapot.c
  106. #    914 -rw-r--r-- demo/torustest.c
  107. #    644 -rw-r--r-- demo/tpt_body.bez
  108. #   2371 -rw-r--r-- demo/tpt_handle.bez
  109. #    481 -rw-r--r-- demo/tpt_lid.bez
  110. #   2358 -rw-r--r-- demo/tpt_spout.bez
  111. #
  112. # ============= Makefile ==============
  113. if test -f 'Makefile' -a X"$1" != X"-c"; then
  114.     echo 'x - skipping Makefile (File already exists)'
  115. else
  116. echo 'x - extracting Makefile (Text)'
  117. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  118. #             sipp 2.0 - a 3-d rendering library
  119. #
  120. # Copyright 1990 Inge Wallin, Jonas Yngvesson
  121. #
  122. # This is the main Makefile for sipp version 2.0. This directory
  123. # contains three subdirectories:
  124. # libsipp: source code for the library itself.
  125. # demo:    source code for demonstrations and tests
  126. # doc:     standard manual pages for the library.
  127. #
  128. # You can either make the library and the tests/demos separately or 
  129. # you can make them all in one make session. 
  130. #
  131. # To create the library, just type 'make library'.
  132. # To make the demo programs, type 'make demos', but if you haven't 
  133. # made the library first, this will be made automatically for you by
  134. # the makefile in the demos directory.
  135. #
  136. # Before you can make anything, though, you may have to edit the 
  137. # following definitions:
  138. X
  139. X
  140. # If your C compiler doesn't grok the void type, uncomment the 
  141. # following line:
  142. #NOVOID = -Dvoid=int
  143. X
  144. # If you don't have memcpy() and friends in your C library, or 
  145. # if you don't have memory.h in /usr/include, uncomment the
  146. # following line:
  147. #NOMEMCPY = -DNOMEMCPY
  148. X
  149. # If you don't have alloca(), uncomment the following line:
  150. #ALLOCA = -DHAVE_NO_ALLOCA
  151. X
  152. # Choose a suitable C compiler and appropriate flags:
  153. CC = cc
  154. CFLAGS = -O4 -pipe
  155. X
  156. # Choose a lexical analyzer generator:
  157. LEX = lex
  158. X
  159. X
  160. # LIBDIR is where libsipp.a will be placed when you make install.
  161. # INCLUDEDIR is where the include files will be placed when you make install.
  162. # MANDIR is where the manuals will be placed when you make install.
  163. # MANEXT is the extension the manuals will receive in MANDIR
  164. X
  165. LIBDIR = /usr/local/lib
  166. INCLUDEDIR = /usr/local/include
  167. MANDIR = /usr/local/man/man3
  168. MANEXT = 3
  169. X
  170. X
  171. # ================================================================
  172. #           Don't change anything below this line.
  173. # ================================================================
  174. X
  175. DOCFILES = primitives.man shaders.man sipp.man
  176. HEADERS =  sipp.h shaders.h primitives.h
  177. X
  178. X
  179. MAKEOPTS = CC=$(CC) LEX=$(LEX) \
  180. X    CFLAGS="$(NOVOID) $(NOMEMCPY) $(ALLOCA) $(CFLAGS) -I../libsipp"
  181. X        
  182. X
  183. all: library demos
  184. X
  185. library:
  186. X    cd libsipp; $(MAKE) $(MAKEOPTS) libsipp.a
  187. X
  188. demos:
  189. X    cd demo; $(MAKE) $(MAKEOPTS) programs
  190. X
  191. X
  192. install: library
  193. X    cd libsipp; $(MAKE) LIBDIR=$(LIBDIR) INCLUDEDIR=$(INCLUDEDIR) install
  194. X    for i in $(DOCFILES) ; do \
  195. X        cp doc/$$i $(MANDIR)/`basename $$i .man`.$(MANEXT); \
  196. X    done
  197. X
  198. X
  199. clean:
  200. X    $(RM) *~ *shar*
  201. X    cd libsipp; $(MAKE) clean;
  202. X    cd demo; $(MAKE) clean;
  203. X    cd doc;   ls -1 | egrep -v \.man$$ | xargs rm -f
  204. X
  205. shar: clean
  206. X    shar -a -n sipp-2.0 -l 50 -o sipp-2.0.shar Makefile README \
  207. X    libsipp/* doc/* demo/*
  208. SHAR_EOF
  209. chmod 0644 Makefile ||
  210. echo 'restore of Makefile failed'
  211. Wc_c="`wc -c < 'Makefile'`"
  212. test 2565 -eq "$Wc_c" ||
  213.     echo 'Makefile: original size 2565, current size' "$Wc_c"
  214. fi
  215. # ============= README ==============
  216. if test -f 'README' -a X"$1" != X"-c"; then
  217.     echo 'x - skipping README (File already exists)'
  218. else
  219. echo 'x - extracting README (Text)'
  220. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  221. *******************************************************************
  222. X             sipp 2.0  --  3d rendering package
  223. X
  224. X             by         Jonas Yngvesson   jonas-y@isy.liu.se
  225. X                        Inge Wallin       ingwa@isy.liu.se
  226. X
  227. X             Linkoping Institute of Technology
  228. X             Sweden
  229. *******************************************************************
  230. X
  231. This is the beta-test release of version 2.0 of SIPP, the SImple
  232. Polygon Processor. SIPP is a library for creating 3-dimensional
  233. scenes and rendering them using a scan-line z-buffer algorithm. A
  234. scene is built up of objects which can be transformed with rotation,
  235. translation and scaling. The objects form hierarchies where each
  236. object can have arbitrarily many subobjects and subsurfaces. A
  237. surface is a number of connected polygons which are rendered with
  238. Phong interpolation of the surface normals.
  239. X
  240. The library has an internal database for the objects that is to be
  241. rendered. Objects can be installed in, and removed from, this
  242. database at any time.
  243. X
  244. The library also provides 3-dimensional texture mapping with
  245. automatic interpolation of texture coordinates. Simple anti-aliasing
  246. is performed through double oversampling. A scene can be illuminated
  247. by an arbitrary number of light sources. A basic shading algorithm is
  248. provided with the library, but the user can also use his own shading
  249. algorithms for each surface to produce special effects. Images are
  250. produced in the Portable Pixmap format (ppm) for which many utilities
  251. exist.
  252. X
  253. The program has some bugs & limitations. See the BUGS entry in the
  254. manuals for more information.
  255. X
  256. To install the library, edit the Makefile and type 'make install'. If
  257. Your system does not have the drand48() random number generator, change
  258. the macro RANDOM() in sipp.h to use the random number generator available
  259. on your system.
  260. X
  261. If you only want to make the library but not install it, just type
  262. 'make library'.
  263. X
  264. If you want to make the tests and demonstrations, type 'make demos'. 
  265. X
  266. X
  267. The library has so far only been tested on Sun workstations
  268. (SPARCstation & SUN3) but should work on most platforms regardless
  269. of UNIX version. If you run into trouble, let us know.
  270. X
  271. Please send any enhancements, bug reports and fixes to us.
  272. Especially, if you create nice new object types, we would be
  273. grateful if you sent the C functions creating those to us. We could
  274. then compile a library of object functions and let other people share
  275. the benefits.
  276. X
  277. Linkoping 19 December 1990
  278. X
  279. X                enjoy! /Jonas & Inge
  280. SHAR_EOF
  281. chmod 0644 README ||
  282. echo 'restore of README failed'
  283. Wc_c="`wc -c < 'README'`"
  284. test 2520 -eq "$Wc_c" ||
  285.     echo 'README: original size 2520, current size' "$Wc_c"
  286. fi
  287. # ============= libsipp/Makefile ==============
  288. if test ! -d 'libsipp'; then
  289.     echo 'x - creating directory libsipp'
  290.     mkdir 'libsipp'
  291. fi
  292. if test -f 'libsipp/Makefile' -a X"$1" != X"-c"; then
  293.     echo 'x - skipping libsipp/Makefile (File already exists)'
  294. else
  295. echo 'x - extracting libsipp/Makefile (Text)'
  296. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/Makefile' &&
  297. #
  298. # Makefile for libsipp.a
  299. #
  300. X
  301. #These values are default if they are not overridden from the command line:
  302. CC = cc
  303. CFLAGS = -pipe -I. -DHAVE_NO_ALLOCA
  304. X
  305. X
  306. IHDRS = sipptypes.h geometric.h noise.h bezier.h
  307. EHDRS = sipp.h shaders.h primitives.h
  308. HDRS = $(IHDRS) $(EHDRS)
  309. SRCS =  sipp.c geometric.c \
  310. X    basic_shader.c mask.c marble.c granite.c noise.c bozo.c bumpy.c \
  311. X    planet.c \
  312. X    block.c cylinder.c ellipsoid.c torus.c bezier.c bezier_lex.l
  313. LIBOBJS = libsipp.a(sipp.o) libsipp.a(geometric.o) libsipp.a(basic_shader.o)\
  314. X          libsipp.a(marble.o) libsipp.a(granite.o) libsipp.a(mask.o)\
  315. X          libsipp.a(bozo.o) libsipp.a(bumpy.o) libsipp.a(planet.o)\
  316. X          libsipp.a(noise.o) libsipp.a(bezier.o) libsipp.a(bezier_lex.o)\
  317. X          libsipp.a(torus.o) libsipp.a(cylinder.o) libsipp.a(ellipsoid.o) \
  318. X          libsipp.a(block.o) \
  319. X      libsipp.a(xalloca.o)
  320. X
  321. X
  322. # These are used if no other values are given at the command line:
  323. LIBDIR = /usr/local/lib
  324. INCLUDEDIR = /usr/local/include
  325. X
  326. X
  327. all: libsipp.a
  328. X
  329. libsipp.a:      $(LIBOBJS)
  330. X    ranlib libsipp.a
  331. X
  332. install: libsipp.a $(EHDRS)
  333. X    cp libsipp.a $(LIBDIR)
  334. X    cp $(EHDRS) $(INCLUDEDIR)
  335. X
  336. X
  337. libsipp.a(sipp.o):              sipp.o
  338. libsipp.a(geometric.o):         geometric.o
  339. libsipp.a(basic_shader.o):      basic_shader.o
  340. libsipp.a(mask.o):              mask.o
  341. libsipp.a(marble.o):            marble.o
  342. libsipp.a(granite.o):           granite.o
  343. libsipp.a(bozo.o):              bozo.o
  344. libsipp.a(bumpy.o):            bumpy.o
  345. libsipp.a(planet.o):        planet.o
  346. libsipp.a(noise.o):             noise.o
  347. libsipp.a(bezier.o):            bezier.o
  348. libsipp.a(bezier_lex.o):        bezier_lex.o
  349. libsipp.a(torus.o):             torus.o
  350. libsipp.a(cylinder.o):          cylinder.o
  351. libsipp.a(ellipsoid.o):         ellipsoid.o
  352. libsipp.a(block.o):             block.o
  353. X
  354. X
  355. X
  356. tags:
  357. X    etags -t $(HDRS) $(SRCS)
  358. X
  359. clean: 
  360. X    $(RM) *.o *~ libsipp.a
  361. X
  362. X
  363. sipp.o:          sipp.h sipptypes.h geometric.h
  364. geometric.o:     geometric.h sipp.h
  365. basic_shader.o:  sipp.h
  366. mask.o:          shaders.h sipp.h
  367. marble.o:        noise.h shaders.h sipp.h
  368. granite.o:       noise.h shaders.h sipp.h
  369. bozo.o:          noise.h shaders.h sipp.h
  370. bumpy.o:     noise.h shaders.h sipp.h geometric.h
  371. planet.o:     noise.h sipp.h geometric.h
  372. noise.o:         noise.h sipp.h
  373. bezier.o:        bezier.h sipp.h
  374. bezier_lex.o:    bezier_lex.l bezier.h
  375. torus.o:         sipp.h
  376. cylinder.o:      sipp.h
  377. ellipsoid:       sipp.h
  378. block.o:         sipp.h
  379. xalloca.o:       xalloca.h
  380. SHAR_EOF
  381. chmod 0644 libsipp/Makefile ||
  382. echo 'restore of libsipp/Makefile failed'
  383. Wc_c="`wc -c < 'libsipp/Makefile'`"
  384. test 2426 -eq "$Wc_c" ||
  385.     echo 'libsipp/Makefile: original size 2426, current size' "$Wc_c"
  386. fi
  387. # ============= libsipp/TAGS ==============
  388. if test -f 'libsipp/TAGS' -a X"$1" != X"-c"; then
  389.     echo 'x - skipping libsipp/TAGS (File already exists)'
  390. else
  391. echo 'x - extracting libsipp/TAGS (Text)'
  392. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/TAGS' &&
  393. X
  394. sipptypes.h,78
  395. } Bucket;48,1498
  396. } Edge;40,1365
  397. } Inst_object;61,1843
  398. } View_coord;20,527
  399. X
  400. geometric.h,389
  401. #define MakePoint2d(42,943
  402. #define MakePoint3d(46,1070
  403. #define MakeVector(51,1250
  404. #define MatCopy(104,2696
  405. #define Vec2Row(113,2964
  406. #define VecAdd(70,1742
  407. #define VecAddS(85,2099
  408. #define VecComb(90,2240
  409. #define VecCopy(67,1691
  410. #define VecCross(95,2393
  411. #define VecDot(61,1548
  412. #define VecLen(64,1631
  413. #define VecNegate(56,1417
  414. #define VecScalMul(80,1978
  415. #define VecSub(75,1861
  416. X
  417. noise.h,0
  418. X
  419. bezier.h,101
  420. } Bez_Curve;25,377
  421. } Bez_Object;43,662
  422. } Bez_Patch;29,426
  423. } Bez_Vertex;21,330
  424. } Tokenval;16,279
  425. X
  426. sipp.h,312
  427. X24,347
  428. } Color;40,564
  429. } Lightsource;130,3248
  430. } Object;119,2965
  431. } Polygon;89,1793
  432. typedef void Shader(29,390
  433. } Surf_desc;142,3674
  434. } Surface;104,2398
  435. } Transf_mat;52,818
  436. } Vector;57,871
  437. } Vertex;69,1321
  438. } Vertex_ref;78,1477
  439. typedef unsigned char 11,102
  440. #define 12,130
  441. #define 13,147
  442. #define 22,287
  443. X
  444. shaders.h,110
  445. } Bozo_desc;28,601
  446. } Bumpy_desc;97,2757
  447. } Granite_desc;60,1492
  448. } Marble_desc;44,1054
  449. } Mask_desc;82,2475
  450. X
  451. primitives.h,0
  452. X
  453. sipp.c,1584
  454. calc_normals(1097,25896
  455. copy_polygons(506,13924
  456. copy_vertices(464,12968
  457. copy_vlist(485,13406
  458. create_edges(1148,27637
  459. delete_edges(1780,47171
  460. delete_vertices(553,14999
  461. get_view_transf(1678,44431
  462. init_buffers(1395,36211
  463. insert_edge(1502,39380
  464. lightsource_push(146,5630
  465. matrix_pop(1815,47811
  466. matrix_push(1799,47488
  467. merge_edge_lists(1536,40219
  468. object_add_subobj(912,22640
  469. object_add_surface(943,23248
  470. object_clear_transf(987,24033
  471. object_copy(727,18662
  472. object_create(703,18150
  473. object_deep_dup(843,21073
  474. object_delete(887,21966
  475. object_dup(820,20689
  476. object_install(628,16789
  477. object_instance(804,20409
  478. object_list_copy(761,19449
  479. object_move(1073,25337
  480. object_rot(1047,24922
  481. object_rot_x(1010,24395
  482. object_rot_y(1022,24562
  483. object_rot_z(1034,24729
  484. object_scale(1061,25142
  485. object_set_transf(975,23840
  486. object_transform(998,24198
  487. object_uninstall(690,17956
  488. polygon_push(357,10556
  489. r_del(640,16929
  490. r_object_delete(867,21574
  491. r_object_install(603,16126
  492. r_object_uninstall(660,17275
  493. render_image(1924,50800
  494. render_line(1419,36768
  495. reset_normals(1658,44082
  496. scan_and_render(1563,40854
  497. sipp_init(1955,51451
  498. surface_basic_create(404,11594
  499. surface_basic_shader(442,12444
  500. surface_copy(527,14400
  501. surface_create(377,10974
  502. surface_delete(569,15256
  503. surface_set_shader(425,12150
  504. transf_vertices(1318,33551
  505. traverse_object_db(1903,50217
  506. traverse_object_tree(1834,48181
  507. vertex_lookup(263,7829
  508. vertex_push(305,9061
  509. vertex_tx_push(316,9254
  510. view_at(202,6760
  511. view_focal(227,7093
  512. view_from(188,6572
  513. view_up(216,6961
  514. view_vec_eval(174,6366
  515. viewpoint(238,7224
  516. X
  517. geometric.c,258
  518. mat_mirror_plane(252,5925
  519. mat_mul(301,7729
  520. mat_mul34(361,9296
  521. mat_rotate(193,4456
  522. mat_rotate_x(98,2067
  523. mat_rotate_y(131,2937
  524. mat_rotate_z(164,3808
  525. mat_scale(227,5422
  526. mat_translate(73,1401
  527. new_matrix(25,397
  528. point_transform(341,8728
  529. vecnorm(47,779
  530. X
  531. basic_shader.c,21
  532. basic_shader(12,131
  533. X
  534. mask.c,18
  535. mask_shader(7,78
  536. X
  537. marble.c,38
  538. marble(17,206
  539. marble_shader(46,1025
  540. X
  541. granite.c,39
  542. granite 17,214
  543. granite_shader(44,788
  544. X
  545. noise.c,115
  546. Vector Dnoise(187,4647
  547. iadjust(39,706
  548. double noise(69,1228
  549. void noise_init(57,1062
  550. double turbulence(167,4317
  551. X
  552. bozo.c,20
  553. bozo_shader(16,198
  554. X
  555. bumpy.c,21
  556. bumpy_shader(18,219
  557. X
  558. planet.c,35
  559. planet_shader(53,899
  560. turb(25,447
  561. X
  562. block.c,38
  563. sipp_block(17,188
  564. sipp_cube(73,1808
  565. X
  566. cylinder.c,20
  567. sipp_cylinder(8,68
  568. X
  569. ellipsoid.c,43
  570. sipp_ellipsoid(8,68
  571. sipp_sphere(108,3652
  572. X
  573. torus.c,52
  574. arr_rot(8,71
  575. push_band(28,444
  576. sipp_torus(52,1101
  577. X
  578. bezier.c,239
  579. C(266,6370
  580. bblend(284,6575
  581. bez_curve_eval(313,7069
  582. bez_patch_eval(341,7691
  583. bezier_patches(381,8825
  584. bezier_read(204,4884
  585. bezier_rot_curves(426,10334
  586. curve_read(86,2083
  587. patch_read(144,3433
  588. sipp_bezier(484,12019
  589. vertex_read(24,591
  590. X
  591. bezier_lex.l,0
  592. SHAR_EOF
  593. chmod 0644 libsipp/TAGS ||
  594. echo 'restore of libsipp/TAGS failed'
  595. Wc_c="`wc -c < 'libsipp/TAGS'`"
  596. test 3876 -eq "$Wc_c" ||
  597.     echo 'libsipp/TAGS: original size 3876, current size' "$Wc_c"
  598. fi
  599. # ============= libsipp/TODO ==============
  600. if test -f 'libsipp/TODO' -a X"$1" != X"-c"; then
  601.     echo 'x - skipping libsipp/TODO (File already exists)'
  602. else
  603. echo 'x - extracting libsipp/TODO (Text)'
  604. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/TODO' &&
  605. X
  606. Minor:
  607. X
  608. Make antialiasing optional with some kind of flag.
  609. X
  610. [Have the program whistle while it works with a verbose flag.]
  611. X
  612. Make it possible to render into a pixmap in core.
  613. X
  614. Major:
  615. X
  616. [Arbitrary number of "texture coordinates" (numbers to be
  617. interpolated over polygon surfaces).]
  618. X
  619. [More sofisticated antialiasing (A-buffer??)]
  620. X
  621. [Line image (without hidden lines) for preview.]
  622. SHAR_EOF
  623. chmod 0644 libsipp/TODO ||
  624. echo 'restore of libsipp/TODO failed'
  625. Wc_c="`wc -c < 'libsipp/TODO'`"
  626. test 377 -eq "$Wc_c" ||
  627.     echo 'libsipp/TODO: original size 377, current size' "$Wc_c"
  628. fi
  629. # ============= libsipp/basic_shader.c ==============
  630. if test -f 'libsipp/basic_shader.c' -a X"$1" != X"-c"; then
  631.     echo 'x - skipping libsipp/basic_shader.c (File already exists)'
  632. else
  633. echo 'x - extracting libsipp/basic_shader.c (Text)'
  634. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/basic_shader.c' &&
  635. /*
  636. X * Basic shading model, somewhat modified and simplified version of
  637. X * Blinn's
  638. X */
  639. X
  640. #include <math.h>
  641. X
  642. #include <sipp.h>
  643. X
  644. X
  645. void
  646. basic_shader(a, b, c, u, v, w, view_vec, lights, sd, color)
  647. X    double       a, b, c, u, v, w;
  648. X    Vector       view_vec;
  649. X    Lightsource *lights;
  650. X    Surf_desc   *sd;
  651. X    Color       *color;
  652. {
  653. X    double       nx, ny, nz, l;
  654. X    double       xs, ys, zs;
  655. X    double       coss, cosi, diffsum, specsum;
  656. X    double       c3two;
  657. X    Lightsource *lp;
  658. X
  659. X    l = (a * a + b * b + c * c);
  660. X    nx = a;
  661. X    ny = b;
  662. X    nz = c;
  663. X    if (fabs(l - 1.0) > 1e-5) {
  664. X        l = sqrt(l);
  665. X        nx /= l;
  666. X        ny /= l;
  667. X        nz /= l;
  668. X    }
  669. X    diffsum = specsum = 0;
  670. X    c3two = sd->c3 * sd->c3;
  671. X    for (lp = lights; lp != (Lightsource *)0; lp = lp->next) {
  672. X        cosi = (lp->dir.x * nx + lp->dir.y * ny + lp->dir.z * nz);
  673. X         if (cosi > 0)
  674. X            diffsum += cosi * lp->intensity;
  675. X        cosi *= -2.0;
  676. X        xs = -lp->dir.x - cosi * nx;
  677. X        ys = -lp->dir.y - cosi * ny;
  678. X        zs = -lp->dir.z - cosi * nz;
  679. X        coss = (xs * view_vec.x + ys * view_vec.y + zs * view_vec.z);
  680. X        if (coss > 0)
  681. X            specsum += lp->intensity * c3two * coss / 
  682. X                                   (coss * coss * (c3two -1) + 1);
  683. X    }
  684. X    color->red = (sd->color.red * (sd->ambient + diffsum) + sd->specular
  685. X                  * specsum); 
  686. X    if (color->red > 1.0) color->red = 1.0;
  687. X    color->grn = (sd->color.grn * (sd->ambient + diffsum) + sd->specular
  688. X                  * specsum); 
  689. X    if (color->grn > 1.0) color->grn = 1.0;
  690. X    color->blu = (sd->color.blu * (sd->ambient + diffsum) + sd->specular
  691. X                  * specsum);
  692. X    if (color->blu > 1.0) color->blu = 1.0;
  693. }
  694. X
  695. X
  696. X
  697. SHAR_EOF
  698. chmod 0644 libsipp/basic_shader.c ||
  699. echo 'restore of libsipp/basic_shader.c failed'
  700. Wc_c="`wc -c < 'libsipp/basic_shader.c'`"
  701. test 1710 -eq "$Wc_c" ||
  702.     echo 'libsipp/basic_shader.c: original size 1710, current size' "$Wc_c"
  703. fi
  704. # ============= libsipp/bezier.c ==============
  705. if test -f 'libsipp/bezier.c' -a X"$1" != X"-c"; then
  706.     echo 'x - skipping libsipp/bezier.c (File already exists)'
  707. else
  708. echo 'x - extracting libsipp/bezier.c (Text)'
  709. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bezier.c' &&
  710. #include <math.h>
  711. #include <stdio.h>
  712. X
  713. #include "sipp.h"
  714. #include "bezier.h"
  715. X
  716. X
  717. Tokenval     tokenval;
  718. extern FILE *yyin;
  719. X
  720. X
  721. /*================================================================*/
  722. /*                                                                */
  723. /*      Functions for reading bezier descriptions from file       */
  724. /*                                                                */
  725. /*================================================================*/
  726. X
  727. X
  728. /*
  729. X * Read a vertex list, where each vertex is an xyz triple, and 
  730. X * install it in the bezier structure.
  731. X */
  732. static void
  733. vertex_read(obj)
  734. X    Bez_Object *obj;
  735. {
  736. X    int token;
  737. X    int i, j;
  738. X
  739. X    token = yylex();
  740. X    if (token != NVERTICES) {
  741. X        fprintf(stderr, "Corrupt vertex description.\n");
  742. X        goto errout;
  743. X    }
  744. X    
  745. X    token = yylex();
  746. X    if (token != INTEGER) {
  747. X        fprintf(stderr, "Corrupt vertex description.\n");
  748. X        goto errout;
  749. X    }
  750. X    obj->nvertex = tokenval.intval;
  751. X    obj->vertex = (Bez_Vertex *)malloc(obj->nvertex * sizeof(Bez_Vertex));
  752. X    if (obj->vertex == NULL) {
  753. X        fprintf(stderr, "vertex_read: Out of core.\n");
  754. X        goto errout;
  755. X    }
  756. X
  757. X    token = yylex();
  758. X    if (token != VERTEX_LIST) {
  759. X        fprintf(stderr, "Corrupt vertex description.\n");
  760. X        goto errout;
  761. X    }
  762. X
  763. X    for (i = 0; i < obj->nvertex; i++) {
  764. X        for (j = 0; j < 3; j++) {
  765. X            token = yylex();
  766. X            if (token != FLOAT && token != INTEGER) {
  767. X                fprintf(stderr, "Corrupt vertex description.\n");
  768. X                goto errout;
  769. X            }
  770. X            if (token == FLOAT) {
  771. X                obj->vertex[i].coor[j] = tokenval.floatval;
  772. X            } else {
  773. X                obj->vertex[i].coor[j] = (double)tokenval.intval;
  774. X            }
  775. X        }
  776. X    }
  777. X
  778. X    return;
  779. X
  780. X  errout:
  781. X    if (obj->vertex != NULL) {
  782. X        free(obj->vertex);
  783. X        obj->vertex = NULL;
  784. X    }
  785. }
  786. X
  787. X    
  788. X
  789. /*
  790. X * Read a list of bezier curves, where each curve consists of 
  791. X * four control points (index into the vertex list), and install 
  792. X * it in the bezier structure.
  793. X */
  794. static void
  795. curve_read(obj)
  796. X    Bez_Object *obj;
  797. {
  798. X    int         token;
  799. X    int         i, j;
  800. X
  801. X    token = yylex();
  802. X    if (token != NCURVES) {
  803. X        fprintf(stderr, "Corrupt curve description.\n");
  804. X        goto errout;
  805. X    }
  806. X    
  807. X    token = yylex();
  808. X    if (token != INTEGER) {
  809. X        fprintf(stderr, "Corrupt curve description.\n");
  810. X        goto errout;
  811. X    }
  812. X    obj->n.ncurves = tokenval.intval;
  813. X    obj->cp.ccp = (Bez_Curve *)malloc(obj->n.ncurves * sizeof(Bez_Curve));
  814. X    if (obj->cp.ccp == NULL) {
  815. X        fprintf(stderr, "curve_read: Out of core.\n");
  816. X        goto errout;
  817. X    }
  818. X
  819. X    token = yylex();
  820. X    if (token != CURVE_LIST) {
  821. X        fprintf(stderr, "Corrupt curve description.\n");
  822. X        goto errout;
  823. X    }
  824. X
  825. X    for (i = 0; i < obj->n.ncurves; i++) {
  826. X        for (j = 0; j < 4; j++) {
  827. X            token = yylex();
  828. X            if (token != INTEGER) {
  829. X                fprintf(stderr, "Corrupt curve description.\n");
  830. X                goto errout;
  831. X            }
  832. X            obj->cp.ccp[i].cp[j] = tokenval.intval - 1;
  833. X        }
  834. X    }
  835. X
  836. X    return;
  837. X
  838. X  errout:
  839. X    if (obj->cp.ccp != NULL) {
  840. X        free(obj->cp.ccp);
  841. X        obj->cp.ccp = NULL;
  842. X    }
  843. }
  844. X
  845. X
  846. X    
  847. /*
  848. X * Read a list of bezier patches, where each patch consists of 
  849. X * sixteen control points (index into the vertex list), and install 
  850. X * it in the bezier structure.
  851. X */
  852. static void
  853. patch_read(obj)
  854. X    Bez_Object *obj;
  855. {
  856. X    int         token;
  857. X    int         i, j, k;
  858. X
  859. X    token = yylex();
  860. X    if (token != NPATCHES) {
  861. X        fprintf(stderr, "Corrupt patch description.\n");
  862. X        goto errout;
  863. X    }
  864. X    
  865. X    token = yylex();
  866. X    if (token != INTEGER) {
  867. X        fprintf(stderr, "Corrupt patch description.\n");
  868. X        goto errout;
  869. X    }
  870. X    obj->n.npatches = tokenval.intval;
  871. X    obj->cp.pcp = (Bez_Patch *)malloc(obj->n.npatches * sizeof(Bez_Patch));
  872. X    if (obj->cp.pcp == NULL) {
  873. X        fprintf(stderr, "patch_read: Out of core.\n");
  874. X        goto errout;
  875. X    }
  876. X
  877. X    token = yylex();
  878. X    if (token != PATCH_LIST) {
  879. X        fprintf(stderr, "Corrupt patch description.\n");
  880. X        goto errout;
  881. X    }
  882. X
  883. X    for (i = 0; i < obj->n.npatches; i++) {
  884. X        for (j = 0; j < 4; j++) {
  885. X            for (k = 0; k < 4; k++) {
  886. X                token = yylex();
  887. X                if (token != INTEGER) {
  888. X                    fprintf(stderr, "Corrupt patch description.\n");
  889. X                    goto errout;
  890. X                }
  891. X                obj->cp.pcp[i].cp[j][k] = tokenval.intval - 1;
  892. X            }
  893. X        }
  894. X    }
  895. X
  896. X    return;
  897. X
  898. X  errout:
  899. X    if (obj->cp.pcp != NULL) {
  900. X        free(obj->cp.pcp);
  901. X        obj->cp.pcp = NULL;
  902. X    }
  903. }
  904. X
  905. X
  906. X    
  907. /*
  908. X * Read a bezier object from a file, i.e. determine if it is a
  909. X * curve or patch description,  read vertex and curve or patch 
  910. X * description. Build a bezier object from the data.
  911. X */
  912. Bez_Object *
  913. bezier_read(file)
  914. X    FILE *file;
  915. {
  916. X    int token;
  917. X    Bez_Object *obj;
  918. X
  919. X
  920. X    yyin = file;
  921. X
  922. X    obj = (Bez_Object *)calloc(1, sizeof(Bez_Object));
  923. X    if (obj == NULL) {
  924. X        fprintf(stderr, "bezier_read: Out of core.\n");
  925. X        return obj;
  926. X    }
  927. X    if ((token = yylex()) == PATCHES) {
  928. X        obj->type = PATCHES;
  929. X        vertex_read(obj);
  930. X        if (obj->vertex == NULL) {
  931. X            goto errout;
  932. X        }
  933. X        patch_read(obj);
  934. X        if (obj->cp.pcp == NULL) {
  935. X            goto errout;
  936. X        }
  937. X    } else if (token == CURVES) {
  938. X        obj->type = CURVES;
  939. X        vertex_read(obj);
  940. X        if (obj->vertex == NULL) {
  941. X            goto errout;
  942. X        }
  943. X        curve_read(obj);
  944. X        if (obj->cp.ccp == NULL) {
  945. X            goto errout;
  946. X        }
  947. X    } else {
  948. X        fprintf(stderr, "Corrupt bezier description file: %s\n", file);
  949. X        return NULL;
  950. X    }
  951. X
  952. X    return obj;
  953. X
  954. X  errout:
  955. X    if (obj != NULL) {
  956. X        if (obj->vertex != NULL) {
  957. X            free(obj->vertex);
  958. X        }
  959. X        if (obj->cp.pcp != NULL) {
  960. X            free(obj->cp.pcp);
  961. X        }
  962. X        free(obj);
  963. X    }
  964. X    return NULL;
  965. }
  966. X
  967. X
  968. /*================================================================*/
  969. /*                                                                */
  970. /*           Functions for evaluating bezier functions            */
  971. /*                                                                */
  972. /*================================================================*/
  973. X
  974. static double
  975. C(i)
  976. X    int i;
  977. {
  978. X    int j, a;
  979. X
  980. X    a = 1;
  981. X    for (j = i + 1; j < 4; j++) {
  982. X        a = a * j;
  983. X    }
  984. X    for (j = 1 ; j < 4 - i; j++) {
  985. X        a = a / j;
  986. X    }
  987. X
  988. X    return (double)a;
  989. }
  990. X
  991. X
  992. static double 
  993. bblend(i, u)
  994. X    int    i;
  995. X    double u;
  996. {
  997. X    int j;
  998. X    double v;
  999. X
  1000. X    v = C(i);
  1001. X    for (j = 1; j <= i; j++) {
  1002. X        v *= u;
  1003. X    }
  1004. X    for (j = 1; j < 4 - i; j++) {
  1005. X        v *= 1.0 - u;
  1006. X    }
  1007. X
  1008. X    if (fabs(v) < 1.0E-15) {
  1009. X        return 0.0;
  1010. X    } else {
  1011. X        return v;
  1012. X    }
  1013. }
  1014. X
  1015. X
  1016. /*
  1017. X * Determine x, y and z coordinates of a point on the bezier
  1018. X * curve described by CURVE and VERTEX. U is a parameter between
  1019. X * 0 and 1 that determines how far "into" the curve we are.
  1020. X */
  1021. static void
  1022. bez_curve_eval(vertex, curve, u, x, y, z)
  1023. X    Bez_Vertex *vertex;
  1024. X    Bez_Curve  *curve;
  1025. X    double      u;
  1026. X    double     *x, *y, *z;
  1027. {
  1028. X    int    i;
  1029. X    double b;
  1030. X
  1031. X    *x = 0;
  1032. X    *y = 0;
  1033. X    *z = 0;
  1034. X    
  1035. X    for (i = 0; i < 4; i++) {
  1036. X        b = bblend(i, u);
  1037. X        *x += vertex[curve->cp[i]].coor[0] * b;
  1038. X        *y += vertex[curve->cp[i]].coor[1] * b;
  1039. X        *z += vertex[curve->cp[i]].coor[2] * b;
  1040. X    }
  1041. }
  1042. X
  1043. X
  1044. /*
  1045. X * Determine x, y and z coordinates of a point on the bezier
  1046. X * patch described by PATCH and VERTEX. U and V are parameters
  1047. X * between 0 and 1 that determines where on the patch we are.
  1048. X */
  1049. static void
  1050. bez_patch_eval(vertex, patch, v, u, x, y, z)
  1051. X    Bez_Vertex *vertex;
  1052. X    Bez_Patch  *patch;
  1053. X    double      u, v;
  1054. X    double     *x, *y, *z;
  1055. {
  1056. X    int i, j;
  1057. X    double b;
  1058. X
  1059. X    *x = 0;
  1060. X    *y = 0;
  1061. X    *z = 0;
  1062. X
  1063. X    for (i = 0; i < 4; i++) {
  1064. X        for (j = 0; j < 4; j++) {
  1065. X            b   = bblend(i, v);
  1066. X            b  *= bblend(j, u);
  1067. X            *x += vertex[patch->cp[i][j]].coor[0] * b;
  1068. X            *y += vertex[patch->cp[i][j]].coor[1] * b;
  1069. X            *z += vertex[patch->cp[i][j]].coor[2] * b;
  1070. X        }
  1071. X    }
  1072. }
  1073. X
  1074. X
  1075. X
  1076. /*================================================================*/
  1077. /*                                                                */
  1078. /*             Functions for creating bezier objects              */
  1079. /*             (these functions are SIPP specific)                */
  1080. /*                                                                */
  1081. /*================================================================*/
  1082. X
  1083. X
  1084. /*
  1085. X * Approximate the bezier patches described in OBJ with polygons
  1086. X * and create a SIPP surface out of them. The patches will be 
  1087. X * tesselated into RESxRES polygons (rectangles).
  1088. X */
  1089. Surface *
  1090. bezier_patches(obj, res, surface, shader)
  1091. X    Bez_Object *obj;
  1092. X    int         res;
  1093. X    void       *surface;
  1094. X    Shader     *shader;
  1095. {
  1096. X    double  x, y, z;
  1097. X    double  u, v;
  1098. X    double  step;
  1099. X    int     i, j, k;
  1100. X
  1101. X    step = 1.0 / (double)res;
  1102. X    
  1103. X    for (i = 0; i < obj->n.npatches; i++) {
  1104. X        for (v = 0.0, j = 0; j < res; j++, v += step) {
  1105. X            for (u = 0.0, k = 0; k < res; k++, u += step) {
  1106. X                bez_patch_eval(obj->vertex, &obj->cp.pcp[i], v, u, &x, &y, &z);
  1107. X                vertex_tx_push(x, y, z, x, y, z);
  1108. X                bez_patch_eval(obj->vertex, &obj->cp.pcp[i], v, u + step,
  1109. X                               &x, &y, &z); 
  1110. X                vertex_tx_push(x, y, z, x, y, z);
  1111. X                bez_patch_eval(obj->vertex, &obj->cp.pcp[i], 
  1112. X                               v + step, u + step, &x, &y, &z);
  1113. X                vertex_tx_push(x, y, z, x, y, z);
  1114. X                bez_patch_eval(obj->vertex, &obj->cp.pcp[i], v + step, u, 
  1115. X                               &x, &y, &z);
  1116. X                vertex_tx_push(x, y, z, x, y, z);
  1117. X                polygon_push();
  1118. X            }
  1119. X        }
  1120. X    }
  1121. X    return surface_create(surface, shader);
  1122. }
  1123. X
  1124. X
  1125. X
  1126. /*
  1127. X * Take the bezier curves described in OBJ and create a
  1128. X * surface by rotating them about th y-axis. The object
  1129. X * will be tesselated as RESx(RES*4) polygons per curve.
  1130. X * (The reason for using 4 times the resolution is rather
  1131. X * "handwavy". I think 90 degrees is about as much as a
  1132. X * patch should cover of a rotational body.)
  1133. X */
  1134. Surface *
  1135. bezier_rot_curves(obj, res, surface, shader)
  1136. X    Bez_Object *obj;
  1137. X    int         res;
  1138. X    void       *surface;
  1139. X    Shader     *shader;
  1140. {
  1141. X    double  x1, y1, z1;
  1142. X    double  x2, y2, z2;
  1143. X    double  xtmp;
  1144. X    double  u;
  1145. X    double  step;
  1146. X    double  ca, sa;
  1147. X    int     i, j, k;
  1148. X
  1149. X    step = 1.0 / (double)res;
  1150. X    ca = cos(2.0 * M_PI / (4.0 * (double)res));
  1151. X    sa = sin(2.0 * M_PI / (4.0 * (double)res));
  1152. X
  1153. X    for (i = 0; i < obj->n.ncurves; i++) {
  1154. X        for (u = 0.0, j = 0; j < res; j++, u += step) {
  1155. X            bez_curve_eval(obj->vertex, &obj->cp.ccp[i], u, 
  1156. X                           &x1, &y1, &z1);
  1157. X            bez_curve_eval(obj->vertex, &obj->cp.ccp[i], u + step, 
  1158. X                           &x2, &y2, &z2);
  1159. X            vertex_tx_push(x1, y1, z1, x1, y1, z1);
  1160. X            vertex_tx_push(x2, y2, z2, x2, y2, z2);
  1161. X            for (k = 0; k < 4 * res; k++) {
  1162. X                xtmp = ca * x1 + sa * z1;
  1163. X                z1   = ca * z1 - sa * x1;
  1164. X                x1   = xtmp;
  1165. X                xtmp = ca * x2 + sa * z2;
  1166. X                z2   = ca * z2 - sa * x2;
  1167. X                x2   = xtmp;
  1168. X                vertex_tx_push(x2, y2, z2, x2, y2, z2);
  1169. X                vertex_tx_push(x1, y1, z1, x1, y1, z1);
  1170. X                polygon_push();
  1171. X
  1172. X                if (k == 4 * res - 1) {
  1173. X                    break;
  1174. X                }
  1175. X
  1176. X                vertex_tx_push(x1, y1, z1, x1, y1, z1);
  1177. X                vertex_tx_push(x2, y2, z2, x2, y2, z2);
  1178. X            }
  1179. X        }
  1180. X    }
  1181. X    
  1182. X    return surface_create(surface, shader);
  1183. }
  1184. X
  1185. X
  1186. X
  1187. /*
  1188. X * Read a bezier description from FILE and build
  1189. X * a bezier surface. Tesselate this object into
  1190. X * polygons and return a pointer to a SIPP object.
  1191. X */
  1192. Object *
  1193. sipp_bezier(file, res, surface, shader)
  1194. X    FILE    *file;
  1195. X    int      res;
  1196. X    void    *surface;
  1197. X    Shader  *shader;
  1198. {
  1199. X    Object     *obj;
  1200. X    Bez_Object *bez_obj;
  1201. X
  1202. X    bez_obj = bezier_read(file);
  1203. X    if (bez_obj == NULL) {
  1204. X        return NULL;
  1205. X    }
  1206. X
  1207. X    obj = object_create();
  1208. X    if (bez_obj->type == PATCHES) {
  1209. X        object_add_surface(obj, bezier_patches(bez_obj, res, surface, shader));
  1210. X    } else {
  1211. X        object_add_surface(obj, bezier_rot_curves(bez_obj, res, surface,
  1212. X                                                  shader)); 
  1213. X    }
  1214. X
  1215. X    return obj;
  1216. }
  1217. SHAR_EOF
  1218. chmod 0644 libsipp/bezier.c ||
  1219. echo 'restore of libsipp/bezier.c failed'
  1220. Wc_c="`wc -c < 'libsipp/bezier.c'`"
  1221. test 12593 -eq "$Wc_c" ||
  1222.     echo 'libsipp/bezier.c: original size 12593, current size' "$Wc_c"
  1223. fi
  1224. # ============= libsipp/bezier.h ==============
  1225. if test -f 'libsipp/bezier.h' -a X"$1" != X"-c"; then
  1226.     echo 'x - skipping libsipp/bezier.h (File already exists)'
  1227. else
  1228. echo 'x - extracting libsipp/bezier.h (Text)'
  1229. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bezier.h' &&
  1230. #define PATCHES     1
  1231. #define CURVES      2
  1232. #define NVERTICES   3
  1233. #define NPATCHES    4
  1234. #define NCURVES     5
  1235. #define VERTEX_LIST 6
  1236. #define PATCH_LIST  7
  1237. #define CURVE_LIST  8
  1238. #define INTEGER     9
  1239. #define FLOAT       10
  1240. X
  1241. X
  1242. typedef union {
  1243. X    int    intval;
  1244. X    double floatval;
  1245. } Tokenval;
  1246. X
  1247. X
  1248. typedef struct {
  1249. X    double coor[3];
  1250. } Bez_Vertex;
  1251. X
  1252. typedef struct {
  1253. X    int cp[4];
  1254. } Bez_Curve;
  1255. X
  1256. typedef struct {
  1257. X    int cp[4][4];
  1258. } Bez_Patch;
  1259. X
  1260. typedef struct {
  1261. X    int         type;
  1262. X    int         nvertex;
  1263. X    Bez_Vertex *vertex;
  1264. X    union {
  1265. X        int ncurves;
  1266. X        int npatches;
  1267. X    } n;
  1268. X    union {
  1269. X        Bez_Curve *ccp;
  1270. X        Bez_Patch *pcp;
  1271. X    } cp;
  1272. } Bez_Object;
  1273. SHAR_EOF
  1274. chmod 0644 libsipp/bezier.h ||
  1275. echo 'restore of libsipp/bezier.h failed'
  1276. Wc_c="`wc -c < 'libsipp/bezier.h'`"
  1277. test 676 -eq "$Wc_c" ||
  1278.     echo 'libsipp/bezier.h: original size 676, current size' "$Wc_c"
  1279. fi
  1280. # ============= libsipp/bezier_lex.c ==============
  1281. if test -f 'libsipp/bezier_lex.c' -a X"$1" != X"-c"; then
  1282.     echo 'x - skipping libsipp/bezier_lex.c (File already exists)'
  1283. else
  1284. echo 'x - extracting libsipp/bezier_lex.c (Text)'
  1285. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bezier_lex.c' &&
  1286. # include "stdio.h"
  1287. # define U(x) x
  1288. # define NLSTATE yyprevious=YYNEWLINE
  1289. # define BEGIN yybgin = yysvec + 1 +
  1290. # define INITIAL 0
  1291. # define YYLERR yysvec
  1292. # define YYSTATE (yyestate-yysvec-1)
  1293. # define YYOPTIM 1
  1294. # define YYLMAX BUFSIZ
  1295. # define output(c) putc(c,yyout)
  1296. # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
  1297. # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
  1298. # define yymore() (yymorfg=1)
  1299. # define ECHO fprintf(yyout, "%s",yytext)
  1300. # define REJECT { nstr = yyreject(); goto yyfussy;}
  1301. int yyleng; extern char yytext[];
  1302. int yymorfg;
  1303. extern char *yysptr, yysbuf[];
  1304. int yytchar;
  1305. FILE *yyin = {stdin}, *yyout = {stdout};
  1306. extern int yylineno;
  1307. struct yysvf { 
  1308. X    struct yywork *yystoff;
  1309. X    struct yysvf *yyother;
  1310. X    int *yystops;};
  1311. struct yysvf *yyestate;
  1312. extern struct yysvf yysvec[], *yybgin;
  1313. #include "bezier.h"
  1314. X
  1315. extern int     atoi();
  1316. extern double  atof();
  1317. X
  1318. extern Tokenval  tokenval;
  1319. extern FILE     *bezier_file;
  1320. # define YYNEWLINE 10
  1321. yylex(){
  1322. int nstr; extern int yyprevious;
  1323. while((nstr = yylook()) >= 0)
  1324. yyfussy: switch(nstr){
  1325. case 0:
  1326. if(yywrap()) return(0); break;
  1327. case 1:
  1328. X      {return PATCHES;}
  1329. break;
  1330. case 2:
  1331. X       {return CURVES;}
  1332. break;
  1333. case 3:
  1334. X            {return NVERTICES;}
  1335. break;
  1336. case 4:
  1337. X             {return NPATCHES;}
  1338. break;
  1339. case 5:
  1340. X              {return NCURVES;}
  1341. break;
  1342. case 6:
  1343. X         {return VERTEX_LIST;}
  1344. break;
  1345. case 7:
  1346. X          {return PATCH_LIST;}
  1347. break;
  1348. case 8:
  1349. X          {return CURVE_LIST;}
  1350. break;
  1351. case 9:
  1352. X               {tokenval.intval = atoi(yytext);
  1353. X                         return INTEGER;
  1354. X                        }
  1355. break;
  1356. case 10:
  1357. X {tokenval.floatval = atof(yytext);
  1358. X                                      return FLOAT;
  1359. X                                     }
  1360. break;
  1361. case 11:
  1362. X                {}
  1363. break;
  1364. case 12:
  1365. X                   { /* This is a comment */ }
  1366. break;
  1367. case 13:
  1368. X                      { return yytext[0]; /* We found something wrong */ }
  1369. break;
  1370. case -1:
  1371. break;
  1372. default:
  1373. fprintf(yyout,"bad switch yylook %d",nstr);
  1374. } return(0); }
  1375. /* end of yylex */
  1376. X
  1377. int
  1378. yywrap()
  1379. {
  1380. X    return 1;
  1381. }
  1382. int yyvstop[] = {
  1383. 0,
  1384. X
  1385. 13,
  1386. 0,
  1387. X
  1388. 11,
  1389. 13,
  1390. 0,
  1391. X
  1392. 11,
  1393. 0,
  1394. X
  1395. 13,
  1396. -12,
  1397. 0,
  1398. X
  1399. 13,
  1400. 0,
  1401. X
  1402. 9,
  1403. 13,
  1404. 0,
  1405. X
  1406. 13,
  1407. 0,
  1408. X
  1409. 13,
  1410. 0,
  1411. X
  1412. 13,
  1413. 0,
  1414. X
  1415. 13,
  1416. 0,
  1417. X
  1418. -12,
  1419. 0,
  1420. X
  1421. 12,
  1422. 0,
  1423. X
  1424. 9,
  1425. 0,
  1426. X
  1427. 10,
  1428. 0,
  1429. X
  1430. 10,
  1431. 0,
  1432. X
  1433. 5,
  1434. 0,
  1435. X
  1436. 4,
  1437. 0,
  1438. X
  1439. 3,
  1440. 0,
  1441. X
  1442. 8,
  1443. 0,
  1444. X
  1445. 7,
  1446. 0,
  1447. X
  1448. 6,
  1449. 0,
  1450. X
  1451. 2,
  1452. 0,
  1453. X
  1454. 1,
  1455. 0,
  1456. 0};
  1457. # define YYTYPE char
  1458. struct yywork { YYTYPE verify, advance; } yycrank[] = {
  1459. 0,0,    0,0,    1,3,    0,0,    
  1460. 0,0,    6,13,    0,0,    0,0,    
  1461. 0,0,    0,0,    1,4,    1,5,    
  1462. 0,0,    6,13,    6,14,    0,0,    
  1463. 0,0,    0,0,    0,0,    0,0,    
  1464. 0,0,    0,0,    0,0,    0,0,    
  1465. 0,0,    0,0,    0,0,    0,0,    
  1466. 0,0,    0,0,    0,0,    0,0,    
  1467. 0,0,    0,0,    0,0,    0,0,    
  1468. 1,6,    0,0,    2,6,    0,0,    
  1469. 0,0,    0,0,    0,0,    0,0,    
  1470. 1,3,    0,0,    1,7,    6,13,    
  1471. 2,7,    1,8,    8,16,    15,16,    
  1472. 6,13,    7,15,    7,15,    7,15,    
  1473. 7,15,    7,15,    7,15,    7,15,    
  1474. 7,15,    7,15,    7,15,    0,0,    
  1475. 0,0,    0,0,    0,0,    0,0,    
  1476. 0,0,    0,0,    1,3,    0,0,    
  1477. 0,0,    6,13,    16,16,    16,16,    
  1478. 16,16,    16,16,    16,16,    16,16,    
  1479. 16,16,    16,16,    16,16,    16,16,    
  1480. 26,27,    26,27,    26,27,    26,27,    
  1481. 26,27,    26,27,    26,27,    26,27,    
  1482. 26,27,    26,27,    39,46,    16,21,    
  1483. 48,55,    57,63,    11,19,    1,9,    
  1484. 1,10,    2,9,    2,10,    9,17,    
  1485. 12,20,    24,30,    22,28,    28,32,    
  1486. 29,33,    30,34,    31,35,    37,44,    
  1487. 66,71,    1,11,    31,36,    2,11,    
  1488. 18,23,    19,24,    10,18,    1,12,    
  1489. 20,25,    2,12,    23,29,    17,22,    
  1490. 21,26,    25,31,    21,26,    16,21,    
  1491. 32,37,    21,27,    21,27,    21,27,    
  1492. 21,27,    21,27,    21,27,    21,27,    
  1493. 21,27,    21,27,    21,27,    33,38,    
  1494. 34,40,    35,42,    36,43,    38,45,    
  1495. 40,47,    41,48,    34,41,    42,49,    
  1496. 43,50,    44,51,    45,53,    47,54,    
  1497. 49,56,    50,57,    51,58,    52,59,    
  1498. 53,60,    54,61,    56,62,    33,39,    
  1499. 58,64,    59,65,    44,52,    60,66,    
  1500. 61,67,    62,68,    64,69,    65,70,    
  1501. 67,72,    68,73,    69,74,    70,75,    
  1502. 73,76,    74,77,    75,78,    77,79,    
  1503. 78,80,    80,81,    0,0,    0,0,    
  1504. 0,0};
  1505. struct yysvf yysvec[] = {
  1506. 0,    0,    0,
  1507. yycrank+-1,    0,        0,    
  1508. yycrank+-3,    yysvec+1,    0,    
  1509. yycrank+0,    0,        yyvstop+1,
  1510. yycrank+0,    0,        yyvstop+3,
  1511. yycrank+0,    0,        yyvstop+6,
  1512. yycrank+-4,    0,        yyvstop+8,
  1513. yycrank+5,    0,        yyvstop+11,
  1514. yycrank+4,    yysvec+7,    yyvstop+13,
  1515. yycrank+2,    0,        yyvstop+16,
  1516. yycrank+1,    0,        yyvstop+18,
  1517. yycrank+1,    0,        yyvstop+20,
  1518. yycrank+3,    0,        yyvstop+22,
  1519. yycrank+0,    yysvec+6,    yyvstop+24,
  1520. yycrank+0,    0,        yyvstop+26,
  1521. yycrank+5,    yysvec+7,    yyvstop+28,
  1522. yycrank+26,    0,        yyvstop+30,
  1523. yycrank+1,    0,        0,    
  1524. yycrank+2,    0,        0,    
  1525. yycrank+1,    0,        0,    
  1526. yycrank+6,    0,        0,    
  1527. yycrank+81,    0,        0,    
  1528. yycrank+1,    0,        0,    
  1529. yycrank+4,    0,        0,    
  1530. yycrank+6,    0,        0,    
  1531. yycrank+9,    0,        0,    
  1532. yycrank+36,    0,        0,    
  1533. yycrank+0,    yysvec+26,    yyvstop+32,
  1534. yycrank+6,    0,        0,    
  1535. yycrank+7,    0,        0,    
  1536. yycrank+5,    0,        0,    
  1537. yycrank+9,    0,        0,    
  1538. yycrank+14,    0,        0,    
  1539. yycrank+44,    0,        0,    
  1540. yycrank+45,    0,        0,    
  1541. yycrank+21,    0,        0,    
  1542. yycrank+43,    0,        0,    
  1543. yycrank+16,    0,        0,    
  1544. yycrank+35,    0,        0,    
  1545. yycrank+36,    0,        0,    
  1546. yycrank+36,    0,        0,    
  1547. yycrank+30,    0,        0,    
  1548. yycrank+52,    0,        0,    
  1549. yycrank+47,    0,        0,    
  1550. yycrank+50,    0,        0,    
  1551. yycrank+45,    0,        0,    
  1552. yycrank+0,    0,        yyvstop+34,
  1553. yycrank+46,    0,        0,    
  1554. yycrank+38,    0,        0,    
  1555. yycrank+44,    0,        0,    
  1556. yycrank+38,    0,        0,    
  1557. yycrank+37,    0,        0,    
  1558. yycrank+58,    0,        0,    
  1559. yycrank+41,    0,        0,    
  1560. yycrank+42,    0,        0,    
  1561. yycrank+0,    0,        yyvstop+36,
  1562. yycrank+53,    0,        0,    
  1563. yycrank+39,    0,        0,    
  1564. yycrank+46,    0,        0,    
  1565. yycrank+45,    0,        0,    
  1566. yycrank+47,    0,        0,    
  1567. yycrank+48,    0,        0,    
  1568. yycrank+50,    0,        0,    
  1569. yycrank+0,    0,        yyvstop+38,
  1570. yycrank+48,    0,        0,    
  1571. yycrank+68,    0,        0,    
  1572. yycrank+54,    0,        0,    
  1573. yycrank+110,    0,        0,    
  1574. yycrank+53,    0,        0,    
  1575. yycrank+69,    0,        0,    
  1576. yycrank+67,    0,        0,    
  1577. yycrank+0,    0,        yyvstop+40,
  1578. yycrank+0,    0,        yyvstop+42,
  1579. yycrank+114,    0,        0,    
  1580. yycrank+58,    0,        0,    
  1581. yycrank+73,    0,        0,    
  1582. yycrank+0,    0,        yyvstop+44,
  1583. yycrank+117,    0,        0,    
  1584. yycrank+61,    0,        0,    
  1585. yycrank+0,    0,        yyvstop+46,
  1586. yycrank+119,    0,        0,    
  1587. yycrank+0,    0,        yyvstop+48,
  1588. 0,    0,    0};
  1589. struct yywork *yytop = yycrank+177;
  1590. struct yysvf *yybgin = yysvec+1;
  1591. char yymatch[] = {
  1592. 00  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1593. 01  ,011 ,012 ,01  ,01  ,01  ,01  ,01  ,
  1594. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1595. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1596. 011 ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1597. 01  ,01  ,01  ,'+' ,01  ,'+' ,01  ,01  ,
  1598. '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
  1599. '0' ,'0' ,01  ,01  ,01  ,01  ,01  ,01  ,
  1600. 01  ,01  ,01  ,01  ,01  ,'E' ,01  ,01  ,
  1601. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1602. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1603. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1604. 01  ,01  ,01  ,01  ,01  ,'E' ,01  ,01  ,
  1605. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1606. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1607. 01  ,01  ,01  ,01  ,01  ,01  ,01  ,01  ,
  1608. 0};
  1609. char yyextra[] = {
  1610. 0,0,0,0,0,0,0,0,
  1611. 0,0,0,0,1,0,0,0,
  1612. 0};
  1613. #ifndef lint
  1614. static    char ncform_sccsid[] = "@(#)ncform 1.6 88/02/08 SMI"; /* from S5R2 1.2 */
  1615. #endif
  1616. X
  1617. int yylineno =1;
  1618. # define YYU(x) x
  1619. # define NLSTATE yyprevious=YYNEWLINE
  1620. char yytext[YYLMAX];
  1621. struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
  1622. char yysbuf[YYLMAX];
  1623. char *yysptr = yysbuf;
  1624. int *yyfnd;
  1625. extern struct yysvf *yyestate;
  1626. int yyprevious = YYNEWLINE;
  1627. yylook(){
  1628. X    register struct yysvf *yystate, **lsp;
  1629. X    register struct yywork *yyt;
  1630. X    struct yysvf *yyz;
  1631. X    int yych, yyfirst;
  1632. X    struct yywork *yyr;
  1633. # ifdef LEXDEBUG
  1634. X    int debug;
  1635. # endif
  1636. X    char *yylastch;
  1637. X    /* start off machines */
  1638. # ifdef LEXDEBUG
  1639. X    debug = 0;
  1640. # endif
  1641. X    yyfirst=1;
  1642. X    if (!yymorfg)
  1643. X        yylastch = yytext;
  1644. X    else {
  1645. X        yymorfg=0;
  1646. X        yylastch = yytext+yyleng;
  1647. X        }
  1648. X    for(;;){
  1649. X        lsp = yylstate;
  1650. X        yyestate = yystate = yybgin;
  1651. X        if (yyprevious==YYNEWLINE) yystate++;
  1652. X        for (;;){
  1653. # ifdef LEXDEBUG
  1654. X            if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
  1655. # endif
  1656. X            yyt = yystate->yystoff;
  1657. X            if(yyt == yycrank && !yyfirst){  /* may not be any transitions */
  1658. X                yyz = yystate->yyother;
  1659. X                if(yyz == 0)break;
  1660. X                if(yyz->yystoff == yycrank)break;
  1661. X                }
  1662. X            *yylastch++ = yych = input();
  1663. X            yyfirst=0;
  1664. X        tryagain:
  1665. # ifdef LEXDEBUG
  1666. X            if(debug){
  1667. X                fprintf(yyout,"char ");
  1668. X                allprint(yych);
  1669. X                putchar('\n');
  1670. X                }
  1671. # endif
  1672. X            yyr = yyt;
  1673. X            if ( (int)yyt > (int)yycrank){
  1674. X                yyt = yyr + yych;
  1675. X                if (yyt <= yytop && yyt->verify+yysvec == yystate){
  1676. X                    if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  1677. X                        {unput(*--yylastch);break;}
  1678. X                    *lsp++ = yystate = yyt->advance+yysvec;
  1679. X                    goto contin;
  1680. X                    }
  1681. X                }
  1682. # ifdef YYOPTIM
  1683. X            else if((int)yyt < (int)yycrank) {        /* r < yycrank */
  1684. X                yyt = yyr = yycrank+(yycrank-yyt);
  1685. # ifdef LEXDEBUG
  1686. X                if(debug)fprintf(yyout,"compressed state\n");
  1687. # endif
  1688. X                yyt = yyt + yych;
  1689. X                if(yyt <= yytop && yyt->verify+yysvec == yystate){
  1690. X                    if(yyt->advance+yysvec == YYLERR)    /* error transitions */
  1691. X                        {unput(*--yylastch);break;}
  1692. X                    *lsp++ = yystate = yyt->advance+yysvec;
  1693. X                    goto contin;
  1694. X                    }
  1695. X                yyt = yyr + YYU(yymatch[yych]);
  1696. # ifdef LEXDEBUG
  1697. X                if(debug){
  1698. X                    fprintf(yyout,"try fall back character ");
  1699. X                    allprint(YYU(yymatch[yych]));
  1700. X                    putchar('\n');
  1701. X                    }
  1702. # endif
  1703. X                if(yyt <= yytop && yyt->verify+yysvec == yystate){
  1704. X                    if(yyt->advance+yysvec == YYLERR)    /* error transition */
  1705. X                        {unput(*--yylastch);break;}
  1706. X                    *lsp++ = yystate = yyt->advance+yysvec;
  1707. X                    goto contin;
  1708. X                    }
  1709. X                }
  1710. X            if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
  1711. # ifdef LEXDEBUG
  1712. X                if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
  1713. # endif
  1714. X                goto tryagain;
  1715. X                }
  1716. # endif
  1717. X            else
  1718. X                {unput(*--yylastch);break;}
  1719. X        contin:
  1720. # ifdef LEXDEBUG
  1721. X            if(debug){
  1722. X                fprintf(yyout,"state %d char ",yystate-yysvec-1);
  1723. X                allprint(yych);
  1724. X                putchar('\n');
  1725. X                }
  1726. # endif
  1727. X            ;
  1728. X            }
  1729. # ifdef LEXDEBUG
  1730. X        if(debug){
  1731. X            fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
  1732. X            allprint(yych);
  1733. X            putchar('\n');
  1734. X            }
  1735. # endif
  1736. X        while (lsp-- > yylstate){
  1737. X            *yylastch-- = 0;
  1738. X            if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
  1739. X                yyolsp = lsp;
  1740. X                if(yyextra[*yyfnd]){        /* must backup */
  1741. X                    while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
  1742. X                        lsp--;
  1743. X                        unput(*yylastch--);
  1744. X                        }
  1745. X                    }
  1746. X                yyprevious = YYU(*yylastch);
  1747. X                yylsp = lsp;
  1748. X                yyleng = yylastch-yytext+1;
  1749. X                yytext[yyleng] = 0;
  1750. # ifdef LEXDEBUG
  1751. X                if(debug){
  1752. X                    fprintf(yyout,"\nmatch ");
  1753. X                    sprint(yytext);
  1754. X                    fprintf(yyout," action %d\n",*yyfnd);
  1755. X                    }
  1756. # endif
  1757. X                return(*yyfnd++);
  1758. X                }
  1759. X            unput(*yylastch);
  1760. X            }
  1761. X        if (yytext[0] == 0  /* && feof(yyin) */)
  1762. X            {
  1763. X            yysptr=yysbuf;
  1764. X            return(0);
  1765. X            }
  1766. X        yyprevious = yytext[0] = input();
  1767. X        if (yyprevious>0)
  1768. X            output(yyprevious);
  1769. X        yylastch=yytext;
  1770. # ifdef LEXDEBUG
  1771. X        if(debug)putchar('\n');
  1772. # endif
  1773. X        }
  1774. X    }
  1775. yyback(p, m)
  1776. X    int *p;
  1777. {
  1778. if (p==0) return(0);
  1779. while (*p)
  1780. X    {
  1781. X    if (*p++ == m)
  1782. X        return(1);
  1783. X    }
  1784. return(0);
  1785. }
  1786. X    /* the following are only used in the lex library */
  1787. yyinput(){
  1788. X    return(input());
  1789. X    }
  1790. yyoutput(c)
  1791. X  int c; {
  1792. X    output(c);
  1793. X    }
  1794. yyunput(c)
  1795. X   int c; {
  1796. X    unput(c);
  1797. X    }
  1798. SHAR_EOF
  1799. chmod 0644 libsipp/bezier_lex.c ||
  1800. echo 'restore of libsipp/bezier_lex.c failed'
  1801. Wc_c="`wc -c < 'libsipp/bezier_lex.c'`"
  1802. test 10294 -eq "$Wc_c" ||
  1803.     echo 'libsipp/bezier_lex.c: original size 10294, current size' "$Wc_c"
  1804. fi
  1805. # ============= libsipp/bezier_lex.l ==============
  1806. if test -f 'libsipp/bezier_lex.l' -a X"$1" != X"-c"; then
  1807.     echo 'x - skipping libsipp/bezier_lex.l (File already exists)'
  1808. else
  1809. echo 'x - extracting libsipp/bezier_lex.l (Text)'
  1810. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bezier_lex.l' &&
  1811. %{
  1812. #include "bezier.h"
  1813. X
  1814. extern int     atoi();
  1815. extern double  atof();
  1816. X
  1817. extern Tokenval  tokenval;
  1818. extern FILE     *bezier_file;
  1819. %}
  1820. %%
  1821. X
  1822. "bezier_patches:"       {return PATCHES;}
  1823. "bezier_curves:"        {return CURVES;}
  1824. "vertices:"             {return NVERTICES;}
  1825. "patches:"              {return NPATCHES;}
  1826. "curves:"               {return NCURVES;}
  1827. "vertex_list:"          {return VERTEX_LIST;}
  1828. "patch_list:"           {return PATCH_LIST;}
  1829. "curve_list:"           {return CURVE_LIST;}
  1830. X
  1831. -?[0-9]+                {tokenval.intval = atoi(yytext);
  1832. X                         return INTEGER;
  1833. X                        }
  1834. -?[0-9]+"."[0-9]*([eE][-+]?[0-9]+)?  {tokenval.floatval = atof(yytext);
  1835. X                                      return FLOAT;
  1836. X                                     }
  1837. X
  1838. [ \n\t]                 {}
  1839. #.*$                    { /* This is a comment */ }
  1840. .                       { return yytext[0]; /* We found something wrong */ }
  1841. X
  1842. %%
  1843. X
  1844. int
  1845. yywrap()
  1846. {
  1847. X    return 1;
  1848. }
  1849. SHAR_EOF
  1850. chmod 0644 libsipp/bezier_lex.l ||
  1851. echo 'restore of libsipp/bezier_lex.l failed'
  1852. Wc_c="`wc -c < 'libsipp/bezier_lex.l'`"
  1853. test 964 -eq "$Wc_c" ||
  1854.     echo 'libsipp/bezier_lex.l: original size 964, current size' "$Wc_c"
  1855. fi
  1856. # ============= libsipp/block.c ==============
  1857. if test -f 'libsipp/block.c' -a X"$1" != X"-c"; then
  1858.     echo 'x - skipping libsipp/block.c (File already exists)'
  1859. else
  1860. echo 'x - extracting libsipp/block.c (Text)'
  1861. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/block.c' &&
  1862. #include <sipp.h>
  1863. X
  1864. X
  1865. struct {
  1866. X    int vertex[4];
  1867. } sides[] = {
  1868. X    {0, 3, 2, 1}, 
  1869. X    {0, 1, 5, 4}, 
  1870. X    {1, 2, 6, 5}, 
  1871. X    {2, 3, 7, 6}, 
  1872. X    {3, 0, 4, 7}, 
  1873. X    {4, 5, 6, 7}
  1874. };
  1875. X
  1876. X
  1877. Object *
  1878. sipp_block(xsize, ysize, zsize, surface, shader)
  1879. X    double  xsize;
  1880. X    double  ysize;
  1881. X    double  zsize;
  1882. X    void   *surface;
  1883. X    Shader *shader;
  1884. {
  1885. X    Object  *block;
  1886. X    Vector  vertices[8];
  1887. X    int     i, j;
  1888. X    
  1889. X    vertices[0].x = -xsize / 2.0;
  1890. X    vertices[0].y = -ysize / 2.0;
  1891. X    vertices[0].z = -zsize / 2.0;
  1892. X    vertices[1].x = xsize / 2.0;
  1893. X    vertices[1].y = -ysize / 2.0;
  1894. X    vertices[1].z = -zsize / 2.0;
  1895. X    vertices[2].x = xsize / 2.0;
  1896. X    vertices[2].y = ysize / 2.0;
  1897. X    vertices[2].z = -zsize / 2.0;
  1898. X    vertices[3].x = -xsize / 2.0;
  1899. X    vertices[3].y = ysize / 2.0;
  1900. X    vertices[3].z = -zsize / 2.0;
  1901. X    vertices[4].x = -xsize / 2.0;
  1902. X    vertices[4].y = -ysize / 2.0;
  1903. X    vertices[4].z = zsize / 2.0;
  1904. X    vertices[5].x = xsize / 2.0;
  1905. X    vertices[5].y = -ysize / 2.0;
  1906. X    vertices[5].z = zsize / 2.0;
  1907. X    vertices[6].x = xsize / 2.0;
  1908. X    vertices[6].y = ysize / 2.0;
  1909. X    vertices[6].z = zsize / 2.0;
  1910. X    vertices[7].x = -xsize / 2.0;
  1911. X    vertices[7].y = ysize / 2.0;
  1912. X    vertices[7].z = zsize / 2.0;
  1913. X
  1914. X    block = object_create();
  1915. X
  1916. X    for (i = 0; i < 6; i++) {
  1917. X        for (j = 0; j < 4; j++) {
  1918. X            vertex_tx_push(vertices[sides[i].vertex[j]].x, 
  1919. X                           vertices[sides[i].vertex[j]].y, 
  1920. X                           vertices[sides[i].vertex[j]].z, 
  1921. X                           vertices[sides[i].vertex[j]].x, 
  1922. X                           vertices[sides[i].vertex[j]].y, 
  1923. X                           vertices[sides[i].vertex[j]].z);
  1924. X        }
  1925. X        polygon_push();
  1926. X        object_add_surface(block, surface_create(surface, shader));
  1927. X    }
  1928. X
  1929. X    return block;    
  1930. }
  1931. X
  1932. X
  1933. Object *
  1934. sipp_cube(size, surface, shader)
  1935. X    double   size;
  1936. X    void     *surface;
  1937. X    Shader   *shader;
  1938. {
  1939. X    return sipp_block(size, size, size, surface, shader);
  1940. }
  1941. X
  1942. SHAR_EOF
  1943. chmod 0644 libsipp/block.c ||
  1944. echo 'restore of libsipp/block.c failed'
  1945. Wc_c="`wc -c < 'libsipp/block.c'`"
  1946. test 1968 -eq "$Wc_c" ||
  1947.     echo 'libsipp/block.c: original size 1968, current size' "$Wc_c"
  1948. fi
  1949. # ============= libsipp/bozo.c ==============
  1950. if test -f 'libsipp/bozo.c' -a X"$1" != X"-c"; then
  1951.     echo 'x - skipping libsipp/bozo.c (File already exists)'
  1952. else
  1953. echo 'x - extracting libsipp/bozo.c (Text)'
  1954. sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bozo.c' &&
  1955. /*
  1956. X * marble shader - simulates marble using noise & turbulence
  1957. X */
  1958. X
  1959. #include <math.h>
  1960. #include <stdio.h>
  1961. X
  1962. #include <sipp.h>
  1963. #include <noise.h>
  1964. #include <shaders.h>
  1965. X
  1966. X
  1967. extern bool noise_ready;
  1968. X
  1969. void
  1970. bozo_shader(nx, ny, nz, u, v, w, view_vec, lights, bd, color)
  1971. X    double  nx, ny, nz, u, v, w;
  1972. X    Vector  view_vec;
  1973. X    Lightsource *lights;
  1974. X    Bozo_desc *bd;
  1975. X    Color *color;
  1976. {
  1977. X    Vector     tmp;
  1978. X    Surf_desc  surface;
  1979. X    double     noiseval;
  1980. X    int        i;
  1981. X
  1982. X    if (!noise_ready) {
  1983. X        noise_init();
  1984. X    }
  1985. X
  1986. X    tmp.x = u * bd->scale;
  1987. X    tmp.y = v * bd->scale;
  1988. X    tmp.z = w * bd->scale;
  1989. X    noiseval = noise(&tmp);
  1990. X
  1991. X    i = (noiseval + 1) * bd->no_of_cols / 2.0;
  1992. X    surface.color    = bd->colors[i];
  1993. X    surface.ambient  = bd->ambient;
  1994. X    surface.specular = bd->specular;
  1995. X    surface.c3       = bd->c3;
  1996. X    basic_shader(nx, ny, nz, u, v, w, view_vec, lights, &surface, color);
  1997. }
  1998. SHAR_EOF
  1999. chmod 0644 libsipp/bozo.c ||
  2000. echo 'restore of libsipp/bozo.c failed'
  2001. Wc_c="`wc -c < 'libsipp/bozo.c'`"
  2002. test 895 -eq "$Wc_c" ||
  2003.     echo 'libsipp/bozo.c: original size 895, current size' "$Wc_c"
  2004. fi
  2005. true || echo 'restore of libsipp/bumpy.c failed'
  2006. echo End of part 1, continue with part 2
  2007. exit 0
  2008.  
  2009. -- 
  2010. Inge Wallin               | Thus spake the master programmer:               |
  2011.                           |      "After three days without programming,     |
  2012. ingwa@isy.liu.se          |       life becomes meaningless."                |
  2013.                           | Geoffrey James: The Tao of Programming.         |
  2014.  
  2015.  
  2016. exit 0 # Just in case...
  2017. -- 
  2018. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  2019. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  2020. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  2021. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  2022.