Fancy view - Alex
[terminatorX.git] / knob / render_all
1 #!/usr/bin/python
2
3 import os, sys
4
5 knob_view = 1
6
7 def render(i, mask):
8         angle = 280.0*float(i)/49.0+40.0-180.0
9         
10         inf = open('tX_knob.pov')
11         outf = open('tmp.pov', 'w')
12         for line in inf:
13                 out = line.replace('ROT_ANGLE','%lf' % angle)
14                 
15                 if mask:
16                         out = out.replace('BACKGROUND','Black')
17                         out = out.replace('MASKOPTION','no_shadow')
18                 else:
19                         out = out.replace('BACKGROUND','Blue')
20                         out = out.replace('MASKOPTION','')
21                         
22                 out = out.replace('KNOB_VIEW', '%i' % knob_view)
23                 
24                 outf.write(out)
25                 
26         outf.close()
27         inf.close()
28         
29         if knob_view == 2:
30                 povargs='-w1600 -h1280 +a0.3'
31         else:
32                 povargs='-w320 -h240 -icon'
33
34         if mask:
35                 m = '-mask'
36         else:
37                 m = ''
38                 
39         imagename = 'knob%0i%s.png' % (49-i,m)
40         os.system('povray +L. -itmp.pov -p -o. -O%s %s' % (imagename,povargs))
41         os.unlink('tmp.pov')
42
43
44 if len(sys.argv)>1:
45         img = []
46         for image in sys.argv[1:]:
47                 if image == "-2":
48                         knob_view = 2
49                 else:
50                         img.append(int(image))
51 else:
52         img = xrange(0,50)
53         
54 print img       
55
56 for i in img:
57         render(i, False)
58         if knob_view == 1:
59                 render(i, True)
60