Path: utzoo!utgpu!water!watmath!clyde!att-cb!att-ih!ihnp4!inuxc!iuvax!pur-ee!j.cc.purdue.edu!ain From: ain@j.cc.purdue.edu (Patrick White) Newsgroups: comp.binaries.amiga Subject: spheres (docs and data) Message-ID: <6624@j.cc.purdue.edu> Date: 8 Mar 88 05:09:52 GMT Organization: PUCC Land, USA Lines: 213 Approved: ain@j.cc.purdue.edu (Pat White) Program Name: spheres (docs and data) Submitted By: guilford@csv.rpi.edu (Jim Guilford) Summary: Rotate spheres in 3-D to mouse movement. Poster Boy: Pat White (ain@j.cc.purdue.edu) Tested. NOTES: Docs and the data. Had to reshar it -- if anything's wrong, it's al my fault :-) -- Pat White (co-moderator comp.sources/binaries.amiga) UUCP: j.cc.purdue.edu!ain BITNET: PATWHITE@PURCCVM PHONE: (317) 743-8421 U.S. Mail: 320 Brown St. apt. 406, West Lafayette, IN 47906 ======================================== # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # README # balls.1.dat # balls.2.dat # balls.default.dat # cyclo.dat # This archive created: Mon Mar 7 19:27:31 1988 # By: Patrick White (PUCC Land, USA) echo shar: extracting README '(5347 characters)' cat << \SHAR_EOF > README ANIMBALLS - An animation hack by JimG (Jim Guilford) Animballs allows one to create a collection of balls in three space and then interactively rotate them in real time. It uses HAM mode to allow for a wide range of coloring. To use animballs, type "animballs BallsFileName" from the CLI, where BallsFileName is the name of the file containing the description of the balls. The format of the file will be described later. A blank screen will appear with the heading of "Please Wait . . .". During this phase, some calculations are taking place. For a large or complex image, this may take a while, so be patient. After a while, the image of the balls will appear and you can start rotating them. You rotate them by draging with the mouse. You should press and hold the left button of the mouse. Then as you move the mouse, the image will rotate. As you move the mouse left and right, the universe will rotate around a veritcal axis (the front of the image moving towards the left or right). As you move the mouse up and down, the collection of balls will rotate around a horizontal axis (front of the object moving up or down). If you press and hold the Control key (CTRL) while you move the mouse, the direction of rotation is modified. With CTRL, moving the mouse to the right rotates the image clockwise, and to the left counterclockwise. Moving the mouse up and down with CTRL pressed has no effect. Pressing (and holding) the shift key while dragging the mouse will slow the rotations down by a factor of 2. Pressing the Alt key will speed up the rotations by a factor of 2. You terminate the program by left clicking on the close gadget. The program may also be invoked as "animballs -bw FileName". This specified black & white mode. Everything will be rendered on a black and white screen instead of a HAM screen. This will both require less memory and speed up the redisplay. For a complex scene, this may be required. Note that in the current implementation, the balls are rendered into a 200 by 200 screen. This means that if you move the mouse further to the right, the pointer will disappear. Don't let this worry you. It is still there, you just can't see it. The balls description file starts with an optional title. If the first character is an double quote ("), then everything up to the next double quote is taken as a title. If the first character is not a quote, then a default title is used. Following this are many numbers which describe the collection of balls. Each number is separated from the others by white-space (space, tab, new-line). Commas should NOT appear. First are three numbers which describe the red, green, and blue components of the background color. These should vary from 0 to 1. Animballs will find a background color which approximates the color you give it. A future enhancement may be to exactly use the given color, but I don't feel like re-coding it now. Following this is the number of balls. Then a description of each ball follows. There is no significance to the order in which the balls appear. For each ball, the first three numbers are the x, y, z coordinates of the center. The center of the screen is the center of rotation, and forms the 0,0,0 point. Then comes the radius of the ball, and finally comes the r,g,b components of the ball color. Note again that there are no commas between any of the numbers. In order to prevent the balls from rotating out of the screen, the distance to the furthest ball added to its radius should not exceed about 90. If it does, a warning will be printed, and the program will re-scale the balls to fit into the allowed space. A further enhancement might be to allow larger scenes and then clip the images, but I haven't done this. The balls are rendered by a light source at infinity from the 1,1,1 direction (right, up, out of the screen). The given color is the diffuse color. White specular highlights are added. The parameters are hard coded in the program, but may be changed if the program is to be recompiled. About the code Feel free to use the code for any non-commercial purpose. If you make any enhancements (or have any other comments) I would appreciate hearing about them. The file "makedata.c" contains the code which generates the data.c file. It is not required for compiling animballs but is included for completeness. I wrote the code using the Lattice 4.0 C compiler. I haven't tried compiling it under Manx or the earlier Lattice compiler, but I don't do anything particularly strange, so it shouldn't be too hard to port. The only thing that may cause problems is the #include lines. If these are troublesome, they can be removed with no harm (under 4.0 they enable addition type checking and allow the library routines to be called directly from C instead of going through stubs). I compiled animballs with the following command: lc -Lf -f animballs screen hamstuff myblit data All this does is invoke the C compiler on each file and then link them. The -f and -Lf cause the Motorola Fast Floating Point routines to be used insead of the IEEE routines. This speeds up the rendering, but is not strictly required. Jim Guilford 225 Hoosick St. Troy, NY 12180 Internet: guilford@csv.rpi.edu uucp: . . . rutgers!nysernic!rpics!guilford SHAR_EOF if test 5347 -ne "`wc -c README`" then echo shar: error transmitting README '(should have been 5347 characters)' fi echo shar: extracting balls.1.dat '(197 characters)' cat << \SHAR_EOF > balls.1.dat "Octohedron" 1 0 0 6 30 0 0 9.5 1 0 0 -30 0 0 9.5 0 1 1 0 30 0 9.5 0 1 0 0 -30 0 9.5 1 0 1 0 0 30 9.5 0 0 1 0 0 -30 9.5 1 1 0 SHAR_EOF if test 197 -ne "`wc -c balls.1.dat`" then echo shar: error transmitting balls.1.dat '(should have been 197 characters)' fi echo shar: extracting balls.2.dat '(115 characters)' cat << \SHAR_EOF > balls.2.dat .6 .5 .4 4 20 20 20 13.5 .0 .0 .0 -20 -20 20 13.5 .2 .2 .2 20 -20 -20 13.5 .4 .4 .4 -20 20 -20 13.5 .6 .6 .6 SHAR_EOF if test 115 -ne "`wc -c balls.2.dat`" then echo shar: error transmitting balls.2.dat '(should have been 115 characters)' fi echo shar: extracting balls.default.dat '(230 characters)' cat << \SHAR_EOF > balls.default.dat "Octohedron" 0.2 0.3 0.3 7 30 0 0 9.5 1 0 0 -30 0 0 9.5 0 1 1 0 30 0 9.5 0 1 0 0 -30 0 9.5 1 0 1 0 0 30 9.5 0 0 1 0 0 -30 9.5 1 1 0 0 0 0 13.5 1 1 1 SHAR_EOF if test 230 -ne "`wc -c balls.default.dat`" then echo shar: error transmitting balls.default.dat '(should have been 230 characters)' fi echo shar: extracting cyclo.dat '(611 characters)' cat << \SHAR_EOF > cyclo.dat .7 .5 .3 19 -17.5 28.4 0.0 13.5 .2 .2 .2 17.5 28.4 0.0 13.5 .2 .2 .2 29.1 0.0 16.8 13.5 .2 .2 .2 17.5 -28.4 0.0 13.5 .2 .2 .2 -17.5 -28.4 0.0 13.5 .2 .2 .2 -29.1 0.0 -16.8 13.5 .2 .2 .2 25.5 47.7 10.6 9.5 1. .7 0. 25.5 28.3 -22.0 9.5 1. .7 0. 21.2 0.0 38.9 9.5 1. .0 0. 37.7 0.0 52.1 9.5 1. .7 0. 52.5 0.0 17.4 9.5 1. .7 0. 25.5 -47.4 10.6 9.5 1. .7 0. 25.5 -28.3 -22.0 9.5 1. .7 0. -25.5 -47.7 -10.6 9.5 1. .7 0. -25.5 -28.3 22.0 9.5 1. .7 0. -21.2 0.0 -38.9 9.5 1. .7 0. -52.5 0.0 -17.4 9.5 1. .7 0. -25.5 47.4 -10.6 9.5 1. .7 0. -25.5 28.3 22.0 9.5 1. .7 0. SHAR_EOF if test 611 -ne "`wc -c cyclo.dat`" then echo shar: error transmitting cyclo.dat '(should have been 611 characters)' fi # End of shell archive exit 0