#!/usr/bin/perl # This program takes in a filename, and outputs pov code to # produce a spider web. You currently have to hand edit # The following variables to move things around. # CENT= Center of the web $CENT="<0,0,0>"; # Number of loops around the web $NUM_RINGS=8; # Radius of the web strings $STRING_RAD=0.05; # The webs made of blobs this is the STRENGTH $STRING_TEN=1; # The webs THRESHOLD $THRESHOLD=0.65; # The points are the anchor points for the web # Example: # X X # # 0 X # # X X # # 0 = center # X = anchor points # @points= ("<0,1,0>", "<.5,.5,0>", "<1,0,0>", "<.5,-.5,0>", "<0,-1,0>", "<-.5,-.5,0>", "<-1,0,0>", "<-.5,.5,0>"); ($outfile) = @ARGV; open (OUTFILE, ">$outfile") || die "Could not open $outfile.\n"; print OUTFILE "#declare CENT = $CENT\n"; print OUTFILE "#declare NUM_RINGS = $NUM_RINGS\n"; print OUTFILE "#declare STRING_RAD = $STRING_RAD\n"; print OUTFILE "#declare STRING_TEN = $STRING_TEN\n"; $i=0; foreach (@points) { print OUTFILE "#declare P$i = $_\n"; print OUTFILE "#declare D$i = (P$i - CENT ) / NUM_RINGS\n"; $i++; } print OUTFILE "// #declare web =\nunion {\n"; print OUTFILE " blob {\n"; print OUTFILE " threshold .65\n"; $i2=0; while ($i2 < $i) { print OUTFILE " cylinder { CENT P$i2 STRING_RAD STRING_TEN }\n"; $i2++; } print OUTFILE " }\n"; print OUTFILE " #declare Z = 1\n"; print OUTFILE " #while ( Z < NUM_RINGS )\n"; $i2=0; while ($i2 < $i) { print OUTFILE " #declare V$i2=\n"; $i2++; } # need to take care of last one also. print OUTFILE " blob {\n"; print OUTFILE " threshold $THRESHOLD\n"; $i2=0; $i--; while ($i2 < $i) { print OUTFILE " cylinder { V$i2 V"; print OUTFILE $i2+1; print OUTFILE " STRING_RAD, STRING_TEN }\n"; $i2++; } print OUTFILE " cylinder { V$i2 V0 STRING_RAD, STRING_TEN }\n"; print OUTFILE " }\n"; print OUTFILE " #declare Z=Z+1\n"; print OUTFILE " #end // while\n"; print OUTFILE " pigment { White }\n"; print OUTFILE " finish { Shiny }\n"; print OUTFILE "}";