/[gzz]/gzz/gfx/demo/paperbasis.py
ViewVC logotype

Diff of /gzz/gfx/demo/paperbasis.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by jvk, Mon Sep 16 06:14:41 2002 UTC revision 1.7 by jvk, Mon Sep 16 06:44:33 2002 UTC
# Line 11  def globalkey(k): Line 11  def globalkey(k):
11      if k == "d":      if k == "d":
12          global dbg          global dbg
13          dbg = not dbg          dbg = not dbg
14        """
15      if k >= "F5" and k <= "F8":      if k >= "F5" and k <= "F8":
16          i = int(k[1]) - 5          i = int(k[1]) - 5
17          global passmask          global passmask
18          passmask[i] = not passmask[i]          passmask[i] = not passmask[i]
19          print passmask          print passmask
20          currentScene.initpaper()          currentScene.initpaper()
21        """
22    
23  tex0codes = {  tex0codes = {
24      "ALL" : "",      "ALL" : "",
# Line 123  def getpaper(seed, vecseed0 = 0, vecseed Line 124  def getpaper(seed, vecseed0 = 0, vecseed
124    
125  rng = java.util.Random()  rng = java.util.Random()
126    
 x0, y0 = 600, 300  
 x1, y1 = 600, 600  
127    
128  class PaperScene:  class PaperScene:
129      def __init__(self):      def __init__(self):
# Line 136  class PaperScene: Line 135  class PaperScene:
135          self.colseed = 0          self.colseed = 0
136          self.initpaper()          self.initpaper()
137    
138            self.x0, self.y0 = 600, 300
139            self.x1, self.y1 = 600, 450
140            self.texgen0 = TexGenXYRepeatUnit(vecs = [[.5,0], [0,.5]])
141            self.texgen1 = TexGenXYRepeatUnit(vecs = [[.25,.25], [.25,-.25]])
142    
143            self.frame = getDList("""
144            Color 0 0 0
145            Disable TEXTURE_2D
146            Disable DEPTH_TEST
147            Begin LINE_LOOP
148            Vertex -1 -1
149            Vertex -1 1
150            Vertex 1 1
151            Vertex 1 -1
152            End
153            """)
154    
155      def initpaper(self):      def initpaper(self):
156          self.pq = getpaper(self.seed, self.vecseed0, self.vecseed1, self.colseed)          self.pq = getpaper(self.seed, self.vecseed0, self.vecseed1, self.colseed)
157          AbstractUpdateManager.setNoAnimation()          AbstractUpdateManager.setNoAnimation()
158    
159      def key(self, k):      def key(self, k):
160          global tex0comb,tex1comb,isectcomb          global tex0comb,tex1comb,isectcomb
         global x0, y0, x1, y1  
161          oldseed = self.seed          oldseed = self.seed
162          if k == "v":          if k == "v":
163              self.seed = rng.nextInt(2000000000)              self.seed = rng.nextInt(2000000000)
# Line 159  class PaperScene: Line 174  class PaperScene:
174          elif k == "2":          elif k == "2":
175              self.colseed = rng.nextInt(2000000000)              self.colseed = rng.nextInt(2000000000)
176              self.initpaper()              self.initpaper()
177          elif k == "Up": y0 -= 20          elif k == "F4":
178          elif k == "Down": y0 += 20              self.texgen0 = TexGenXYRepeatUnit(rnd=rng)
179          elif k == "Left": x0 -= 20          elif k == "F5":
180          elif k == "Right": x0 += 20              self.texgen1 = TexGenXYRepeatUnit(rnd=rng)
181            elif k == "Up": self.y0 -= 20
182            elif k == "Down": self.y0 += 20
183            elif k == "Left": self.x0 -= 20
184            elif k == "Right": self.x0 += 20
185          elif k == "F1":          elif k == "F1":
186              list = tex0codes.keys()              list = tex0codes.keys()
187              tex0comb = list[(list.index(tex0comb) + 1) % len(list)]              tex0comb = list[(list.index(tex0comb) + 1) % len(list)]
# Line 187  class PaperScene: Line 206  class PaperScene:
206          # [0,1] x [0,1] to vertex coords, cs1 is for the first texture unit          # [0,1] x [0,1] to vertex coords, cs1 is for the first texture unit
207          # and cs2 for the second          # and cs2 for the second
208    
209          cs1 = vs.coords.affineCoordsys(0, "1", 10, x0, y0, 200, 0, 0, 200)          scale = 400
210          cs2 = vs.coords.affineCoordsys(0, "2", 10, x1, y1, 100, 100, 100, -100)          cs1 = vs.coords.affineCoordsys(0, "1", 10, self.x0, self.y0,
211                                           scale * self.texgen0.vecs[0][0],
212                                           scale * self.texgen0.vecs[1][0],
213                                           scale * self.texgen0.vecs[0][1],
214                                           scale * self.texgen0.vecs[1][1])
215            cs2 = vs.coords.affineCoordsys(0, "2", 10, self.x1, self.y1,
216                                           scale * self.texgen1.vecs[0][0],
217                                           scale * self.texgen1.vecs[1][0],
218                                           scale * self.texgen1.vecs[0][1],
219                                           scale * self.texgen1.vecs[1][1])
220    
221          vs.map.put(self.pq, cs1, cs2)          vs.map.put(self.pq, cs1, cs2)
222            vs.map.put(self.frame, cs1)
223            vs.map.put(self.frame, cs2)
224    
225  currentScene = PaperScene()          currentScene = PaperScene()        

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26