home *** CD-ROM | disk | FTP | other *** search
- From: kent@sparky.IMD.Sterling.COM (Kent Landfield)
- Newsgroups: comp.sources.misc
- Subject: v16i005: sipp 2.0 - a library for 3D graphics, Part01/06
- Message-ID: <1991Jan3.065459.4991@sparky.IMD.Sterling.COM>
- Date: 3 Jan 91 06:54:59 GMT
- Approved: kent@sparky.imd.sterling.com
- X-Checksum-Snefru: c73dc831 0ea7b816 cf160ca9 668afaed
-
- Submitted-by: ingwa@isy.liu.se (Inge Wallin)
- Posting-number: Volume 16, Issue 5
- Archive-name: sipp2.0/part01
-
- This is an excerpt from the README file:
-
- *******************************************************************
- sipp 2.0 -- 3d rendering package
-
- by Jonas Yngvesson jonas-y@isy.liu.se
- Inge Wallin ingwa@isy.liu.se
-
- Linkoping Institute of Technology
- Sweden
- *******************************************************************
-
- This is the beta-test release of version 2.0 of SIPP, the SImple
- Polygon Processor. SIPP is a library for creating 3-dimensional
- scenes and rendering them using a scan-line z-buffer algorithm. A
- scene is built up of objects which can be transformed with rotation,
- translation and scaling. The objects form hierarchies where each
- object can have arbitrarily many subobjects and subsurfaces. A
- surface is a number of connected polygons which are rendered with
- Phong interpolation of the surface normals.
-
- The library has an internal database for the objects that is to be
- rendered. Objects can be installed in, and removed from, this
- database at any time.
-
- The library also provides 3-dimensional texture mapping with
- automatic interpolation of texture coordinates. Simple anti-aliasing
- is performed through double oversampling. A scene can be illuminated
- by an arbitrary number of light sources. A basic shading algorithm is
- provided with the library, but the user can also use his own shading
- algorithms for each surface to produce special effects. Images are
- produced in the Portable Pixmap format (ppm) for which many utilities
- exist.
-
- -------------------------- CUT HERE --------------------------
- #!/bin/sh
- # This is sipp-2.0, a shell archive (produced by shar 3.49)
- # To extract the files from this archive, save it to a file, remove
- # everything above the "!/bin/sh" line above, and type "sh file_name".
- #
- # made 12/20/1990 14:54 UTC by jonas-y@brassie
- # Source directory /u1/it/jonas-y/sippuz/sipp-2.0
- #
- # existing files will NOT be overwritten unless -c is specified
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 2565 -rw-r--r-- Makefile
- # 2520 -rw-r--r-- README
- # 2426 -rw-r--r-- libsipp/Makefile
- # 3876 -rw-r--r-- libsipp/TAGS
- # 377 -rw-r--r-- libsipp/TODO
- # 1710 -rw-r--r-- libsipp/basic_shader.c
- # 12593 -rw-r--r-- libsipp/bezier.c
- # 676 -rw-r--r-- libsipp/bezier.h
- # 10294 -rw-r--r-- libsipp/bezier_lex.c
- # 964 -rw-r--r-- libsipp/bezier_lex.l
- # 1968 -rw-r--r-- libsipp/block.c
- # 895 -rw-r--r-- libsipp/bozo.c
- # 1027 -rw-r--r-- libsipp/bumpy.c
- # 1981 -rw-r--r-- libsipp/cylinder.c
- # 3850 -rw-r--r-- libsipp/ellipsoid.c
- # 9833 -rw-r--r-- libsipp/geometric.c
- # 4007 -rw-r--r-- libsipp/geometric.h
- # 1373 -rw-r--r-- libsipp/granite.c
- # 1607 -rw-r--r-- libsipp/marble.c
- # 741 -rw-r--r-- libsipp/mask.c
- # 9261 -rw-r--r-- libsipp/noise.c
- # 234 -rw-r--r-- libsipp/noise.h
- # 1700 -rw-r--r-- libsipp/planet.c
- # 211 -rw-r--r-- libsipp/primitives.h
- # 3024 -rw-r--r-- libsipp/shaders.h
- # 52154 -rw-r--r-- libsipp/sipp.c
- # 5119 -rw-r--r-- libsipp/sipp.h
- # 1885 -rw-r--r-- libsipp/sipptypes.h
- # 2322 -rw-r--r-- libsipp/torus.c
- # 5405 -rw-r--r-- libsipp/xalloca.c
- # 314 -rw-r--r-- libsipp/xalloca.h
- # 7416 -rw-r--r-- doc/primitives.man
- # 10071 -rw-r--r-- doc/shaders.man
- # 20064 -rw-r--r-- doc/sipp.man
- # 2518 -rw-r--r-- demo/Makefile
- # 1771 -rw-r--r-- demo/README
- # 327 -rw-r--r-- demo/TAGS
- # 830 -rw-r--r-- demo/blocktest.c
- # 1910 -rw-r--r-- demo/chain.c
- # 866 -rw-r--r-- demo/cylindertest.c
- # 908 -rw-r--r-- demo/ellipsoid.c
- # 2837 -rw-r--r-- demo/isy90.c
- # 878 -rw-r--r-- demo/planettest.c
- # 2360 -rw-r--r-- demo/structure.c
- # 1505 -rw-r--r-- demo/teapot.c
- # 914 -rw-r--r-- demo/torustest.c
- # 644 -rw-r--r-- demo/tpt_body.bez
- # 2371 -rw-r--r-- demo/tpt_handle.bez
- # 481 -rw-r--r-- demo/tpt_lid.bez
- # 2358 -rw-r--r-- demo/tpt_spout.bez
- #
- # ============= Makefile ==============
- if test -f 'Makefile' -a X"$1" != X"-c"; then
- echo 'x - skipping Makefile (File already exists)'
- else
- echo 'x - extracting Makefile (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
- # sipp 2.0 - a 3-d rendering library
- #
- # Copyright 1990 Inge Wallin, Jonas Yngvesson
- #
- # This is the main Makefile for sipp version 2.0. This directory
- # contains three subdirectories:
- # libsipp: source code for the library itself.
- # demo: source code for demonstrations and tests
- # doc: standard manual pages for the library.
- #
- # You can either make the library and the tests/demos separately or
- # you can make them all in one make session.
- #
- # To create the library, just type 'make library'.
- # To make the demo programs, type 'make demos', but if you haven't
- # made the library first, this will be made automatically for you by
- # the makefile in the demos directory.
- #
- # Before you can make anything, though, you may have to edit the
- # following definitions:
- X
- X
- # If your C compiler doesn't grok the void type, uncomment the
- # following line:
- #NOVOID = -Dvoid=int
- X
- # If you don't have memcpy() and friends in your C library, or
- # if you don't have memory.h in /usr/include, uncomment the
- # following line:
- #NOMEMCPY = -DNOMEMCPY
- X
- # If you don't have alloca(), uncomment the following line:
- #ALLOCA = -DHAVE_NO_ALLOCA
- X
- # Choose a suitable C compiler and appropriate flags:
- CC = cc
- CFLAGS = -O4 -pipe
- X
- # Choose a lexical analyzer generator:
- LEX = lex
- X
- X
- # LIBDIR is where libsipp.a will be placed when you make install.
- # INCLUDEDIR is where the include files will be placed when you make install.
- # MANDIR is where the manuals will be placed when you make install.
- # MANEXT is the extension the manuals will receive in MANDIR
- X
- LIBDIR = /usr/local/lib
- INCLUDEDIR = /usr/local/include
- MANDIR = /usr/local/man/man3
- MANEXT = 3
- X
- X
- # ================================================================
- # Don't change anything below this line.
- # ================================================================
- X
- DOCFILES = primitives.man shaders.man sipp.man
- HEADERS = sipp.h shaders.h primitives.h
- X
- X
- MAKEOPTS = CC=$(CC) LEX=$(LEX) \
- X CFLAGS="$(NOVOID) $(NOMEMCPY) $(ALLOCA) $(CFLAGS) -I../libsipp"
- X
- X
- all: library demos
- X
- library:
- X cd libsipp; $(MAKE) $(MAKEOPTS) libsipp.a
- X
- demos:
- X cd demo; $(MAKE) $(MAKEOPTS) programs
- X
- X
- install: library
- X cd libsipp; $(MAKE) LIBDIR=$(LIBDIR) INCLUDEDIR=$(INCLUDEDIR) install
- X for i in $(DOCFILES) ; do \
- X cp doc/$$i $(MANDIR)/`basename $$i .man`.$(MANEXT); \
- X done
- X
- X
- clean:
- X $(RM) *~ *shar*
- X cd libsipp; $(MAKE) clean;
- X cd demo; $(MAKE) clean;
- X cd doc; ls -1 | egrep -v \.man$$ | xargs rm -f
- X
- shar: clean
- X shar -a -n sipp-2.0 -l 50 -o sipp-2.0.shar Makefile README \
- X libsipp/* doc/* demo/*
- SHAR_EOF
- chmod 0644 Makefile ||
- echo 'restore of Makefile failed'
- Wc_c="`wc -c < 'Makefile'`"
- test 2565 -eq "$Wc_c" ||
- echo 'Makefile: original size 2565, current size' "$Wc_c"
- fi
- # ============= README ==============
- if test -f 'README' -a X"$1" != X"-c"; then
- echo 'x - skipping README (File already exists)'
- else
- echo 'x - extracting README (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'README' &&
- *******************************************************************
- X sipp 2.0 -- 3d rendering package
- X
- X by Jonas Yngvesson jonas-y@isy.liu.se
- X Inge Wallin ingwa@isy.liu.se
- X
- X Linkoping Institute of Technology
- X Sweden
- *******************************************************************
- X
- This is the beta-test release of version 2.0 of SIPP, the SImple
- Polygon Processor. SIPP is a library for creating 3-dimensional
- scenes and rendering them using a scan-line z-buffer algorithm. A
- scene is built up of objects which can be transformed with rotation,
- translation and scaling. The objects form hierarchies where each
- object can have arbitrarily many subobjects and subsurfaces. A
- surface is a number of connected polygons which are rendered with
- Phong interpolation of the surface normals.
- X
- The library has an internal database for the objects that is to be
- rendered. Objects can be installed in, and removed from, this
- database at any time.
- X
- The library also provides 3-dimensional texture mapping with
- automatic interpolation of texture coordinates. Simple anti-aliasing
- is performed through double oversampling. A scene can be illuminated
- by an arbitrary number of light sources. A basic shading algorithm is
- provided with the library, but the user can also use his own shading
- algorithms for each surface to produce special effects. Images are
- produced in the Portable Pixmap format (ppm) for which many utilities
- exist.
- X
- The program has some bugs & limitations. See the BUGS entry in the
- manuals for more information.
- X
- To install the library, edit the Makefile and type 'make install'. If
- Your system does not have the drand48() random number generator, change
- the macro RANDOM() in sipp.h to use the random number generator available
- on your system.
- X
- If you only want to make the library but not install it, just type
- 'make library'.
- X
- If you want to make the tests and demonstrations, type 'make demos'.
- X
- X
- The library has so far only been tested on Sun workstations
- (SPARCstation & SUN3) but should work on most platforms regardless
- of UNIX version. If you run into trouble, let us know.
- X
- Please send any enhancements, bug reports and fixes to us.
- Especially, if you create nice new object types, we would be
- grateful if you sent the C functions creating those to us. We could
- then compile a library of object functions and let other people share
- the benefits.
- X
- Linkoping 19 December 1990
- X
- X enjoy! /Jonas & Inge
- SHAR_EOF
- chmod 0644 README ||
- echo 'restore of README failed'
- Wc_c="`wc -c < 'README'`"
- test 2520 -eq "$Wc_c" ||
- echo 'README: original size 2520, current size' "$Wc_c"
- fi
- # ============= libsipp/Makefile ==============
- if test ! -d 'libsipp'; then
- echo 'x - creating directory libsipp'
- mkdir 'libsipp'
- fi
- if test -f 'libsipp/Makefile' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/Makefile (File already exists)'
- else
- echo 'x - extracting libsipp/Makefile (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/Makefile' &&
- #
- # Makefile for libsipp.a
- #
- X
- #These values are default if they are not overridden from the command line:
- CC = cc
- CFLAGS = -pipe -I. -DHAVE_NO_ALLOCA
- X
- X
- IHDRS = sipptypes.h geometric.h noise.h bezier.h
- EHDRS = sipp.h shaders.h primitives.h
- HDRS = $(IHDRS) $(EHDRS)
- SRCS = sipp.c geometric.c \
- X basic_shader.c mask.c marble.c granite.c noise.c bozo.c bumpy.c \
- X planet.c \
- X block.c cylinder.c ellipsoid.c torus.c bezier.c bezier_lex.l
- LIBOBJS = libsipp.a(sipp.o) libsipp.a(geometric.o) libsipp.a(basic_shader.o)\
- X libsipp.a(marble.o) libsipp.a(granite.o) libsipp.a(mask.o)\
- X libsipp.a(bozo.o) libsipp.a(bumpy.o) libsipp.a(planet.o)\
- X libsipp.a(noise.o) libsipp.a(bezier.o) libsipp.a(bezier_lex.o)\
- X libsipp.a(torus.o) libsipp.a(cylinder.o) libsipp.a(ellipsoid.o) \
- X libsipp.a(block.o) \
- X libsipp.a(xalloca.o)
- X
- X
- # These are used if no other values are given at the command line:
- LIBDIR = /usr/local/lib
- INCLUDEDIR = /usr/local/include
- X
- X
- all: libsipp.a
- X
- libsipp.a: $(LIBOBJS)
- X ranlib libsipp.a
- X
- install: libsipp.a $(EHDRS)
- X cp libsipp.a $(LIBDIR)
- X cp $(EHDRS) $(INCLUDEDIR)
- X
- X
- libsipp.a(sipp.o): sipp.o
- libsipp.a(geometric.o): geometric.o
- libsipp.a(basic_shader.o): basic_shader.o
- libsipp.a(mask.o): mask.o
- libsipp.a(marble.o): marble.o
- libsipp.a(granite.o): granite.o
- libsipp.a(bozo.o): bozo.o
- libsipp.a(bumpy.o): bumpy.o
- libsipp.a(planet.o): planet.o
- libsipp.a(noise.o): noise.o
- libsipp.a(bezier.o): bezier.o
- libsipp.a(bezier_lex.o): bezier_lex.o
- libsipp.a(torus.o): torus.o
- libsipp.a(cylinder.o): cylinder.o
- libsipp.a(ellipsoid.o): ellipsoid.o
- libsipp.a(block.o): block.o
- X
- X
- X
- tags:
- X etags -t $(HDRS) $(SRCS)
- X
- clean:
- X $(RM) *.o *~ libsipp.a
- X
- X
- sipp.o: sipp.h sipptypes.h geometric.h
- geometric.o: geometric.h sipp.h
- basic_shader.o: sipp.h
- mask.o: shaders.h sipp.h
- marble.o: noise.h shaders.h sipp.h
- granite.o: noise.h shaders.h sipp.h
- bozo.o: noise.h shaders.h sipp.h
- bumpy.o: noise.h shaders.h sipp.h geometric.h
- planet.o: noise.h sipp.h geometric.h
- noise.o: noise.h sipp.h
- bezier.o: bezier.h sipp.h
- bezier_lex.o: bezier_lex.l bezier.h
- torus.o: sipp.h
- cylinder.o: sipp.h
- ellipsoid: sipp.h
- block.o: sipp.h
- xalloca.o: xalloca.h
- SHAR_EOF
- chmod 0644 libsipp/Makefile ||
- echo 'restore of libsipp/Makefile failed'
- Wc_c="`wc -c < 'libsipp/Makefile'`"
- test 2426 -eq "$Wc_c" ||
- echo 'libsipp/Makefile: original size 2426, current size' "$Wc_c"
- fi
- # ============= libsipp/TAGS ==============
- if test -f 'libsipp/TAGS' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/TAGS (File already exists)'
- else
- echo 'x - extracting libsipp/TAGS (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/TAGS' &&
- X
- sipptypes.h,78
- } Bucket;48,1498
- } Edge;40,1365
- } Inst_object;61,1843
- } View_coord;20,527
- X
- geometric.h,389
- #define MakePoint2d(42,943
- #define MakePoint3d(46,1070
- #define MakeVector(51,1250
- #define MatCopy(104,2696
- #define Vec2Row(113,2964
- #define VecAdd(70,1742
- #define VecAddS(85,2099
- #define VecComb(90,2240
- #define VecCopy(67,1691
- #define VecCross(95,2393
- #define VecDot(61,1548
- #define VecLen(64,1631
- #define VecNegate(56,1417
- #define VecScalMul(80,1978
- #define VecSub(75,1861
- X
- noise.h,0
- X
- bezier.h,101
- } Bez_Curve;25,377
- } Bez_Object;43,662
- } Bez_Patch;29,426
- } Bez_Vertex;21,330
- } Tokenval;16,279
- X
- sipp.h,312
- X24,347
- } Color;40,564
- } Lightsource;130,3248
- } Object;119,2965
- } Polygon;89,1793
- typedef void Shader(29,390
- } Surf_desc;142,3674
- } Surface;104,2398
- } Transf_mat;52,818
- } Vector;57,871
- } Vertex;69,1321
- } Vertex_ref;78,1477
- typedef unsigned char 11,102
- #define 12,130
- #define 13,147
- #define 22,287
- X
- shaders.h,110
- } Bozo_desc;28,601
- } Bumpy_desc;97,2757
- } Granite_desc;60,1492
- } Marble_desc;44,1054
- } Mask_desc;82,2475
- X
- primitives.h,0
- X
- sipp.c,1584
- calc_normals(1097,25896
- copy_polygons(506,13924
- copy_vertices(464,12968
- copy_vlist(485,13406
- create_edges(1148,27637
- delete_edges(1780,47171
- delete_vertices(553,14999
- get_view_transf(1678,44431
- init_buffers(1395,36211
- insert_edge(1502,39380
- lightsource_push(146,5630
- matrix_pop(1815,47811
- matrix_push(1799,47488
- merge_edge_lists(1536,40219
- object_add_subobj(912,22640
- object_add_surface(943,23248
- object_clear_transf(987,24033
- object_copy(727,18662
- object_create(703,18150
- object_deep_dup(843,21073
- object_delete(887,21966
- object_dup(820,20689
- object_install(628,16789
- object_instance(804,20409
- object_list_copy(761,19449
- object_move(1073,25337
- object_rot(1047,24922
- object_rot_x(1010,24395
- object_rot_y(1022,24562
- object_rot_z(1034,24729
- object_scale(1061,25142
- object_set_transf(975,23840
- object_transform(998,24198
- object_uninstall(690,17956
- polygon_push(357,10556
- r_del(640,16929
- r_object_delete(867,21574
- r_object_install(603,16126
- r_object_uninstall(660,17275
- render_image(1924,50800
- render_line(1419,36768
- reset_normals(1658,44082
- scan_and_render(1563,40854
- sipp_init(1955,51451
- surface_basic_create(404,11594
- surface_basic_shader(442,12444
- surface_copy(527,14400
- surface_create(377,10974
- surface_delete(569,15256
- surface_set_shader(425,12150
- transf_vertices(1318,33551
- traverse_object_db(1903,50217
- traverse_object_tree(1834,48181
- vertex_lookup(263,7829
- vertex_push(305,9061
- vertex_tx_push(316,9254
- view_at(202,6760
- view_focal(227,7093
- view_from(188,6572
- view_up(216,6961
- view_vec_eval(174,6366
- viewpoint(238,7224
- X
- geometric.c,258
- mat_mirror_plane(252,5925
- mat_mul(301,7729
- mat_mul34(361,9296
- mat_rotate(193,4456
- mat_rotate_x(98,2067
- mat_rotate_y(131,2937
- mat_rotate_z(164,3808
- mat_scale(227,5422
- mat_translate(73,1401
- new_matrix(25,397
- point_transform(341,8728
- vecnorm(47,779
- X
- basic_shader.c,21
- basic_shader(12,131
- X
- mask.c,18
- mask_shader(7,78
- X
- marble.c,38
- marble(17,206
- marble_shader(46,1025
- X
- granite.c,39
- granite 17,214
- granite_shader(44,788
- X
- noise.c,115
- Vector Dnoise(187,4647
- iadjust(39,706
- double noise(69,1228
- void noise_init(57,1062
- double turbulence(167,4317
- X
- bozo.c,20
- bozo_shader(16,198
- X
- bumpy.c,21
- bumpy_shader(18,219
- X
- planet.c,35
- planet_shader(53,899
- turb(25,447
- X
- block.c,38
- sipp_block(17,188
- sipp_cube(73,1808
- X
- cylinder.c,20
- sipp_cylinder(8,68
- X
- ellipsoid.c,43
- sipp_ellipsoid(8,68
- sipp_sphere(108,3652
- X
- torus.c,52
- arr_rot(8,71
- push_band(28,444
- sipp_torus(52,1101
- X
- bezier.c,239
- C(266,6370
- bblend(284,6575
- bez_curve_eval(313,7069
- bez_patch_eval(341,7691
- bezier_patches(381,8825
- bezier_read(204,4884
- bezier_rot_curves(426,10334
- curve_read(86,2083
- patch_read(144,3433
- sipp_bezier(484,12019
- vertex_read(24,591
- X
- bezier_lex.l,0
- SHAR_EOF
- chmod 0644 libsipp/TAGS ||
- echo 'restore of libsipp/TAGS failed'
- Wc_c="`wc -c < 'libsipp/TAGS'`"
- test 3876 -eq "$Wc_c" ||
- echo 'libsipp/TAGS: original size 3876, current size' "$Wc_c"
- fi
- # ============= libsipp/TODO ==============
- if test -f 'libsipp/TODO' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/TODO (File already exists)'
- else
- echo 'x - extracting libsipp/TODO (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/TODO' &&
- X
- Minor:
- X
- Make antialiasing optional with some kind of flag.
- X
- [Have the program whistle while it works with a verbose flag.]
- X
- Make it possible to render into a pixmap in core.
- X
- Major:
- X
- [Arbitrary number of "texture coordinates" (numbers to be
- interpolated over polygon surfaces).]
- X
- [More sofisticated antialiasing (A-buffer??)]
- X
- [Line image (without hidden lines) for preview.]
- SHAR_EOF
- chmod 0644 libsipp/TODO ||
- echo 'restore of libsipp/TODO failed'
- Wc_c="`wc -c < 'libsipp/TODO'`"
- test 377 -eq "$Wc_c" ||
- echo 'libsipp/TODO: original size 377, current size' "$Wc_c"
- fi
- # ============= libsipp/basic_shader.c ==============
- if test -f 'libsipp/basic_shader.c' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/basic_shader.c (File already exists)'
- else
- echo 'x - extracting libsipp/basic_shader.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/basic_shader.c' &&
- /*
- X * Basic shading model, somewhat modified and simplified version of
- X * Blinn's
- X */
- X
- #include <math.h>
- X
- #include <sipp.h>
- X
- X
- void
- basic_shader(a, b, c, u, v, w, view_vec, lights, sd, color)
- X double a, b, c, u, v, w;
- X Vector view_vec;
- X Lightsource *lights;
- X Surf_desc *sd;
- X Color *color;
- {
- X double nx, ny, nz, l;
- X double xs, ys, zs;
- X double coss, cosi, diffsum, specsum;
- X double c3two;
- X Lightsource *lp;
- X
- X l = (a * a + b * b + c * c);
- X nx = a;
- X ny = b;
- X nz = c;
- X if (fabs(l - 1.0) > 1e-5) {
- X l = sqrt(l);
- X nx /= l;
- X ny /= l;
- X nz /= l;
- X }
- X diffsum = specsum = 0;
- X c3two = sd->c3 * sd->c3;
- X for (lp = lights; lp != (Lightsource *)0; lp = lp->next) {
- X cosi = (lp->dir.x * nx + lp->dir.y * ny + lp->dir.z * nz);
- X if (cosi > 0)
- X diffsum += cosi * lp->intensity;
- X cosi *= -2.0;
- X xs = -lp->dir.x - cosi * nx;
- X ys = -lp->dir.y - cosi * ny;
- X zs = -lp->dir.z - cosi * nz;
- X coss = (xs * view_vec.x + ys * view_vec.y + zs * view_vec.z);
- X if (coss > 0)
- X specsum += lp->intensity * c3two * coss /
- X (coss * coss * (c3two -1) + 1);
- X }
- X color->red = (sd->color.red * (sd->ambient + diffsum) + sd->specular
- X * specsum);
- X if (color->red > 1.0) color->red = 1.0;
- X color->grn = (sd->color.grn * (sd->ambient + diffsum) + sd->specular
- X * specsum);
- X if (color->grn > 1.0) color->grn = 1.0;
- X color->blu = (sd->color.blu * (sd->ambient + diffsum) + sd->specular
- X * specsum);
- X if (color->blu > 1.0) color->blu = 1.0;
- }
- X
- X
- X
- SHAR_EOF
- chmod 0644 libsipp/basic_shader.c ||
- echo 'restore of libsipp/basic_shader.c failed'
- Wc_c="`wc -c < 'libsipp/basic_shader.c'`"
- test 1710 -eq "$Wc_c" ||
- echo 'libsipp/basic_shader.c: original size 1710, current size' "$Wc_c"
- fi
- # ============= libsipp/bezier.c ==============
- if test -f 'libsipp/bezier.c' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/bezier.c (File already exists)'
- else
- echo 'x - extracting libsipp/bezier.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bezier.c' &&
- #include <math.h>
- #include <stdio.h>
- X
- #include "sipp.h"
- #include "bezier.h"
- X
- X
- Tokenval tokenval;
- extern FILE *yyin;
- X
- X
- /*================================================================*/
- /* */
- /* Functions for reading bezier descriptions from file */
- /* */
- /*================================================================*/
- X
- X
- /*
- X * Read a vertex list, where each vertex is an xyz triple, and
- X * install it in the bezier structure.
- X */
- static void
- vertex_read(obj)
- X Bez_Object *obj;
- {
- X int token;
- X int i, j;
- X
- X token = yylex();
- X if (token != NVERTICES) {
- X fprintf(stderr, "Corrupt vertex description.\n");
- X goto errout;
- X }
- X
- X token = yylex();
- X if (token != INTEGER) {
- X fprintf(stderr, "Corrupt vertex description.\n");
- X goto errout;
- X }
- X obj->nvertex = tokenval.intval;
- X obj->vertex = (Bez_Vertex *)malloc(obj->nvertex * sizeof(Bez_Vertex));
- X if (obj->vertex == NULL) {
- X fprintf(stderr, "vertex_read: Out of core.\n");
- X goto errout;
- X }
- X
- X token = yylex();
- X if (token != VERTEX_LIST) {
- X fprintf(stderr, "Corrupt vertex description.\n");
- X goto errout;
- X }
- X
- X for (i = 0; i < obj->nvertex; i++) {
- X for (j = 0; j < 3; j++) {
- X token = yylex();
- X if (token != FLOAT && token != INTEGER) {
- X fprintf(stderr, "Corrupt vertex description.\n");
- X goto errout;
- X }
- X if (token == FLOAT) {
- X obj->vertex[i].coor[j] = tokenval.floatval;
- X } else {
- X obj->vertex[i].coor[j] = (double)tokenval.intval;
- X }
- X }
- X }
- X
- X return;
- X
- X errout:
- X if (obj->vertex != NULL) {
- X free(obj->vertex);
- X obj->vertex = NULL;
- X }
- }
- X
- X
- X
- /*
- X * Read a list of bezier curves, where each curve consists of
- X * four control points (index into the vertex list), and install
- X * it in the bezier structure.
- X */
- static void
- curve_read(obj)
- X Bez_Object *obj;
- {
- X int token;
- X int i, j;
- X
- X token = yylex();
- X if (token != NCURVES) {
- X fprintf(stderr, "Corrupt curve description.\n");
- X goto errout;
- X }
- X
- X token = yylex();
- X if (token != INTEGER) {
- X fprintf(stderr, "Corrupt curve description.\n");
- X goto errout;
- X }
- X obj->n.ncurves = tokenval.intval;
- X obj->cp.ccp = (Bez_Curve *)malloc(obj->n.ncurves * sizeof(Bez_Curve));
- X if (obj->cp.ccp == NULL) {
- X fprintf(stderr, "curve_read: Out of core.\n");
- X goto errout;
- X }
- X
- X token = yylex();
- X if (token != CURVE_LIST) {
- X fprintf(stderr, "Corrupt curve description.\n");
- X goto errout;
- X }
- X
- X for (i = 0; i < obj->n.ncurves; i++) {
- X for (j = 0; j < 4; j++) {
- X token = yylex();
- X if (token != INTEGER) {
- X fprintf(stderr, "Corrupt curve description.\n");
- X goto errout;
- X }
- X obj->cp.ccp[i].cp[j] = tokenval.intval - 1;
- X }
- X }
- X
- X return;
- X
- X errout:
- X if (obj->cp.ccp != NULL) {
- X free(obj->cp.ccp);
- X obj->cp.ccp = NULL;
- X }
- }
- X
- X
- X
- /*
- X * Read a list of bezier patches, where each patch consists of
- X * sixteen control points (index into the vertex list), and install
- X * it in the bezier structure.
- X */
- static void
- patch_read(obj)
- X Bez_Object *obj;
- {
- X int token;
- X int i, j, k;
- X
- X token = yylex();
- X if (token != NPATCHES) {
- X fprintf(stderr, "Corrupt patch description.\n");
- X goto errout;
- X }
- X
- X token = yylex();
- X if (token != INTEGER) {
- X fprintf(stderr, "Corrupt patch description.\n");
- X goto errout;
- X }
- X obj->n.npatches = tokenval.intval;
- X obj->cp.pcp = (Bez_Patch *)malloc(obj->n.npatches * sizeof(Bez_Patch));
- X if (obj->cp.pcp == NULL) {
- X fprintf(stderr, "patch_read: Out of core.\n");
- X goto errout;
- X }
- X
- X token = yylex();
- X if (token != PATCH_LIST) {
- X fprintf(stderr, "Corrupt patch description.\n");
- X goto errout;
- X }
- X
- X for (i = 0; i < obj->n.npatches; i++) {
- X for (j = 0; j < 4; j++) {
- X for (k = 0; k < 4; k++) {
- X token = yylex();
- X if (token != INTEGER) {
- X fprintf(stderr, "Corrupt patch description.\n");
- X goto errout;
- X }
- X obj->cp.pcp[i].cp[j][k] = tokenval.intval - 1;
- X }
- X }
- X }
- X
- X return;
- X
- X errout:
- X if (obj->cp.pcp != NULL) {
- X free(obj->cp.pcp);
- X obj->cp.pcp = NULL;
- X }
- }
- X
- X
- X
- /*
- X * Read a bezier object from a file, i.e. determine if it is a
- X * curve or patch description, read vertex and curve or patch
- X * description. Build a bezier object from the data.
- X */
- Bez_Object *
- bezier_read(file)
- X FILE *file;
- {
- X int token;
- X Bez_Object *obj;
- X
- X
- X yyin = file;
- X
- X obj = (Bez_Object *)calloc(1, sizeof(Bez_Object));
- X if (obj == NULL) {
- X fprintf(stderr, "bezier_read: Out of core.\n");
- X return obj;
- X }
- X if ((token = yylex()) == PATCHES) {
- X obj->type = PATCHES;
- X vertex_read(obj);
- X if (obj->vertex == NULL) {
- X goto errout;
- X }
- X patch_read(obj);
- X if (obj->cp.pcp == NULL) {
- X goto errout;
- X }
- X } else if (token == CURVES) {
- X obj->type = CURVES;
- X vertex_read(obj);
- X if (obj->vertex == NULL) {
- X goto errout;
- X }
- X curve_read(obj);
- X if (obj->cp.ccp == NULL) {
- X goto errout;
- X }
- X } else {
- X fprintf(stderr, "Corrupt bezier description file: %s\n", file);
- X return NULL;
- X }
- X
- X return obj;
- X
- X errout:
- X if (obj != NULL) {
- X if (obj->vertex != NULL) {
- X free(obj->vertex);
- X }
- X if (obj->cp.pcp != NULL) {
- X free(obj->cp.pcp);
- X }
- X free(obj);
- X }
- X return NULL;
- }
- X
- X
- /*================================================================*/
- /* */
- /* Functions for evaluating bezier functions */
- /* */
- /*================================================================*/
- X
- static double
- C(i)
- X int i;
- {
- X int j, a;
- X
- X a = 1;
- X for (j = i + 1; j < 4; j++) {
- X a = a * j;
- X }
- X for (j = 1 ; j < 4 - i; j++) {
- X a = a / j;
- X }
- X
- X return (double)a;
- }
- X
- X
- static double
- bblend(i, u)
- X int i;
- X double u;
- {
- X int j;
- X double v;
- X
- X v = C(i);
- X for (j = 1; j <= i; j++) {
- X v *= u;
- X }
- X for (j = 1; j < 4 - i; j++) {
- X v *= 1.0 - u;
- X }
- X
- X if (fabs(v) < 1.0E-15) {
- X return 0.0;
- X } else {
- X return v;
- X }
- }
- X
- X
- /*
- X * Determine x, y and z coordinates of a point on the bezier
- X * curve described by CURVE and VERTEX. U is a parameter between
- X * 0 and 1 that determines how far "into" the curve we are.
- X */
- static void
- bez_curve_eval(vertex, curve, u, x, y, z)
- X Bez_Vertex *vertex;
- X Bez_Curve *curve;
- X double u;
- X double *x, *y, *z;
- {
- X int i;
- X double b;
- X
- X *x = 0;
- X *y = 0;
- X *z = 0;
- X
- X for (i = 0; i < 4; i++) {
- X b = bblend(i, u);
- X *x += vertex[curve->cp[i]].coor[0] * b;
- X *y += vertex[curve->cp[i]].coor[1] * b;
- X *z += vertex[curve->cp[i]].coor[2] * b;
- X }
- }
- X
- X
- /*
- X * Determine x, y and z coordinates of a point on the bezier
- X * patch described by PATCH and VERTEX. U and V are parameters
- X * between 0 and 1 that determines where on the patch we are.
- X */
- static void
- bez_patch_eval(vertex, patch, v, u, x, y, z)
- X Bez_Vertex *vertex;
- X Bez_Patch *patch;
- X double u, v;
- X double *x, *y, *z;
- {
- X int i, j;
- X double b;
- X
- X *x = 0;
- X *y = 0;
- X *z = 0;
- X
- X for (i = 0; i < 4; i++) {
- X for (j = 0; j < 4; j++) {
- X b = bblend(i, v);
- X b *= bblend(j, u);
- X *x += vertex[patch->cp[i][j]].coor[0] * b;
- X *y += vertex[patch->cp[i][j]].coor[1] * b;
- X *z += vertex[patch->cp[i][j]].coor[2] * b;
- X }
- X }
- }
- X
- X
- X
- /*================================================================*/
- /* */
- /* Functions for creating bezier objects */
- /* (these functions are SIPP specific) */
- /* */
- /*================================================================*/
- X
- X
- /*
- X * Approximate the bezier patches described in OBJ with polygons
- X * and create a SIPP surface out of them. The patches will be
- X * tesselated into RESxRES polygons (rectangles).
- X */
- Surface *
- bezier_patches(obj, res, surface, shader)
- X Bez_Object *obj;
- X int res;
- X void *surface;
- X Shader *shader;
- {
- X double x, y, z;
- X double u, v;
- X double step;
- X int i, j, k;
- X
- X step = 1.0 / (double)res;
- X
- X for (i = 0; i < obj->n.npatches; i++) {
- X for (v = 0.0, j = 0; j < res; j++, v += step) {
- X for (u = 0.0, k = 0; k < res; k++, u += step) {
- X bez_patch_eval(obj->vertex, &obj->cp.pcp[i], v, u, &x, &y, &z);
- X vertex_tx_push(x, y, z, x, y, z);
- X bez_patch_eval(obj->vertex, &obj->cp.pcp[i], v, u + step,
- X &x, &y, &z);
- X vertex_tx_push(x, y, z, x, y, z);
- X bez_patch_eval(obj->vertex, &obj->cp.pcp[i],
- X v + step, u + step, &x, &y, &z);
- X vertex_tx_push(x, y, z, x, y, z);
- X bez_patch_eval(obj->vertex, &obj->cp.pcp[i], v + step, u,
- X &x, &y, &z);
- X vertex_tx_push(x, y, z, x, y, z);
- X polygon_push();
- X }
- X }
- X }
- X return surface_create(surface, shader);
- }
- X
- X
- X
- /*
- X * Take the bezier curves described in OBJ and create a
- X * surface by rotating them about th y-axis. The object
- X * will be tesselated as RESx(RES*4) polygons per curve.
- X * (The reason for using 4 times the resolution is rather
- X * "handwavy". I think 90 degrees is about as much as a
- X * patch should cover of a rotational body.)
- X */
- Surface *
- bezier_rot_curves(obj, res, surface, shader)
- X Bez_Object *obj;
- X int res;
- X void *surface;
- X Shader *shader;
- {
- X double x1, y1, z1;
- X double x2, y2, z2;
- X double xtmp;
- X double u;
- X double step;
- X double ca, sa;
- X int i, j, k;
- X
- X step = 1.0 / (double)res;
- X ca = cos(2.0 * M_PI / (4.0 * (double)res));
- X sa = sin(2.0 * M_PI / (4.0 * (double)res));
- X
- X for (i = 0; i < obj->n.ncurves; i++) {
- X for (u = 0.0, j = 0; j < res; j++, u += step) {
- X bez_curve_eval(obj->vertex, &obj->cp.ccp[i], u,
- X &x1, &y1, &z1);
- X bez_curve_eval(obj->vertex, &obj->cp.ccp[i], u + step,
- X &x2, &y2, &z2);
- X vertex_tx_push(x1, y1, z1, x1, y1, z1);
- X vertex_tx_push(x2, y2, z2, x2, y2, z2);
- X for (k = 0; k < 4 * res; k++) {
- X xtmp = ca * x1 + sa * z1;
- X z1 = ca * z1 - sa * x1;
- X x1 = xtmp;
- X xtmp = ca * x2 + sa * z2;
- X z2 = ca * z2 - sa * x2;
- X x2 = xtmp;
- X vertex_tx_push(x2, y2, z2, x2, y2, z2);
- X vertex_tx_push(x1, y1, z1, x1, y1, z1);
- X polygon_push();
- X
- X if (k == 4 * res - 1) {
- X break;
- X }
- X
- X vertex_tx_push(x1, y1, z1, x1, y1, z1);
- X vertex_tx_push(x2, y2, z2, x2, y2, z2);
- X }
- X }
- X }
- X
- X return surface_create(surface, shader);
- }
- X
- X
- X
- /*
- X * Read a bezier description from FILE and build
- X * a bezier surface. Tesselate this object into
- X * polygons and return a pointer to a SIPP object.
- X */
- Object *
- sipp_bezier(file, res, surface, shader)
- X FILE *file;
- X int res;
- X void *surface;
- X Shader *shader;
- {
- X Object *obj;
- X Bez_Object *bez_obj;
- X
- X bez_obj = bezier_read(file);
- X if (bez_obj == NULL) {
- X return NULL;
- X }
- X
- X obj = object_create();
- X if (bez_obj->type == PATCHES) {
- X object_add_surface(obj, bezier_patches(bez_obj, res, surface, shader));
- X } else {
- X object_add_surface(obj, bezier_rot_curves(bez_obj, res, surface,
- X shader));
- X }
- X
- X return obj;
- }
- SHAR_EOF
- chmod 0644 libsipp/bezier.c ||
- echo 'restore of libsipp/bezier.c failed'
- Wc_c="`wc -c < 'libsipp/bezier.c'`"
- test 12593 -eq "$Wc_c" ||
- echo 'libsipp/bezier.c: original size 12593, current size' "$Wc_c"
- fi
- # ============= libsipp/bezier.h ==============
- if test -f 'libsipp/bezier.h' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/bezier.h (File already exists)'
- else
- echo 'x - extracting libsipp/bezier.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bezier.h' &&
- #define PATCHES 1
- #define CURVES 2
- #define NVERTICES 3
- #define NPATCHES 4
- #define NCURVES 5
- #define VERTEX_LIST 6
- #define PATCH_LIST 7
- #define CURVE_LIST 8
- #define INTEGER 9
- #define FLOAT 10
- X
- X
- typedef union {
- X int intval;
- X double floatval;
- } Tokenval;
- X
- X
- typedef struct {
- X double coor[3];
- } Bez_Vertex;
- X
- typedef struct {
- X int cp[4];
- } Bez_Curve;
- X
- typedef struct {
- X int cp[4][4];
- } Bez_Patch;
- X
- typedef struct {
- X int type;
- X int nvertex;
- X Bez_Vertex *vertex;
- X union {
- X int ncurves;
- X int npatches;
- X } n;
- X union {
- X Bez_Curve *ccp;
- X Bez_Patch *pcp;
- X } cp;
- } Bez_Object;
- SHAR_EOF
- chmod 0644 libsipp/bezier.h ||
- echo 'restore of libsipp/bezier.h failed'
- Wc_c="`wc -c < 'libsipp/bezier.h'`"
- test 676 -eq "$Wc_c" ||
- echo 'libsipp/bezier.h: original size 676, current size' "$Wc_c"
- fi
- # ============= libsipp/bezier_lex.c ==============
- if test -f 'libsipp/bezier_lex.c' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/bezier_lex.c (File already exists)'
- else
- echo 'x - extracting libsipp/bezier_lex.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bezier_lex.c' &&
- # include "stdio.h"
- # define U(x) x
- # define NLSTATE yyprevious=YYNEWLINE
- # define BEGIN yybgin = yysvec + 1 +
- # define INITIAL 0
- # define YYLERR yysvec
- # define YYSTATE (yyestate-yysvec-1)
- # define YYOPTIM 1
- # define YYLMAX BUFSIZ
- # define output(c) putc(c,yyout)
- # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
- # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
- # define yymore() (yymorfg=1)
- # define ECHO fprintf(yyout, "%s",yytext)
- # define REJECT { nstr = yyreject(); goto yyfussy;}
- int yyleng; extern char yytext[];
- int yymorfg;
- extern char *yysptr, yysbuf[];
- int yytchar;
- FILE *yyin = {stdin}, *yyout = {stdout};
- extern int yylineno;
- struct yysvf {
- X struct yywork *yystoff;
- X struct yysvf *yyother;
- X int *yystops;};
- struct yysvf *yyestate;
- extern struct yysvf yysvec[], *yybgin;
- #include "bezier.h"
- X
- extern int atoi();
- extern double atof();
- X
- extern Tokenval tokenval;
- extern FILE *bezier_file;
- # define YYNEWLINE 10
- yylex(){
- int nstr; extern int yyprevious;
- while((nstr = yylook()) >= 0)
- yyfussy: switch(nstr){
- case 0:
- if(yywrap()) return(0); break;
- case 1:
- X {return PATCHES;}
- break;
- case 2:
- X {return CURVES;}
- break;
- case 3:
- X {return NVERTICES;}
- break;
- case 4:
- X {return NPATCHES;}
- break;
- case 5:
- X {return NCURVES;}
- break;
- case 6:
- X {return VERTEX_LIST;}
- break;
- case 7:
- X {return PATCH_LIST;}
- break;
- case 8:
- X {return CURVE_LIST;}
- break;
- case 9:
- X {tokenval.intval = atoi(yytext);
- X return INTEGER;
- X }
- break;
- case 10:
- X {tokenval.floatval = atof(yytext);
- X return FLOAT;
- X }
- break;
- case 11:
- X {}
- break;
- case 12:
- X { /* This is a comment */ }
- break;
- case 13:
- X { return yytext[0]; /* We found something wrong */ }
- break;
- case -1:
- break;
- default:
- fprintf(yyout,"bad switch yylook %d",nstr);
- } return(0); }
- /* end of yylex */
- X
- int
- yywrap()
- {
- X return 1;
- }
- int yyvstop[] = {
- 0,
- X
- 13,
- 0,
- X
- 11,
- 13,
- 0,
- X
- 11,
- 0,
- X
- 13,
- -12,
- 0,
- X
- 13,
- 0,
- X
- 9,
- 13,
- 0,
- X
- 13,
- 0,
- X
- 13,
- 0,
- X
- 13,
- 0,
- X
- 13,
- 0,
- X
- -12,
- 0,
- X
- 12,
- 0,
- X
- 9,
- 0,
- X
- 10,
- 0,
- X
- 10,
- 0,
- X
- 5,
- 0,
- X
- 4,
- 0,
- X
- 3,
- 0,
- X
- 8,
- 0,
- X
- 7,
- 0,
- X
- 6,
- 0,
- X
- 2,
- 0,
- X
- 1,
- 0,
- 0};
- # define YYTYPE char
- struct yywork { YYTYPE verify, advance; } yycrank[] = {
- 0,0, 0,0, 1,3, 0,0,
- 0,0, 6,13, 0,0, 0,0,
- 0,0, 0,0, 1,4, 1,5,
- 0,0, 6,13, 6,14, 0,0,
- 0,0, 0,0, 0,0, 0,0,
- 0,0, 0,0, 0,0, 0,0,
- 0,0, 0,0, 0,0, 0,0,
- 0,0, 0,0, 0,0, 0,0,
- 0,0, 0,0, 0,0, 0,0,
- 1,6, 0,0, 2,6, 0,0,
- 0,0, 0,0, 0,0, 0,0,
- 1,3, 0,0, 1,7, 6,13,
- 2,7, 1,8, 8,16, 15,16,
- 6,13, 7,15, 7,15, 7,15,
- 7,15, 7,15, 7,15, 7,15,
- 7,15, 7,15, 7,15, 0,0,
- 0,0, 0,0, 0,0, 0,0,
- 0,0, 0,0, 1,3, 0,0,
- 0,0, 6,13, 16,16, 16,16,
- 16,16, 16,16, 16,16, 16,16,
- 16,16, 16,16, 16,16, 16,16,
- 26,27, 26,27, 26,27, 26,27,
- 26,27, 26,27, 26,27, 26,27,
- 26,27, 26,27, 39,46, 16,21,
- 48,55, 57,63, 11,19, 1,9,
- 1,10, 2,9, 2,10, 9,17,
- 12,20, 24,30, 22,28, 28,32,
- 29,33, 30,34, 31,35, 37,44,
- 66,71, 1,11, 31,36, 2,11,
- 18,23, 19,24, 10,18, 1,12,
- 20,25, 2,12, 23,29, 17,22,
- 21,26, 25,31, 21,26, 16,21,
- 32,37, 21,27, 21,27, 21,27,
- 21,27, 21,27, 21,27, 21,27,
- 21,27, 21,27, 21,27, 33,38,
- 34,40, 35,42, 36,43, 38,45,
- 40,47, 41,48, 34,41, 42,49,
- 43,50, 44,51, 45,53, 47,54,
- 49,56, 50,57, 51,58, 52,59,
- 53,60, 54,61, 56,62, 33,39,
- 58,64, 59,65, 44,52, 60,66,
- 61,67, 62,68, 64,69, 65,70,
- 67,72, 68,73, 69,74, 70,75,
- 73,76, 74,77, 75,78, 77,79,
- 78,80, 80,81, 0,0, 0,0,
- 0,0};
- struct yysvf yysvec[] = {
- 0, 0, 0,
- yycrank+-1, 0, 0,
- yycrank+-3, yysvec+1, 0,
- yycrank+0, 0, yyvstop+1,
- yycrank+0, 0, yyvstop+3,
- yycrank+0, 0, yyvstop+6,
- yycrank+-4, 0, yyvstop+8,
- yycrank+5, 0, yyvstop+11,
- yycrank+4, yysvec+7, yyvstop+13,
- yycrank+2, 0, yyvstop+16,
- yycrank+1, 0, yyvstop+18,
- yycrank+1, 0, yyvstop+20,
- yycrank+3, 0, yyvstop+22,
- yycrank+0, yysvec+6, yyvstop+24,
- yycrank+0, 0, yyvstop+26,
- yycrank+5, yysvec+7, yyvstop+28,
- yycrank+26, 0, yyvstop+30,
- yycrank+1, 0, 0,
- yycrank+2, 0, 0,
- yycrank+1, 0, 0,
- yycrank+6, 0, 0,
- yycrank+81, 0, 0,
- yycrank+1, 0, 0,
- yycrank+4, 0, 0,
- yycrank+6, 0, 0,
- yycrank+9, 0, 0,
- yycrank+36, 0, 0,
- yycrank+0, yysvec+26, yyvstop+32,
- yycrank+6, 0, 0,
- yycrank+7, 0, 0,
- yycrank+5, 0, 0,
- yycrank+9, 0, 0,
- yycrank+14, 0, 0,
- yycrank+44, 0, 0,
- yycrank+45, 0, 0,
- yycrank+21, 0, 0,
- yycrank+43, 0, 0,
- yycrank+16, 0, 0,
- yycrank+35, 0, 0,
- yycrank+36, 0, 0,
- yycrank+36, 0, 0,
- yycrank+30, 0, 0,
- yycrank+52, 0, 0,
- yycrank+47, 0, 0,
- yycrank+50, 0, 0,
- yycrank+45, 0, 0,
- yycrank+0, 0, yyvstop+34,
- yycrank+46, 0, 0,
- yycrank+38, 0, 0,
- yycrank+44, 0, 0,
- yycrank+38, 0, 0,
- yycrank+37, 0, 0,
- yycrank+58, 0, 0,
- yycrank+41, 0, 0,
- yycrank+42, 0, 0,
- yycrank+0, 0, yyvstop+36,
- yycrank+53, 0, 0,
- yycrank+39, 0, 0,
- yycrank+46, 0, 0,
- yycrank+45, 0, 0,
- yycrank+47, 0, 0,
- yycrank+48, 0, 0,
- yycrank+50, 0, 0,
- yycrank+0, 0, yyvstop+38,
- yycrank+48, 0, 0,
- yycrank+68, 0, 0,
- yycrank+54, 0, 0,
- yycrank+110, 0, 0,
- yycrank+53, 0, 0,
- yycrank+69, 0, 0,
- yycrank+67, 0, 0,
- yycrank+0, 0, yyvstop+40,
- yycrank+0, 0, yyvstop+42,
- yycrank+114, 0, 0,
- yycrank+58, 0, 0,
- yycrank+73, 0, 0,
- yycrank+0, 0, yyvstop+44,
- yycrank+117, 0, 0,
- yycrank+61, 0, 0,
- yycrank+0, 0, yyvstop+46,
- yycrank+119, 0, 0,
- yycrank+0, 0, yyvstop+48,
- 0, 0, 0};
- struct yywork *yytop = yycrank+177;
- struct yysvf *yybgin = yysvec+1;
- char yymatch[] = {
- 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 011 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,01 ,01 ,'+' ,01 ,'+' ,01 ,01 ,
- '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
- '0' ,'0' ,01 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,'E' ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,'E' ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
- 0};
- char yyextra[] = {
- 0,0,0,0,0,0,0,0,
- 0,0,0,0,1,0,0,0,
- 0};
- #ifndef lint
- static char ncform_sccsid[] = "@(#)ncform 1.6 88/02/08 SMI"; /* from S5R2 1.2 */
- #endif
- X
- int yylineno =1;
- # define YYU(x) x
- # define NLSTATE yyprevious=YYNEWLINE
- char yytext[YYLMAX];
- struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
- char yysbuf[YYLMAX];
- char *yysptr = yysbuf;
- int *yyfnd;
- extern struct yysvf *yyestate;
- int yyprevious = YYNEWLINE;
- yylook(){
- X register struct yysvf *yystate, **lsp;
- X register struct yywork *yyt;
- X struct yysvf *yyz;
- X int yych, yyfirst;
- X struct yywork *yyr;
- # ifdef LEXDEBUG
- X int debug;
- # endif
- X char *yylastch;
- X /* start off machines */
- # ifdef LEXDEBUG
- X debug = 0;
- # endif
- X yyfirst=1;
- X if (!yymorfg)
- X yylastch = yytext;
- X else {
- X yymorfg=0;
- X yylastch = yytext+yyleng;
- X }
- X for(;;){
- X lsp = yylstate;
- X yyestate = yystate = yybgin;
- X if (yyprevious==YYNEWLINE) yystate++;
- X for (;;){
- # ifdef LEXDEBUG
- X if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
- # endif
- X yyt = yystate->yystoff;
- X if(yyt == yycrank && !yyfirst){ /* may not be any transitions */
- X yyz = yystate->yyother;
- X if(yyz == 0)break;
- X if(yyz->yystoff == yycrank)break;
- X }
- X *yylastch++ = yych = input();
- X yyfirst=0;
- X tryagain:
- # ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"char ");
- X allprint(yych);
- X putchar('\n');
- X }
- # endif
- X yyr = yyt;
- X if ( (int)yyt > (int)yycrank){
- X yyt = yyr + yych;
- X if (yyt <= yytop && yyt->verify+yysvec == yystate){
- X if(yyt->advance+yysvec == YYLERR) /* error transitions */
- X {unput(*--yylastch);break;}
- X *lsp++ = yystate = yyt->advance+yysvec;
- X goto contin;
- X }
- X }
- # ifdef YYOPTIM
- X else if((int)yyt < (int)yycrank) { /* r < yycrank */
- X yyt = yyr = yycrank+(yycrank-yyt);
- # ifdef LEXDEBUG
- X if(debug)fprintf(yyout,"compressed state\n");
- # endif
- X yyt = yyt + yych;
- X if(yyt <= yytop && yyt->verify+yysvec == yystate){
- X if(yyt->advance+yysvec == YYLERR) /* error transitions */
- X {unput(*--yylastch);break;}
- X *lsp++ = yystate = yyt->advance+yysvec;
- X goto contin;
- X }
- X yyt = yyr + YYU(yymatch[yych]);
- # ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"try fall back character ");
- X allprint(YYU(yymatch[yych]));
- X putchar('\n');
- X }
- # endif
- X if(yyt <= yytop && yyt->verify+yysvec == yystate){
- X if(yyt->advance+yysvec == YYLERR) /* error transition */
- X {unput(*--yylastch);break;}
- X *lsp++ = yystate = yyt->advance+yysvec;
- X goto contin;
- X }
- X }
- X if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
- # ifdef LEXDEBUG
- X if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
- # endif
- X goto tryagain;
- X }
- # endif
- X else
- X {unput(*--yylastch);break;}
- X contin:
- # ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"state %d char ",yystate-yysvec-1);
- X allprint(yych);
- X putchar('\n');
- X }
- # endif
- X ;
- X }
- # ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
- X allprint(yych);
- X putchar('\n');
- X }
- # endif
- X while (lsp-- > yylstate){
- X *yylastch-- = 0;
- X if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
- X yyolsp = lsp;
- X if(yyextra[*yyfnd]){ /* must backup */
- X while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
- X lsp--;
- X unput(*yylastch--);
- X }
- X }
- X yyprevious = YYU(*yylastch);
- X yylsp = lsp;
- X yyleng = yylastch-yytext+1;
- X yytext[yyleng] = 0;
- # ifdef LEXDEBUG
- X if(debug){
- X fprintf(yyout,"\nmatch ");
- X sprint(yytext);
- X fprintf(yyout," action %d\n",*yyfnd);
- X }
- # endif
- X return(*yyfnd++);
- X }
- X unput(*yylastch);
- X }
- X if (yytext[0] == 0 /* && feof(yyin) */)
- X {
- X yysptr=yysbuf;
- X return(0);
- X }
- X yyprevious = yytext[0] = input();
- X if (yyprevious>0)
- X output(yyprevious);
- X yylastch=yytext;
- # ifdef LEXDEBUG
- X if(debug)putchar('\n');
- # endif
- X }
- X }
- yyback(p, m)
- X int *p;
- {
- if (p==0) return(0);
- while (*p)
- X {
- X if (*p++ == m)
- X return(1);
- X }
- return(0);
- }
- X /* the following are only used in the lex library */
- yyinput(){
- X return(input());
- X }
- yyoutput(c)
- X int c; {
- X output(c);
- X }
- yyunput(c)
- X int c; {
- X unput(c);
- X }
- SHAR_EOF
- chmod 0644 libsipp/bezier_lex.c ||
- echo 'restore of libsipp/bezier_lex.c failed'
- Wc_c="`wc -c < 'libsipp/bezier_lex.c'`"
- test 10294 -eq "$Wc_c" ||
- echo 'libsipp/bezier_lex.c: original size 10294, current size' "$Wc_c"
- fi
- # ============= libsipp/bezier_lex.l ==============
- if test -f 'libsipp/bezier_lex.l' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/bezier_lex.l (File already exists)'
- else
- echo 'x - extracting libsipp/bezier_lex.l (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bezier_lex.l' &&
- %{
- #include "bezier.h"
- X
- extern int atoi();
- extern double atof();
- X
- extern Tokenval tokenval;
- extern FILE *bezier_file;
- %}
- %%
- X
- "bezier_patches:" {return PATCHES;}
- "bezier_curves:" {return CURVES;}
- "vertices:" {return NVERTICES;}
- "patches:" {return NPATCHES;}
- "curves:" {return NCURVES;}
- "vertex_list:" {return VERTEX_LIST;}
- "patch_list:" {return PATCH_LIST;}
- "curve_list:" {return CURVE_LIST;}
- X
- -?[0-9]+ {tokenval.intval = atoi(yytext);
- X return INTEGER;
- X }
- -?[0-9]+"."[0-9]*([eE][-+]?[0-9]+)? {tokenval.floatval = atof(yytext);
- X return FLOAT;
- X }
- X
- [ \n\t] {}
- #.*$ { /* This is a comment */ }
- . { return yytext[0]; /* We found something wrong */ }
- X
- %%
- X
- int
- yywrap()
- {
- X return 1;
- }
- SHAR_EOF
- chmod 0644 libsipp/bezier_lex.l ||
- echo 'restore of libsipp/bezier_lex.l failed'
- Wc_c="`wc -c < 'libsipp/bezier_lex.l'`"
- test 964 -eq "$Wc_c" ||
- echo 'libsipp/bezier_lex.l: original size 964, current size' "$Wc_c"
- fi
- # ============= libsipp/block.c ==============
- if test -f 'libsipp/block.c' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/block.c (File already exists)'
- else
- echo 'x - extracting libsipp/block.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/block.c' &&
- #include <sipp.h>
- X
- X
- struct {
- X int vertex[4];
- } sides[] = {
- X {0, 3, 2, 1},
- X {0, 1, 5, 4},
- X {1, 2, 6, 5},
- X {2, 3, 7, 6},
- X {3, 0, 4, 7},
- X {4, 5, 6, 7}
- };
- X
- X
- Object *
- sipp_block(xsize, ysize, zsize, surface, shader)
- X double xsize;
- X double ysize;
- X double zsize;
- X void *surface;
- X Shader *shader;
- {
- X Object *block;
- X Vector vertices[8];
- X int i, j;
- X
- X vertices[0].x = -xsize / 2.0;
- X vertices[0].y = -ysize / 2.0;
- X vertices[0].z = -zsize / 2.0;
- X vertices[1].x = xsize / 2.0;
- X vertices[1].y = -ysize / 2.0;
- X vertices[1].z = -zsize / 2.0;
- X vertices[2].x = xsize / 2.0;
- X vertices[2].y = ysize / 2.0;
- X vertices[2].z = -zsize / 2.0;
- X vertices[3].x = -xsize / 2.0;
- X vertices[3].y = ysize / 2.0;
- X vertices[3].z = -zsize / 2.0;
- X vertices[4].x = -xsize / 2.0;
- X vertices[4].y = -ysize / 2.0;
- X vertices[4].z = zsize / 2.0;
- X vertices[5].x = xsize / 2.0;
- X vertices[5].y = -ysize / 2.0;
- X vertices[5].z = zsize / 2.0;
- X vertices[6].x = xsize / 2.0;
- X vertices[6].y = ysize / 2.0;
- X vertices[6].z = zsize / 2.0;
- X vertices[7].x = -xsize / 2.0;
- X vertices[7].y = ysize / 2.0;
- X vertices[7].z = zsize / 2.0;
- X
- X block = object_create();
- X
- X for (i = 0; i < 6; i++) {
- X for (j = 0; j < 4; j++) {
- X vertex_tx_push(vertices[sides[i].vertex[j]].x,
- X vertices[sides[i].vertex[j]].y,
- X vertices[sides[i].vertex[j]].z,
- X vertices[sides[i].vertex[j]].x,
- X vertices[sides[i].vertex[j]].y,
- X vertices[sides[i].vertex[j]].z);
- X }
- X polygon_push();
- X object_add_surface(block, surface_create(surface, shader));
- X }
- X
- X return block;
- }
- X
- X
- Object *
- sipp_cube(size, surface, shader)
- X double size;
- X void *surface;
- X Shader *shader;
- {
- X return sipp_block(size, size, size, surface, shader);
- }
- X
- SHAR_EOF
- chmod 0644 libsipp/block.c ||
- echo 'restore of libsipp/block.c failed'
- Wc_c="`wc -c < 'libsipp/block.c'`"
- test 1968 -eq "$Wc_c" ||
- echo 'libsipp/block.c: original size 1968, current size' "$Wc_c"
- fi
- # ============= libsipp/bozo.c ==============
- if test -f 'libsipp/bozo.c' -a X"$1" != X"-c"; then
- echo 'x - skipping libsipp/bozo.c (File already exists)'
- else
- echo 'x - extracting libsipp/bozo.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'libsipp/bozo.c' &&
- /*
- X * marble shader - simulates marble using noise & turbulence
- X */
- X
- #include <math.h>
- #include <stdio.h>
- X
- #include <sipp.h>
- #include <noise.h>
- #include <shaders.h>
- X
- X
- extern bool noise_ready;
- X
- void
- bozo_shader(nx, ny, nz, u, v, w, view_vec, lights, bd, color)
- X double nx, ny, nz, u, v, w;
- X Vector view_vec;
- X Lightsource *lights;
- X Bozo_desc *bd;
- X Color *color;
- {
- X Vector tmp;
- X Surf_desc surface;
- X double noiseval;
- X int i;
- X
- X if (!noise_ready) {
- X noise_init();
- X }
- X
- X tmp.x = u * bd->scale;
- X tmp.y = v * bd->scale;
- X tmp.z = w * bd->scale;
- X noiseval = noise(&tmp);
- X
- X i = (noiseval + 1) * bd->no_of_cols / 2.0;
- X surface.color = bd->colors[i];
- X surface.ambient = bd->ambient;
- X surface.specular = bd->specular;
- X surface.c3 = bd->c3;
- X basic_shader(nx, ny, nz, u, v, w, view_vec, lights, &surface, color);
- }
- SHAR_EOF
- chmod 0644 libsipp/bozo.c ||
- echo 'restore of libsipp/bozo.c failed'
- Wc_c="`wc -c < 'libsipp/bozo.c'`"
- test 895 -eq "$Wc_c" ||
- echo 'libsipp/bozo.c: original size 895, current size' "$Wc_c"
- fi
- true || echo 'restore of libsipp/bumpy.c failed'
- echo End of part 1, continue with part 2
- exit 0
-
- --
- Inge Wallin | Thus spake the master programmer: |
- | "After three days without programming, |
- ingwa@isy.liu.se | life becomes meaningless." |
- | Geoffrey James: The Tao of Programming. |
-
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-