#!/usr/bin/perl -w # off2pov - converts .off files to .pov-files # Copyright (C) Ingo Blechschmidt Sam Okt 5 17:41:20 MEST 2002 - now, # released under the Terms of the GNU General Public License. # Ingo Blechschmidt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Arberstraße 5 # 86179 Augsburg # E-Mail: iblech@web.de, http://www.way.to/uselinux/ # Tel.: +49 / 821 882955 # # $radiS = "0.3"; $radiC = "0.2"; $pigS = "MyP"; $pigC = "MyC"; $pigF = "MyF"; $finS = "FiP"; $finC = "FiC"; $finF = "FiF"; @points = (); @rechts = (); @verbs = (); @Sat = (); $a = ""; $i = 0; $a = ; chomp($a); @Sat = split(" ", $a); for($i = 0; $i < $Sat[0]; $i++) { $a = ; chomp($a); $points[$i]=$a; } for($i = 0; $i < $Sat[1]; $i++) { $a = ; chomp($a); $rechts[$i]=$a; } for($i = 0; $i < $Sat[2]; $i++) { $a = ; chomp($a); $verbs[$i]=$a; } for($i = 0; $i < $Sat[0]; $i++) { print "sphere { <"; print `echo $points[$i] | sed -e 's+^ *++' -e 's+ *\$++' | tr -s ' ' | tr ' ' ',' | tr -d '\n'`; print ">, rad pigment { $pigS } finish { $finS } }\n"; } for($i = 0; $i < $Sat[1]; $i++) { @R = split(" ", $rechts[$i]); print "polygon { " . int($R[0] + 1) . " "; for($j = 1; $j <= $R[0]; $j++) { print "<" . `echo $points[$R[$j]] | sed -e 's+^ *++' -e 's+ *\$++' | tr -s ' ' | tr ' ' ',' | tr -d '\n' ` . ">, "; } print "<" . `echo $points[$R[1]] | sed -e 's+^ *++' -e 's+ *\$++' | tr -s ' ' | tr ' ' ',' | tr -d '\n' ` . "> pigment { $pigF } finish { $finF } }\n"; } for($i = 0; $i < $Sat[2]; $i++) { @R = split(" ", $verbs[$i]); print "cylinder { <"; print `echo $points[$R[0]] | sed -e 's+^ *++' -e 's+ *\$++' | tr -s ' ' | tr ' ' ',' | tr -d '\n'`; print ">, <"; print `echo $points[$R[1]] | sed -e 's+^ *++' -e 's+ *\$++' | tr -s ' ' | tr ' ' ',' | tr -d '\n'`; print ">, cad pigment { $pigC } finish { $finC } }\n"; }