gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx/demo irregu4.py papertest.py


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx/demo irregu4.py papertest.py
Date: Sat, 30 Nov 2002 04:23:57 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/11/30 04:23:57

Modified files:
        gfx/demo       : irregu4.py papertest.py 

Log message:
        Add "p" key for making irregu motion screenshot

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu4.py.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/papertest.py.diff?tr1=1.54&tr2=1.55&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregu4.py
diff -u gzz/gfx/demo/irregu4.py:1.23 gzz/gfx/demo/irregu4.py:1.24
--- gzz/gfx/demo/irregu4.py:1.23        Mon Nov 25 07:59:58 2002
+++ gzz/gfx/demo/irregu4.py     Sat Nov 30 04:23:57 2002
@@ -1,6 +1,8 @@
 from gfx.libutil.nvcode import combinercode, parseCombiner
 from gfx.libpaper.texcache import getCachedTexture
 from math import sin,cos
+from gfx.libutil import saveanim
+
 
 from gfx.libpaper.papermill import ThePaperMill
 
@@ -61,33 +63,21 @@
         shade_all_levels = 1)
 
 inittex()
-    
-class IrreguScene:
-    def __init__(self):
-        self.bg = background((0.7,0.7,1.0))
 
-        self.a1 = 0
-        self.tx = 0
-        self.ty = 0
-        self.x1 = 0
-        self.y1 = 0
-        self.xs = 1
-        self.ys = 1
-        self.x0 = 0
-        self.y0 = 0
-        self.scale = 150
-        self.shape = 0
-        self.texslicing = 0
-        self.flags = 127
 
-        self.initcode()
+# Irregu flags
+Y_COLOR       = 1;
+Y_SECCOLOR    = 2;
+DOTVEC_COLOR  = 4;
+INTERP_DOTVEC = 8;
+SLICE_1D      = 16;
+SLICE_2D      = 32;
+SHIFTS        = 64;
+INSIDE        = 128;
 
-        self.depthmask0 = getDListNocoords("DepthMask 0")
-        self.depthmask1 = getDListNocoords("DepthMask 1")
-        self.depthtest0 = getDListNocoords("Disable DEPTH_TEST")
-        self.depthtest1 = getDListNocoords("Enable DEPTH_TEST")
 
