source: util/src/AnimateStereo.py.in@ a3ffb44

Last change on this file since a3ffb44 was e1a46d, checked in by Frederik Heber <heber@…>, 16 years ago

All of my python script put into ESPACK and adapted with @PYTHON@ and so on.

  • Property mode set to 100755
File size: 4.3 KB
Line 
1#!@PYTHON@
2#
3# Creates a series of stereo header (left and right) files to be included in a raster3d with a rotational coordinate transformation
4
5import sys, random, math, re
6wrerr=sys.stderr.write
7wrout=sys.stdout.write
8
9# check arguments
10if len(sys.argv) < 2:
11 print "Usage: "+sys.argv[0]+" <prefix> [AtomCount]"
12 sys.exit(1)
13
14# get atomcount
15if len(sys.argv) < 2:
16 Atoms=10
17else:
18 Atoms=int(sys.argv[2])
19
20# deduce r-factor
21factor=15.0 + (40.0-15.0)/2000*Atoms
22
23for i in range(36):
24 for type in range(2):
25 c = math.cos(2.*math.pi/36.*i);
26 s = math.sin(2.*math.pi/36.*i);
27 if type == 0: # left
28 output = open("%s-%03d-l.r3d" % (sys.argv[1],i), "w")
29 else:
30 output = open("%s-%03d-r.r3d" % (sys.argv[1],i), "w")
31 output.write("Example of material properties and file indirection\n");
32 output.write("80 64 tiles in x,y\n");
33 output.write(" 8 8 pixels (x,y) per tile\n");
34 output.write("4 3x3 virtual pixels -> 2x2 pixels\n");
35 output.write("0 0 0 background colour\n");
36 output.write("T cast shadows\n");
37 output.write("25 Phong power\n");
38 output.write("0.15 secondary light contribution\n");
39 output.write("0.05 ambient light contribution\n");
40 output.write("0.25 specular reflection component\n");
41 output.write("0.0 eye position\n");
42 output.write("1 1 1 main light source position\n");
43 output.write("%lg %lg 0 0 input coordinate, radius transformation\n" % (c, s));
44 output.write("%lg %lg 0 0\n" % (-s, c));
45 if type == 0: #left
46 output.write("0.03 0 1 0\n");
47 else: # right
48 output.write("-0.03 0 1 0\n");
49 output.write("0 0 0 %5.2f\n" % (factor));
50 output.write("3 mixed objects\n");
51 output.write("*\n");
52 output.write("*\n");
53 output.write("*\n");
54 output.close()
55
56for i in range(36):
57 for type in range(2):
58 c = math.cos(2.*math.pi/36.*i);
59 s = math.sin(2.*math.pi/36.*i);
60 if type == 0: # left
61 output = open("%s-%03d-l.r3d" % (sys.argv[1],i+36), "w")
62 else:
63 output = open("%s-%03d-r.r3d" % (sys.argv[1],i+36), "w")
64 output.write("Example of material properties and file indirection\n");
65 output.write("80 64 tiles in x,y\n");
66 output.write(" 8 8 pixels (x,y) per tile\n");
67 output.write("4 3x3 virtual pixels -> 2x2 pixels\n");
68 output.write("0 0 0 background colour\n");
69 output.write("T cast shadows\n");
70 output.write("25 Phong power\n");
71 output.write("0.15 secondary light contribution\n");
72 output.write("0.05 ambient light contribution\n");
73 output.write("0.25 specular reflection component\n");
74 output.write("0.0 eye position\n");
75 output.write("1 1 1 main light source position\n");
76 output.write("%lg 0 %lg 0 input coordinate, radius transformation\n" % (c, s));
77 output.write("0 1 0 0\n");
78 if type == 0: #left
79 output.write("%lg 0 %lg 0\n" % (-s+0.03, c));
80 else: # right
81 output.write("%lg 0 %lg 0\n" % (-s-0.03, c));
82 output.write("0 0 0 %5.2f\n" % (factor));
83 output.write("3 mixed objects\n");
84 output.write("*\n");
85 output.write("*\n");
86 output.write("*\n");
87 output.close()
88
89for i in range(36):
90 for type in range(2):
91 c = math.cos(2.*math.pi/36.*i);
92 s = math.sin(2.*math.pi/36.*i);
93 if type == 0: # left
94 output = open("%s-%03d-l.r3d" % (sys.argv[1],i+72), "w")
95 else:
96 output = open("%s-%03d-r.r3d" % (sys.argv[1],i+72), "w")
97 output.write("Example of material properties and file indirection\n");
98 output.write("80 64 tiles in x,y\n");
99 output.write(" 8 8 pixels (x,y) per tile\n");
100 output.write("4 3x3 virtual pixels -> 2x2 pixels\n");
101 output.write("0 0 0 background colour\n");
102 output.write("T cast shadows\n");
103 output.write("25 Phong power\n");
104 output.write("0.15 secondary light contribution\n");
105 output.write("0.05 ambient light contribution\n");
106 output.write("0.25 specular reflection component\n");
107 output.write("0.0 eye position\n");
108 output.write("1 1 1 main light source position\n");
109 output.write("1 0 0 0 input coordinate, radius transformation\n");
110 output.write("0 %lg %lg 0\n" % (c, s));
111 if type == 0: #left
112 output.write("0.03 %lg %lg 0\n" % (-s, c));
113 else: # right
114 output.write("-0.03 %lg %lg 0\n" % (-s, c));
115 output.write("0 0 0 %5.2f\n" % (factor));
116 output.write("3 mixed objects\n");
117 output.write("*\n");
118 output.write("*\n");
119 output.write("*\n");
120 output.close()
121
Note: See TracBrowser for help on using the repository browser.