changes to visualization, not finished by now!
[physik/posic.git] / visualize
diff --git a/visualize b/visualize
new file mode 100755 (executable)
index 0000000..b85b839
--- /dev/null
+++ b/visualize
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+if [ ! -d $1 ] ; then
+       echo "no such directory -> $1"
+       exit
+fi
+
+POVRAY="povray -W1024 -H768 -d" 
+
+echo "processing $1 ..."
+
+for file in $1/povray_*.in ; do
+       cat > temp.pov <<-EOF
+#include "colors.inc"
+#include "textures.inc"
+#include "shapes.inc"
+#include "glass.inc"
+#include "metals.inc"
+#include "woods.inc"
+#include "stones.inc"
+EOF
+
+       # meta info
+       count=`grep '# \[C\]' $file | awk '{ print $3 }'`
+       time=`grep '# \[T\]' $file | awk '{ print $3 }'`
+       camloc=`grep '# \[L\]' $file | awk '{ print $3 }'`
+
+       # atoms
+       cat $file | grep -v '#' | while read radius x y z ; do #temp dis; do
+               cat >> temp.pov <<-EOF
+sphere {
+       <$x, $z, $y>, $radius
+       texture {
+               pigment { color Yellow }
+               finish {
+                       phong 1
+                       metallic
+                }
+       }
+}
+EOF
+       done
+
+       # boundaries
+       cat $file | grep '# \[D\]' | while read foo bar x1 y1 z1 x2 y2 z2 ; do
+               cat >> temp.pov <<-EOF
+cylinder {
+       <$x1, $z1, $y1>, <$x2, $z2, $y2>, 0.05
+       pigment { color White }
+}
+EOF
+       done
+
+       # add camera and light source
+       cat >> temp.pov <<-EOF
+camera {
+//     orthographic
+       location $camloc
+       look_at <0,0,0>
+}
+light_source { <0,10000,0> color White shadowless }
+EOF
+
+       # mv png
+       $POVRAY temp.pov > /dev/null 2>&1
+       mv temp.png `echo $file | sed 's/\.in/\.png/'`
+
+done
+
+echo "done"