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

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

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

revision 1.3 by jvk, Wed Sep 11 13:44:54 2002 UTC revision 1.4 by jvk, Thu Sep 12 14:52:27 2002 UTC
# Line 2  from __future__ import nested_scopes Line 2  from __future__ import nested_scopes
2    
3  execfile("gfx/libpaper/papermill.py")  execfile("gfx/libpaper/papermill.py")
4    
5    
6    pdfimg = "mstmpimg/0000000008000000E9377484930004EE0856BC11F38551006325788A14C474081350DF47A8280C-144-1"
7    pdftex = None
8    showpdf = 0
9    
10    def globalkey(k):
11        global benchmark
12        global currentScene
13        if k == "d":
14            global dbg
15            dbg = not dbg
16    
17    
18    def addpdftex(pap):
19        passno = pap.getNPasses()
20        pap.setNPasses(passno + 1)
21        ppass = pap.getPass(passno)
22    
23        global pdftex
24        if pdftex == None:
25            pdftex = getTex(pdfimg)
26        texid = pdftex.getTexId()
27    
28        ppass.setSetupcode("""
29            PushAttrib ENABLE_BIT TEXTURE_BIT        
30            ActiveTexture TEXTURE0
31            Enable BLEND
32            BlendFunc ZERO SRC_COLOR
33            Disable DEPTH_TEST
34            Color 1 1 1
35            Enable TEXTURE_2D
36            Disable ALPHA_TEST
37    
38            BindTexture TEXTURE_2D %(texid)s
39            TexParameter TEXTURE_2D TEXTURE_WRAP_S REPEAT
40            TexParameter TEXTURE_2D TEXTURE_WRAP_T REPEAT
41            TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
42            TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
43        """ % locals())
44    
45        ppass.setTeardowncode("""
46            PopAttrib
47        """)
48    
49        ppass.setNTexGens(1)
50        ppass.putNormalTexGen(0, [.2,0,0,.25,
51                                  0,.2,0,.2,
52                                  0,0,1,0,
53                                  0,0,0,1])
54        
55    
56        
57    
58  def getfisheyepaper(seed):  def getfisheyepaper(seed):
59      pap = ThePaperMill().getPaper(seed)      pap = ThePaperMill().getPaper(seed)
     #print "Pq: ",seed  
     return GZZGL.createFisheyePaperQuad(pap, -1, -1, 1, 1)  
60    
61        global showpdf
62        if showpdf:
63            addpdftex(pap)
64    
65        pfq = GZZGL.createFisheyePaperQuad(pap, -1, -1, 1, 1)
66    
67        return pfq
68    
69  bx = 600  bx = 600
70  by = 450  by = 450
71  bs = .15  bs = .2
72  ba = 0  ba = 0
73  bl = 0  bl = 0
74    bm = 2
75    
76  rng = java.util.Random()  rng = java.util.Random()
77    
# Line 22  class FisheyeScene: Line 81  class FisheyeScene:
81          self.seed = 0          self.seed = 0
82          self.initpaper()          self.initpaper()
83    
84            self.renderPaper = 1
85    
86      def initpaper(self):      def initpaper(self):
87          self.fpq = getfisheyepaper(self.seed);          self.fpq = getfisheyepaper(self.seed);
88    
89      def key(self, k):      def key(self, k):
90          global bx, by, bs, ba, bl          global bx, by, bs, ba, bl, bm
91          if k == "Up": by -= 100          if k == "Up": by -= 100
92          elif k == "Down": by += 100          elif k == "Down": by += 100
93          elif k == "Left": bx -= 100          elif k == "Left": bx -= 100
94          elif k == "Right": bx += 100          elif k == "Right": bx += 100
95          elif k == "+": bs += .05          elif k == "+": bs += .05; print "bs ", bs
96          elif k == "-": bs -= .05          elif k == "-": bs -= .05; print "bs ", bs
97          elif k == "a": ba += .2          elif k == "a": ba += .2; print "ba ", ba
98          elif k == "A": ba -= .2          elif k == "A": ba -= .2; print "ba ", ba
99          elif k == "l": bl += .1          elif k == "l": bl += .1; print "bl ", bl
100          elif k == "L": bl -= .1          elif k == "L": bl -= .1; print "bl ", bl
101            elif k == "m": bm += .5; print "bm ", bm
102            elif k == "M": bm -= .5; print "bm ", bm
103          elif k == "v":          elif k == "v":
104              self.seed = rng.nextInt(2000000000)              self.seed = rng.nextInt(2000000000)
105              self.initpaper()              self.initpaper()
106              AbstractUpdateManager.setNoAnimation()              AbstractUpdateManager.setNoAnimation()
107            elif k == "p":
108                global showpdf
109                showpdf = not showpdf
110                self.initpaper()
111                AbstractUpdateManager.setNoAnimation()
112    
113      def scene(self, vs):      def scene(self, vs):
114          putnoc(vs, background(self.bgcolor))          putnoc(vs, background(self.bgcolor))
115    
116          cs1 = vs.coords.affineCoordsys(0, "1", 10, 600, 450, 400, 0, 0, 400)          cs1 = vs.coords.affineCoordsys(0, "1", 10, 600, 450, 400, 0, 0, 400)
117    
118          cs2 = vs.coords.affineCoordsys(0, "2", 10, bx, by,          cs2 = vs.coords.affineCoordsys(0, "2", 10 - bm, bx, by,
119                                         400 * bs * math.exp(+bl) * math.cos(ba),                                         400 * bs * math.exp(+bl) * math.cos(ba),
120                                         400 * bs * math.exp(+bl) * math.sin(ba),                                         400 * bs * math.exp(+bl) * math.sin(ba),
121                                         400 * bs * math.exp(-bl) *-math.sin(ba),                                         400 * bs * math.exp(-bl) *-math.sin(ba),

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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