gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz ./TODO gfx/demo/fillet/zbuffer.py gfx/demo/...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz ./TODO gfx/demo/fillet/zbuffer.py gfx/demo/...
Date: Mon, 23 Dec 2002 05:34:51 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/12/23 05:34:51

Modified files:
        .              : TODO 
        gfx/demo/fillet: zbuffer.py 
        gfx/demo/paper : combiners.py combinerutil.py 
        gfx/util       : demo.py demokeys.py misc.py 
        test/gzz/gfx/gl: glvobcoorder.test 
        test/gzz/vob   : vobcoorder.test 

Log message:
        Demo fixes

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.469&tr2=1.470&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/fillet/zbuffer.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/paper/combiners.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/paper/combinerutil.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/util/demo.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/util/demokeys.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/util/misc.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/gfx/gl/glvobcoorder.test.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/vob/vobcoorder.test.diff?tr1=1.10&tr2=1.11&r1=text&r2=text

Patches:
Index: gzz/TODO
diff -u gzz/TODO:1.469 gzz/TODO:1.470
--- gzz/TODO:1.469      Fri Dec 20 11:00:20 2002
+++ gzz/TODO    Mon Dec 23 05:34:51 2002
@@ -51,12 +51,14 @@
            - less pages 
     tjl:
        + return ANKOS to Agora [ blocked by: waiting for trip to agora ]
+       - move lots of stuff to lava and basalt
        - go through most important GL demos and redo the interfaces
          and document
            - paper
                - register combiners: separate nv combiner source, show in 
                  demos.
                    - not in hash at first
+               - combine single- and multipaper -scenes
            - xupdf
                - fix for new buoys
            - irregu 
Index: gzz/gfx/demo/fillet/zbuffer.py
diff -u gzz/gfx/demo/fillet/zbuffer.py:1.4 gzz/gfx/demo/fillet/zbuffer.py:1.5
--- gzz/gfx/demo/fillet/zbuffer.py:1.4  Fri Dec 20 11:00:21 2002
+++ gzz/gfx/demo/fillet/zbuffer.py      Mon Dec 23 05:34:51 2002
@@ -15,13 +15,14 @@
        initConnTexs()
        self.ind = 5
 
+       self.cellTexs = cellTexs
        self.key = KeyPresses(self,
 Toggle("rotate", 0, "rotation to show Z-buffer use", "p"),
 Toggle("conn", 1, "drawing of connection", "k", noAnimation = 1),
 Toggle("color", 0, "coloring of the connecting segment", "v", noAnimation = 1),
 Toggle("movel", 0, "shifting one of the rectangles", "s"),
 Toggle("polymode", 0, "drawing polygons or only their edges", "m", noAnimation 
= 1),
-ListIndex("ind", cellTexs, 0, "fillet type", "<", ">", noAnimation = 1),
+ListIndex("ind", "cellTexs", 0, "fillet type", "<", ">", noAnimation = 1),
        )
     def scene(self, vs):
        d = vs.getSize()
Index: gzz/gfx/demo/paper/combiners.py
diff -u gzz/gfx/demo/paper/combiners.py:1.2 gzz/gfx/demo/paper/combiners.py:1.3
--- gzz/gfx/demo/paper/combiners.py:1.2 Fri Dec 20 11:00:21 2002
+++ gzz/gfx/demo/paper/combiners.py     Mon Dec 23 05:34:51 2002
@@ -2,50 +2,32 @@
 from combinerutil import *
 
 from gfx.libutil import saveanim
+from gfx.util.demokeys import *
+from gfx.util import misc
+
 
 class Scene:
-    """Show some basis textures and what combiner operations result.
+    """Show some basis textures and what the NV10 register combiners can do 
with them.
     """
     def __init__(self):
        self.bgcolor = (0.7, 0.8, 0.6)
        self.pt = PaperTemplate()
-       self.tex0comb = "RGB0"
-       self.tex1comb = "RGB1"
 
        self.isectcomb = "BAND0"
-    def key(self, k):
-        if k == "F1":
-            list = texcodes.keys()
-            self.tex0comb = list[(list.index(self.tex0comb) + 1) % len(list)]
-            print "Using", self.tex0comb, self.isectcomb, self.tex1comb, 
"combiners"
-           print texcodes[self.tex0comb]
-           AbstractUpdateManager.setNoAnimation()
-        elif k == "F3":
-            list = texcodes.keys()
-            self.tex1comb = list[(list.index(self.tex1comb) + 1) % len(list)]
-            print "Using", self.tex0comb, self.isectcomb, self.tex1comb, 
"combiners"
-           print texcodes[self.tex1comb]
-           AbstractUpdateManager.setNoAnimation()
-        elif k == "c":
-            list = texcodes.keys()
-           list.sort()
-            self.isectcomb = list[(list.index(self.isectcomb) + 1) % len(list)]
-            print "Using", self.tex0comb, self.isectcomb, self.tex1comb, 
"combiners"
-           print texcodes[self.isectcomb]
-           AbstractUpdateManager.setNoAnimation()
-        elif k == "C":
-            list = texcodes.keys()
-           list.sort()
-            self.isectcomb = list[(list.index(self.isectcomb) - 1) % len(list)]
-           AbstractUpdateManager.setNoAnimation()
-       else:
-           self.pt.key(k)
+
+       self.combinercodes = [e[0] for e in texcodesList if e[0] != "NONE"]
+       self.key = KeyPresses(self,
+ListIndex("ccind", "combinercodes", 0, "combiner code for intersection 
region", "<", ">", 
+                   noAnimation = 1),
+       )
+       # else:
+       #     self.pt.key(k)
            
     def scene(self, vs):
        putnoc(vs, background(self.bgcolor))
 
        cs = vs.orthoCS(0, "S1", 0, 100, 100, 200, 200)
-       self.pt.place(vs, cs, self.tex0comb, self.isectcomb, self.tex1comb)
+       self.pt.place(vs, cs, "RGB0", self.combinercodes[self.ccind], "RGB1")
 
         for i in range(0,3):
             cs = vs.coords.affineCoordsys(0, 10, 600 + (i-1)*150, 80, 50, 0, 
0, 50)
@@ -54,3 +36,12 @@
             cq = coloredQuad((col[0], col[1], col[2]))
             vs.map.put(cq, cs)
             vs.map.put(self.pt.frame, cs)
+
+       tcs = vs.orthoCS(0, "TXT", 0, 500, 300, 1, 1)
+       vs.map.put(getDListNocoords("""
+           Disable REGISTER_COMBINERS_NV
+           Color 0 0 0 1
+           Disable ALPHA_TEST
+           Enable TEXTURE_2D
+       """))
+       misc.putMultilineText (vs, tcs, 
texcodes[self.combinercodes[self.ccind]], 20)
Index: gzz/gfx/demo/paper/combinerutil.py
diff -u gzz/gfx/demo/paper/combinerutil.py:1.2 
gzz/gfx/demo/paper/combinerutil.py:1.3
--- gzz/gfx/demo/paper/combinerutil.py:1.2      Fri Dec 20 11:00:21 2002
+++ gzz/gfx/demo/paper/combinerutil.py  Mon Dec 23 05:34:51 2002
@@ -1,6 +1,7 @@
 from __future__ import nested_scopes
 from gfx.libutil import nvcode
 from gfx.util.misc import *
+from gfx.util.demokeys import *
 
 def shootImages():
     pt = PaperTemplate()
@@ -33,25 +34,27 @@
 
 passmask = [ 1, 0, 0, 0 ]
 
-texcodes = {
-    "NONE" :  nvcode.parseCombiner("""
+texcodesList = [
+(    "NONE" ,"""
     alpha = 0
     """),
-    "RGB0" : nvcode.parseCombiner("""
+(    "RGB0" ,"""
     color = TEX0
     alpha = 1
     """),
-    "RGB1" : nvcode.parseCombiner("""
+(    "RGB1" ,"""
     color = TEX1
     alpha = 1
     """),
-    "DOT" : nvcode.parseCombiner("""
-
-    SPARE0 = (2*TEX0-1).(2*COL0-1)
+(    "DOT" ,"""
+    # Dot product between TEX0 and a constant
+    SPARE0 = (2*TEX0-1).(2*CONST0-1)
     color = SPARE0
 
     """),
-    "BAND0" : nvcode.parseCombiner("""
+(    "BAND0" ,"""
+       
+       # Dot product between the two texture values
        SPARE0 = ((2*TEX0-1) . (2*TEX1-1)) * 2
 
        SPARE0 = (+SPARE0) + (.5)
@@ -59,35 +62,32 @@
        color = SPARE0
        alpha = 1
     """),
-    "BAND1" : nvcode.parseCombiner("""
+(    "BAND1" ,"""
+       # Dot product between the two texture values
        SPARE0 = ((2*TEX0-1) . (2*TEX1-1)) * 4
 
+       # Square to select a narrow band
        SPARE0 = ((+SPARE0)*(+SPARE0)) * 2
 
        color = SPARE0
        alpha = 1
     """),
-    "BAND1_X" : nvcode.parseCombiner("""
+(    "BAND1_X" ,"""
+       # Dot product between the two texture values
        SPARE0 = ((2*TEX0-1) . (2*TEX1-1)) * 4
 
+       # Square to select a narrow band
        SPARE0 = ((+SPARE0)*(+SPARE0)) * 2
 
+       # Interpolate between the color values
        color = SPARE0*COL0 + (1-SPARE0)*COL1
        alpha = 1
     """),
 
-    "BAND2" : nvcode.parseCombiner("""
-       SPARE0 = ((2*TEX0-1) . (2*TEX1-1)) * 4
-       SPARE1 = ((2*TEX0-1).(2*CONST0-1)) * 4
-       SPARE1.a = ((TEX1.a)+(.5-TEX0.a)) * 4
-
-       SPARE0 = ((+SPARE0)*(+SPARE0)) * 2
-       SPARE1 = ((SPARE1.a) * (SPARE1.a)) * 2
-
-       color = SPARE0 * SPARE1
-       alpha = 1
-    """),
-    "BAND3" : nvcode.parseCombiner("""
+(    "BAND3" ,"""
+       # Same as before, now modulate the
+       # dot product with some values 
+       # depending on a dot product of TEX0.
        SPARE0 = ((2*TEX0-1) . (2*TEX1-1)) * 4
        SPARE1 = ((2*TEX0-1).(2*CONST0-1)) * 4
        SPARE1.a = ((TEX1.blue)*(TEX0.blue)) * 4
@@ -99,50 +99,15 @@
        color = EF*COL0 + (1-EF)*COL1
        alpha = 1
     """),
-    "SHAPEX_2" : nvcode.parseCombiner("""
-       SPARE0 = ((TEX0) * (2*TEX1-1)) * 4
+]
 
-       SPARE0 = ((SPARE0).(CONST0)) * 1
+texcodes = { }
+parsedTexcodes = { }
+for e in texcodesList: 
+    code = "# "+e[0]+"\n"+e[1]
+    texcodes[e[0]] = code
+    parsedTexcodes[e[0]] = nvcode.parseCombiner(code)
 
-       color = SPARE0 
-       alpha = 1
-    """),
-    "SHAPEX_3" : nvcode.parseCombiner("""
-       SPARE0 = ((2*TEX0-1) * (2*TEX1-1)) * 4
-       SPARE1.a = ((TEX1.blue)*(TEX0.blue)) * 4
-
-       SPARE0 = ((+SPARE0).(2*CONST0-1)) * 1
-       COL0 = COL0 * (SPARE1.a)
-        SPARE1.a = (1-SPARE1.a) * SPARE0.b
-
-       EF = FOG * SPARE1.a
-       color = SPARE0 * COL0 + (1-SPARE0) * COL1 + EF
-       alpha = 1
-    """),
-    "SHAPEX_3B" : nvcode.parseCombiner("""
-       SPARE0 = ((2*TEX0-1) * (2*TEX1-1)) * 1
-       SPARE1 = COL0 * TEX0.a
-
-       SPARE0 = ((2*SPARE0-1).(2*CONST0-1)) * 1
-       COL0 = FOG * (1-TEX0.a) 
-
-       EF = SPARE0 * SPARE1
-       color = SPARE0 * COL0 + (1-SPARE0) * COL1 + EF
-       alpha = 1
-    """),
-    "SHAPEX_3C" : nvcode.parseCombiner("""
-        SPARE1 = (2*TEX0-1) * (2*TEX1-1)
-        SPARE0 = FOG * (1 - TEX0.a)
-        TEX0.a = (TEX0.a * (.5)) * .5
-
-        SPARE1 = ((+SPARE1).(2*CONST0-1)) * 4
-        COL1 = (COL1 * TEX0.a) * 4
-
-        EF = SPARE1 * SPARE1
-        color = EF * SPARE0_PLUS_COL1 + (1-EF) * COL0
-        alpha = 1
-    """),
-}
 
 
 def getpaper(vecs, cols, x0, y0, x1, y1, t0, t1, tex0comb, isectcomb, 
tex1comb):
@@ -198,15 +163,14 @@
 
     return GLRen.createBasisPaperQuad(pap, 0, 0, x0, y0,
                                0, 0, x1, y1,
-                                      constcode + texcodes[tex0comb],
-                                      constcode + texcodes[tex1comb],
-                                      constcode + texcodes[isectcomb])
+                                      constcode + parsedTexcodes[tex0comb],
+                                      constcode + parsedTexcodes[tex1comb],
+                                      constcode + parsedTexcodes[isectcomb])
 
 rng = java.util.Random()
 
 class PaperTemplate:
     def __init__(self):
-       self.deltac = .01
         self.vecseed0 = 0
         self.vecseed1 = 1
         self.colseed = 2
@@ -231,6 +195,14 @@
        Vertex 1 0
        End
         """)
+
+       keys = [
+Action("Select random new colors", "c", lambda *args: self.randColors()),
+Action("Select random dot-product vector 1", "1", lambda *args: 
self.randvec(0)),
+Action("Select random dot-product vector 2", "2",  lambda *args: 
self.randvec(1)),
+SlideLin("x0",  .12, .01, "Move area 1", "Left", "Right"),
+SlideLin("y0",  .02, .01, "Move area 1", "Left", "Right"),
+       ]
     def initvecs(self):
         colors = Colors(self.vecseed0)
         r0 = colors.getNVDP3VecStr(0)
@@ -245,23 +217,20 @@
        self.cols = [ colors.getColorStr(colorbase+i)
                       for i in range(0,4) ]
 
-    def key(self, k):
-        if k == "v":
+    def randColors(self):
+       self.colseed = rng.nextInt(2000000000)
+       self.initcols()
+       
+    def randVec(self, ind):
+       if ind == 0:
             self.vecseed0 = rng.nextInt(2000000000)
+       else:
             self.vecseed1 = rng.nextInt(2000000000)
-            self.colseed = rng.nextInt(2000000000)
-            self.initvecs()
-            self.initcols()
-        elif k == "1":
-            self.vecseed0 = rng.nextInt(2000000000)
-            self.initvecs()
-        elif k == "3":
-            self.vecseed1 = rng.nextInt(2000000000)
-            self.initvecs()
-        elif k == "2":
-            self.colseed = rng.nextInt(2000000000)
-            self.initcols()
-        elif k == "F4":
+       self.initvecs()
+       return
+
+       # XXX
+        if k == "F4":
             self.texgen0 = TexGenXYRepeatUnit(rnd=rng)
         elif k == "F5":
             self.texgen1 = TexGenXYRepeatUnit(rnd=rng)
Index: gzz/gfx/util/demo.py
diff -u gzz/gfx/util/demo.py:1.7 gzz/gfx/util/demo.py:1.8
--- gzz/gfx/util/demo.py:1.7    Thu Dec 19 10:02:33 2002
+++ gzz/gfx/util/demo.py        Mon Dec 23 05:34:51 2002
@@ -177,11 +177,6 @@
     def timeout(self, o):
        print str(System.currentTimeMillis()) + " TIMEOUT ",o
        currentScene.timeout(o)
-# class Scr(AbstractUpdateManager.Window):
-#     def __init__(self, w):
-#      b = Bindings()
-#      w.registerBinder(b)
-#     def
 
 def addHelp(vs):
     def d(obj): 
Index: gzz/gfx/util/demokeys.py
diff -u gzz/gfx/util/demokeys.py:1.4 gzz/gfx/util/demokeys.py:1.5
--- gzz/gfx/util/demokeys.py:1.4        Fri Dec 20 11:00:21 2002
+++ gzz/gfx/util/demokeys.py    Mon Dec 23 05:34:51 2002
@@ -103,13 +103,13 @@
 class ListIndex(_Presses):
     """A key or a pair of keys used to move on a list of alternatives.
     """
-    def __init__(self, attr, list, default, description, keydown, keyup, 
**opts):
+    def __init__(self, attr, listattr, default, description, keydown, keyup, 
**opts):
        _Presses.__init__(self, opts, 
            (keydown , lambda *args: self.move(-1, *args)),
            (keyup , lambda *args: self.move(1, *args)),
            )
        self.attr = attr
-       self.list = list
+       self.listattr = listattr
        self.default = default
        self.descline = self.keyStrings() + ": Select " + description
 
@@ -118,12 +118,13 @@
 
     def move(self, dir, scene, key):
        v = getattr(scene, self.attr)
+       l = getattr(scene, self.listattr)
        v += dir
-       v = v % len(self.list)
+       v = v % len(l)
        setattr(scene, self.attr, v)
 
 
-class SlideLog(_Presses):
+class _Slide(_Presses):
     """A pair of keys used to move a log slider up&down.
     """
     def __init__(self, attr, default, description, keydown, keyup, **opts):
@@ -138,6 +139,10 @@
     def prepare(self, scene):
        setattr(scene, self.attr, self.default)
 
+class SlideLog(_Slide):
+    def __init__(*args):
+       _Slide.__init__(*args)
+
     def move(self, dir, scene, key):
        v = getattr(scene, self.attr)
        if dir > 0:
@@ -146,6 +151,24 @@
            v /= 1.1
        print "SlideLog: ",v
        setattr(scene, self.attr, v)
+
+
+class SlideLin(_Slide):
+    def __init__(self, attr, default, delta, description, keydown, keyup, 
**opts):
+       _Slide.__init__(self, attr, default, description, keydown, keyup, 
**opts)
+       self.delta = delta
+
+    def move(self, dir, scene, key):
+       v = getattr(scene, self.attr)
+       if dir > 0:
+           v += self.delta
+       else:
+           v -= self.delta
+       print "SlideLin: ",v
+       setattr(scene, self.attr, v)
+
+
+
 
 
 
Index: gzz/gfx/util/misc.py
diff -u gzz/gfx/util/misc.py:1.4 gzz/gfx/util/misc.py:1.5
--- gzz/gfx/util/misc.py:1.4    Mon Dec  9 05:05:13 2002
+++ gzz/gfx/util/misc.py        Mon Dec 23 05:34:51 2002
@@ -99,6 +99,12 @@
         PopAttrib
     """))
 
+def putMultilineText(vs, cs, text, rowheight):
+    y = 0
+    for line in text.split("\n"):
+       c = vs.orthoCS(cs, str(y), 0, 0, y, rowheight, rowheight)
+       vs.map.put(getText(line), c)
+       y += rowheight
 
 def js(list):
     return " ".join([str(el) for el in list])
Index: gzz/test/gzz/gfx/gl/glvobcoorder.test
diff -u gzz/test/gzz/gfx/gl/glvobcoorder.test:1.28 
gzz/test/gzz/gfx/gl/glvobcoorder.test:1.29
--- gzz/test/gzz/gfx/gl/glvobcoorder.test:1.28  Thu Dec 19 04:12:39 2002
+++ gzz/test/gzz/gfx/gl/glvobcoorder.test       Mon Dec 23 05:34:51 2002
@@ -273,4 +273,21 @@
     putThings()
     checkAvgColor(10, 10, 80, 80, (255, 0, 0), delta=50)
 
+def testInterpolateType():
+    """Test that cses of different types get interpolated
+    """
+    cs1 = vs.affineCS(0, "FOO", 0, 0, 0, 2, 0, 0, 2)
+
+    vs2 = getvs()
+    cs2 = vs2.rotateCS(0, "FOO", 90)
+
+    interp = vs.matcher.interpList(vs2.matcher)
+    interp[0] = len(interp)
+    failUnlessEqual(interp[cs1], cs2)
+    checkInterp(vs, vs2, interp , 0, cs1, [0, 1, 0], [0, 2, 0])
+    checkInterp(vs, vs2, interp , 1, cs1, [0, 1, 0], [-1, 0, 0])
+    checkInterp(vs, vs2, interp , .5, cs1, [0, 1, 0], [-.5, 1, 0])
+
+    
+
 # : vim: set syntax=python :
Index: gzz/test/gzz/vob/vobcoorder.test
diff -u gzz/test/gzz/vob/vobcoorder.test:1.10 
gzz/test/gzz/vob/vobcoorder.test:1.11
--- gzz/test/gzz/vob/vobcoorder.test:1.10       Fri Dec 20 11:00:21 2002
+++ gzz/test/gzz/vob/vobcoorder.test    Mon Dec 23 05:34:51 2002
@@ -130,7 +130,7 @@
 
     checkInterp(vs, vs2, interp , .5, cs1_1, [0, 0, 0], [175, 175, 0])
 
-def testInterpolateAlways():
+def testInterpolateOutsideHierarchy():
     """Test that vobs always get interpolated, even when hierarchy changes.
     """
     cs1 = c.translate(0, 100, 100, 0)
@@ -146,7 +146,6 @@
     interp[0] = len(interp)
     failUnlessEqual(interp[cs1_1], cs2)
     checkInterp(vs, vs2, interp , .5, cs1_1, [0, 0, 0], [175, 125, 0])
-
 
     
 # : vim: set syntax=python :



reply via email to

[Prev in Thread] Current Thread [Next in Thread]