-        self.stencil_init = getDListNocoords("""
+class Stencil:
+        init = getDListNocoords("""
         # Create stencil
         StencilMask 255
         Enable STENCIL_TEST
@@ -96,46 +86,75 @@
         ColorMask 0 0 0 0
         """)
 
-        self.stencil_use = getDListNocoords("""
+        use = getDListNocoords("""
         Enable STENCIL_TEST
         StencilFunc NOTEQUAL 0 255
         StencilOp KEEP KEEP KEEP
         ColorMask 1 1 1 1
         """)
         
-        self.stencil_use_init2 = getDListNocoords("""
+        use_init2 = getDListNocoords("""
         Enable STENCIL_TEST
         StencilFunc NOTEQUAL 0 255
         StencilOp ZERO ZERO INCR
         ColorMask 1 1 1 1
         """)
 
-        self.stencil_use2_clear = getDListNocoords("""
+        use2_clear = getDListNocoords("""
         Enable STENCIL_TEST
         StencilFunc LESS 1 255
         StencilOp ZERO ZERO ZERO
         ColorMask 1 1 1 1
         """)
 
-        self.stencil_use_clear = getDListNocoords("""
+        use_clear = getDListNocoords("""
         Enable STENCIL_TEST
         StencilFunc NOTEQUAL 0 255
         StencilOp ZERO ZERO ZERO
         ColorMask 1 1 1 1
         """)
 
-        self.stencil_clear = getDListNocoords("""
+        clear = getDListNocoords("""
         Enable STENCIL_TEST
         StencilFunc NOTEQUAL 0 255
         StencilOp ZERO ZERO ZERO
         ColorMask 0 0 0 0
         """)
 
-        self.stencil_teardown = getDListNocoords("""
+        teardown = getDListNocoords("""
         Disable STENCIL_TEST
         ColorMask 1 1 1 1
         """)
 
+class Depth:
+        mask0 = getDListNocoords("DepthMask 0")
+        mask1 = getDListNocoords("DepthMask 1")
+        test0 = getDListNocoords("Disable DEPTH_TEST")
+        test1 = getDListNocoords("Enable DEPTH_TEST")
+
+    
+
+class IrreguScene:
+    def __init__(self):
+        self.bg = background((0.7,0.7,1.0))
+
+        self.a1 = 0
+        self.tx = 0
+        self.ty = 0
+        self.x1 = 0
+        self.y1 = 0
+        self.xs = 1
+        self.ys = 1
+        self.x0 = 0
+        self.y0 = 0
+        self.scale = 150
+        self.shape = 0
+        self.texslicing = 0
+        self.flags = 127
+
+        self.initcode()
+
+
     def initcode(self):
         code = combinercode("""
                 PushAttrib ENABLE_BIT TEXTURE_BIT
@@ -230,15 +249,6 @@
             Color 0 0 0 0
         """)
 
-        Y_COLOR       = 1;
-        Y_SECCOLOR    = 2;
-        DOTVEC_COLOR  = 4;
-        INTERP_DOTVEC = 8;
-        SLICE_1D      = 16;
-        SLICE_2D      = 32;
-        SHIFTS        = 64;
-        INSIDE        = 128;
-
         inner_code = code % {"tex" : texRGBA.getTexId(),
                              "color" : "1 1 1 1" }
         outer_code = code % {"tex" : texRGBA.getTexId(),
@@ -467,29 +477,29 @@
 
 
         if self.flags >> 5 & 1:
-            vs.map.put(self.depthmask0)
-            vs.map.put(self.stencil_init)
+            vs.map.put(Depth.mask0)
+            vs.map.put(Stencil.init)
             if self.flags >> 3 & 1:
                 vs.map.put(self.outer, cs1, cs2)
-                vs.map.put(self.stencil_use_init2)
+                vs.map.put(Stencil.use_init2)
             else:
                 vs.map.put(self.inner, cs1, cs2)
-                vs.map.put(self.stencil_use)
+                vs.map.put(Stencil.use)
 
-            vs.map.put(self.depthmask1)
+            vs.map.put(Depth.mask1)
             vs.map.put(paperframe, cs1)
             vs.map.put(paperquad, cs1, cspap)
             
-            vs.map.put(self.depthmask0)
-            vs.map.put(self.depthtest0)
-            vs.map.put(self.stencil_clear)
+            vs.map.put(Depth.mask0)
+            vs.map.put(Depth.test0)
+            vs.map.put(Stencil.clear)
             vs.map.put(self.inner, cs1, cs2)
-            vs.map.put(self.stencil_use2_clear)
+            vs.map.put(Stencil.use2_clear)
             vs.map.put(self.envelope, cs1, cs2)
-            vs.map.put(self.stencil_teardown)
+            vs.map.put(Stencil.teardown)
 
-            vs.map.put(self.depthmask1)
-            vs.map.put(self.depthtest1)
+            vs.map.put(Depth.mask1)
+            vs.map.put(Depth.test1)
         else:
             if self.flags >> 3 & 1:
                 vs.map.put(self.outer, cs1, cs2)
@@ -556,10 +566,152 @@
             self.initcode()
        elif k == "0":
            self.film()
+        elif k == "p":
+            makeScreenshots()
+
     def film(self):
        # 
        pass
 
+
+class StillMotionScene:
+    stdcode = """
+        PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT
+        BindTexture TEXTURE_2D %s
+        TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
+        TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
+        Enable TEXTURE_2D
+        TexEnv TEXTURE_ENV TEXTURE_ENV_MODE ADD
+        Enable ALPHA_TEST
+        AlphaFunc GEQUAL 1.0
+        """ % texINTENSITY.getTexId() 
+
+    
+    shape = 0
+    texscale = 3
+    linewidth = 4
+    refsize = 128
+    scale_pow = 0
+    border0 = -.5 * ripple_scale * texscale
+    border1 = .5 * ripple_scale * texscale 
+    texslicing = 0.0
+
+    inner =  GLRen.createIrregularEdge(
+        shape, texscale, linewidth, refsize, scale_pow,
+        border0, border1, texslicing,
+        "0 0 0 1 0 0 0 0", "", 0, 0, SLICE_1D + Y_COLOR + INSIDE,
+        stdcode, 1.0)
+    outer = GLRen.createIrregularEdge(
+        shape, texscale, linewidth, refsize, scale_pow,
+        border0, border1, texslicing,
+        "0 0 0 1 0 0 0 0", "", 0, 0, SLICE_1D + Y_COLOR + SHIFTS + INSIDE,
+        stdcode, 1.0)
+    envelope = GLRen.createIrregularEdge(
+        shape, texscale, linewidth, refsize, scale_pow,
+        border0, border1, texslicing,
+        "", "", 0, 0, SLICE_2D + INSIDE,
+        """
+        PushAttrib
+        Disable TEXTURE_2D
+        """, 1.0)
+
+    canvas = getDList("""
+    Enable BLEND
+    Disable ALPHA_TEST
+    BlendFunc SRC_ALPHA ONE_MINUS_SRC_ALPHA
+    LineWidth %s
+    Begin LINES
+    Vertex -4 -4
+    Vertex -4 +4
+
+    Vertex +4 -4
+    Vertex +4 +4
+
+    Vertex -4 -4
+    Vertex +4 -4
+
+    Vertex -4 +4
+    Vertex +4 +4
+    End
+    Color 0 0 0 0
+    Begin QUAD_STRIP
+    Vertex -4 -4 
+    Vertex -4 +4 
+    Vertex +4 -4 
+    Vertex +4 +4 
+    End
+    """ % linewidth)
+
+    def __init__(self):
+        self.scale = 256
+        self.x0, self.y0 = 2,0
+        self.x1, self.y1 = -2.5,0
+        self.xs, self.ys = 2,1
+        self.a1 = 0
+
+    def putedge(self, vs, cs1, cs2, alpha):
+        vs.map.put(Depth.mask0)
+        vs.map.put(Stencil.init)
+
+        vs.map.put(self.outer, cs1, cs2)
+        vs.map.put(Stencil.use_init2)
+
+        vs.map.put(Depth.mask1)
+
+        putnoc(vs, getDListNocoords("Color 0 0 0 %s" % alpha))
+        vs.map.put(self.canvas, cs1)
+            
+        vs.map.put(Depth.mask0)
+        vs.map.put(Depth.test0)
+        vs.map.put(Stencil.clear)
+        vs.map.put(self.inner, cs1, cs2)
+        vs.map.put(Stencil.use2_clear)
+
+        putnoc(vs, getDListNocoords("Color 0 0 0 %s" % alpha))
+        vs.map.put(self.envelope, cs1, cs2)
+        vs.map.put(Stencil.teardown)
+
+        vs.map.put(Depth.mask1)
+        vs.map.put(Depth.test1)
+
+    def scene(self, vs):
+        putnoc(vs, background((1.0,1.0,1.0)))
+    
+        cs1 = vs.coords.affineCoordsys(0, 10,
+                                       600 + self.scale * self.x0,
+                                       450 + self.scale * self.y0,
+                                       self.scale * 1,
+                                       self.scale * 0,
+                                       self.scale * 0,
+                                       self.scale * 1)
+       vs.matcher.add(cs1, "1")
+
+        for i in 0,1,2,3:
+            
+            cs2 = vs.coords.affineCoordsys(
+                0, 0, self.x1 + .15 * i, self.y1,
+                self.xs * cos(self.a1), self.ys * -sin(self.a1),
+                self.xs * sin(self.a1), self.ys * cos(self.a1) )
+
+            vs.matcher.add(cs2, "2." + str(i))
+
+            self.putedge(vs, cs1, cs2, (1, .6, .3, .2)[i])
+
+
+def r(sc, filename):
+    vs = w.createVobScene()
+    sc.scene(vs)
+    w.renderStill(vs, 0)
+    saveanim.saveframe(filename, w)
+
+def makeScreenshots():
+    w.setLocation(0,0,1200,900)
+    ps = StillMotionScene()
+    r(ps, "shots/motion.png")
+
+
 currentScene = IrreguScene()
+
+#currentScene = StillMotionScene()
 
 #GL.call("PolygonMode FRONT_AND_BACK FILL")
Index: gzz/gfx/demo/papertest.py
diff -u gzz/gfx/demo/papertest.py:1.54 gzz/gfx/demo/papertest.py:1.55
--- gzz/gfx/demo/papertest.py:1.54      Fri Nov 29 08:29:03 2002
+++ gzz/gfx/demo/papertest.py   Sat Nov 30 04:23:57 2002
@@ -398,12 +398,20 @@
        sp = 10
        size = vs.getSize().height / 4 - 2*sp
        (w,h) = (size,size)
+        total = 0
        for t in self.tex:
           vs.put(quad((t.getTexId())),  0, sp + x*(w+sp), sp + y*(h+sp), w, h)
           x += 1
           if x>3:
                x = 0
                y += 1
+           pw = GL.getGLTexLevelParameterFloat("TEXTURE_2D", t.getTexId(), 0, 
+                                               "TEXTURE_WIDTH")[0]
+           ph = GL.getGLTexLevelParameterFloat("TEXTURE_2D", t.getTexId(), 0, 
+                                               "TEXTURE_HEIGHT")[0]
+           print "Size: %sx%s = %s" % (pw, ph, pw * ph)
+           total += pw * ph
+        print "Total size =", total
 
 scenebindings = {
     "F1": PaperScene,




reply via email to

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