changes to visualization, not finished by now!
[physik/posic.git] / visualize
1 #!/bin/sh
2
3 if [ ! -d $1 ] ; then
4         echo "no such directory -> $1"
5         exit
6 fi
7
8 POVRAY="povray -W1024 -H768 -d" 
9
10 echo "processing $1 ..."
11
12 for file in $1/povray_*.in ; do
13         cat > temp.pov <<-EOF
14 #include "colors.inc"
15 #include "textures.inc"
16 #include "shapes.inc"
17 #include "glass.inc"
18 #include "metals.inc"
19 #include "woods.inc"
20 #include "stones.inc"
21 EOF
22
23         # meta info
24         count=`grep '# \[C\]' $file | awk '{ print $3 }'`
25         time=`grep '# \[T\]' $file | awk '{ print $3 }'`
26         camloc=`grep '# \[L\]' $file | awk '{ print $3 }'`
27
28         # atoms
29         cat $file | grep -v '#' | while read radius x y z ; do #temp dis; do
30                 cat >> temp.pov <<-EOF
31 sphere {
32         <$x, $z, $y>, $radius
33         texture {
34                 pigment { color Yellow }
35                 finish {
36                         phong 1
37                         metallic
38                  }
39         }
40 }
41 EOF
42         done
43
44         # boundaries
45         cat $file | grep '# \[D\]' | while read foo bar x1 y1 z1 x2 y2 z2 ; do
46                 cat >> temp.pov <<-EOF
47 cylinder {
48         <$x1, $z1, $y1>, <$x2, $z2, $y2>, 0.05
49         pigment { color White }
50 }
51 EOF
52         done
53
54         # add camera and light source
55         cat >> temp.pov <<-EOF
56 camera {
57 //      orthographic
58         location $camloc
59         look_at <0,0,0>
60 }
61 light_source { <0,10000,0> color White shadowless }
62 EOF
63
64         # mv png
65         $POVRAY temp.pov > /dev/null 2>&1
66         mv temp.png `echo $file | sed 's/\.in/\.png/'`
67
68 done
69
70 echo "done"