15 |
|
|
16 |
self.mode = 255 |
self.mode = 255 |
17 |
self.combiners = "Enable" |
self.combiners = "Enable" |
18 |
|
|
19 |
|
self.border = 0.2 |
20 |
|
self.w, self.h = 2, 1.5 |
21 |
self.initirregu() |
self.initirregu() |
22 |
|
|
23 |
self.x1, self.y1 = 600, 450 |
self.x1, self.y1 = 600, 450 |
24 |
|
self.xs, self.ys = 200, 100 |
25 |
|
self.scale = 1 |
26 |
|
|
27 |
def initirregu(self): |
def initirregu(self): |
|
w = 2 |
|
28 |
|
|
29 |
self.white = getDListNocoords("Color 1 1 1") |
self.white = getDListNocoords("Color 1 1 1") |
30 |
self.black = getDListNocoords("Color 0 0 0") |
self.black = getDListNocoords("Color 0 0 0") |
31 |
|
|
32 |
# Setup texgen for TEXTURE1 so that [-w,w]x[-1,1] in cs2 is mapped |
w = self.w |
33 |
# into [.25,75]^2 (center box of a 4x4 texture) |
h = self.h |
|
iw = .25 / w |
|
34 |
self.mask = getDList(""" |
self.mask = getDList(""" |
|
#ActiveTexture TEXTURE1 |
|
|
#TexGen S TEXTURE_GEN_MODE EYE_LINEAR |
|
|
#TexGen S EYE_PLANE %(iw)s 0 0 .5 |
|
|
#Enable TEXTURE_GEN_S |
|
|
#TexGen T TEXTURE_GEN_MODE EYE_LINEAR |
|
|
#TexGen T EYE_PLANE 0 .25 0 .5 |
|
|
#Enable TEXTURE_GEN_T |
|
|
#ActiveTexture TEXTURE0 |
|
35 |
Begin LINE_LOOP |
Begin LINE_LOOP |
36 |
Vertex -%(w)s -1 |
Vertex -%(w)s -%(h)s |
37 |
Vertex -%(w)s +1 |
Vertex -%(w)s +%(h)s |
38 |
Vertex +%(w)s +1 |
Vertex +%(w)s +%(h)s |
39 |
Vertex +%(w)s -1 |
Vertex +%(w)s -%(h)s |
40 |
End |
End |
41 |
""" % locals()) |
""" % locals()) |
42 |
|
|
81 |
""" % (boxtex.getTexId(), tex.getTexId(), self.combiners) |
""" % (boxtex.getTexId(), tex.getTexId(), self.combiners) |
82 |
|
|
83 |
|
|
84 |
self.iq = GZZGL.createIrregularQuad(.2, w, 0, code) |
self.iq = GZZGL.createIrregularQuad(self.border, self.w, self.h, 0, code) |
85 |
self.iq2 = GZZGL.createIrregularQuad(.2, w, 1, code) |
self.iq2 = GZZGL.createIrregularQuad(self.border, self.w, self.h, 1, code) |
86 |
|
|
87 |
def key(self, k): |
def key(self, k): |
88 |
if 0: pass |
if 0: pass |
90 |
elif k == "Down": self.y1 += 50 |
elif k == "Down": self.y1 += 50 |
91 |
elif k == "Left": self.x1 -= 50 |
elif k == "Left": self.x1 -= 50 |
92 |
elif k == "Right": self.x1 += 50 |
elif k == "Right": self.x1 += 50 |
93 |
|
elif k == "x": self.xs += 50 |
94 |
|
elif k == "X": self.xs -= 50 |
95 |
|
elif k == "y": self.ys += 50 |
96 |
|
elif k == "Y": self.ys -= 50 |
97 |
|
elif k == "+": self.scale += .1 |
98 |
|
elif k == "-": self.scale -= .1 |
99 |
elif k == "c": |
elif k == "c": |
100 |
if self.combiners == "Enable": |
if self.combiners == "Enable": |
101 |
self.combiners = "Disable" |
self.combiners = "Disable" |
102 |
else: |
else: |
103 |
self.combiners = "Enable" |
self.combiners = "Enable" |
104 |
self.initirregu() |
self.initirregu() |
105 |
|
elif k == "w": self.w += .1; self.initirregu() |
106 |
|
elif k == "W": self.w -= .1; self.initirregu() |
107 |
|
elif k == "h": self.h += .1; self.initirregu() |
108 |
|
elif k == "H": self.h -= .1; self.initirregu() |
109 |
|
elif k == "b": self.border += .01; self.initirregu() |
110 |
|
elif k == "B": self.border -= .01; self.initirregu() |
111 |
elif "1" <= k <= "9": |
elif "1" <= k <= "9": |
112 |
self.mode ^= 1 << (int(k)-1) |
self.mode ^= 1 << (int(k)-1) |
113 |
print "mode=", self.mode |
print "mode=", [ (".","X")[(self.mode >> i) & 1] for i in range(0, 9) ] |
114 |
pass |
pass |
115 |
|
|
116 |
def scene(self, vs): |
def scene(self, vs): |
117 |
putnoc(vs, background((0.1,0.4,0.5))) |
putnoc(vs, background((0.1,0.4,0.5))) |
118 |
|
|
119 |
|
#putnoc(vs, getDListNocoords("Translate -1000 -1000 0\nScale 4 4 4\n")) |
120 |
|
|
121 |
cs1 = vs.coords.affineCoordsys(0, "1", 10, self.x1, self.y1, 200, 0, 0, 100) |
cs1 = vs.coords.affineCoordsys(0, "1", 10, self.x1, self.y1, self.xs, 0, 0, self.ys) |
122 |
cs2 = vs.coords.affineCoordsys(0, "2", 10, 600, 450, 150, 32.3, -14.2, 150) |
cs2 = vs.coords.affineCoordsys(0, "2", 10, 600, 450, |
123 |
|
self.scale * 150, |
124 |
|
self.scale * 32.3, |
125 |
|
self.scale * -14.2, |
126 |
|
self.scale * 150) |
127 |
#vs.map.put(self.mask, cs2) |
#vs.map.put(self.mask, cs2) |
128 |
|
|
129 |
|
if self.mode & 4: |
130 |
|
vs.map.put(self.mask, cs2) |
131 |
|
|
132 |
if self.mode & 1: |
if self.mode & 1: |
133 |
putnoc(vs, self.black); |
putnoc(vs, self.black); |
134 |
vs.map.put(self.iq2, cs1, cs2) |
vs.map.put(self.iq2, cs1, cs2) |