gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz Documentation/Manuscripts/Paper/Makefile Do...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz Documentation/Manuscripts/Paper/Makefile Do...
Date: Tue, 26 Nov 2002 15:18:15 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/11/26 15:18:14

Modified files:
        Documentation/Manuscripts/Paper: Makefile paper.tex 
        gfx/demo       : gldemo.py paperbasis.py 
        gfx/librenderables: renderables.py 
Added files:
        Documentation/Manuscripts/Paper: texcomb_a.ps texcomb_b.ps 
                                         texcomb_c.ps texcomb_d.ps 

Log message:
        shooting

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Documentation/Manuscripts/Paper/texcomb_a.ps?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Documentation/Manuscripts/Paper/texcomb_b.ps?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Documentation/Manuscripts/Paper/texcomb_c.ps?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Documentation/Manuscripts/Paper/texcomb_d.ps?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Documentation/Manuscripts/Paper/Makefile.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Documentation/Manuscripts/Paper/paper.tex.diff?tr1=1.75&tr2=1.76&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/gldemo.py.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/paperbasis.py.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.154&tr2=1.155&r1=text&r2=text

Patches:
Index: gzz/Documentation/Manuscripts/Paper/Makefile
diff -u gzz/Documentation/Manuscripts/Paper/Makefile:1.3 
gzz/Documentation/Manuscripts/Paper/Makefile:1.4
--- gzz/Documentation/Manuscripts/Paper/Makefile:1.3    Mon Nov 25 06:17:24 2002
+++ gzz/Documentation/Manuscripts/Paper/Makefile        Tue Nov 26 15:18:12 2002
@@ -7,3 +7,8 @@
 
 .fig.eps:
        fig2dev -L eps $< $@
+
+shots:
+       for i in ../../../shots/texcomb_?.png; do \
+           pngtopnm <$$i | pnmtops -noturn -imagewidth 3  > `basename $$i 
.png`.ps; \
+       done
Index: gzz/Documentation/Manuscripts/Paper/paper.tex
diff -u gzz/Documentation/Manuscripts/Paper/paper.tex:1.75 
gzz/Documentation/Manuscripts/Paper/paper.tex:1.76
--- gzz/Documentation/Manuscripts/Paper/paper.tex:1.75  Tue Nov 26 09:35:23 2002
+++ gzz/Documentation/Manuscripts/Paper/paper.tex       Tue Nov 26 15:18:12 2002
@@ -633,11 +633,21 @@
 
 \begin{figure}
 \centering
-\fbox{\vbox{\vskip 3in}}
+\def\w{4cm}
+\includegraphics[width=\w]{texcomb_a.ps}%
+\includegraphics[width=\w]{texcomb_b.ps}\\
+\includegraphics[width=\w]{texcomb_c.ps}%
+\includegraphics[width=\w]{texcomb_d.ps}
 \caption{
 \label{fig-regcomb}
-How register combiners on the NV10 architecture 
-can be used to generate shapes. (band-like!)
+How the limited register combiners of the NV10 architecture 
+can be used to generate shapes. 
+Top: the two basis textures.
+Bottom left: dot product of the basis textures: 
+$2(2a-1)\cdot(2b-1)+1/2$, where $a$ and $b$ are the texture RGB values.
+Bottom right: dot product of the basis textures squared:
+$32\left( (2a-1)\cdot(2b-1) \right)^2$.
+This term can then be used to modulate between two colors.
 }
 \end{figure}
 
Index: gzz/gfx/demo/gldemo.py
diff -u gzz/gfx/demo/gldemo.py:1.50 gzz/gfx/demo/gldemo.py:1.51
--- gzz/gfx/demo/gldemo.py:1.50 Sun Nov 24 16:12:40 2002
+++ gzz/gfx/demo/gldemo.py      Tue Nov 26 15:18:14 2002
@@ -284,7 +284,7 @@
 
 class Bindings(AbstractBinder):
     def keystroke(self, s):
-       print "KEY: '%s'"%s
+       # print "KEY: '%s'"%s
        if usingNormalBindings:
            if s == "q" or s == "Q":
                System.exit(43)
Index: gzz/gfx/demo/paperbasis.py
diff -u gzz/gfx/demo/paperbasis.py:1.28 gzz/gfx/demo/paperbasis.py:1.29
--- gzz/gfx/demo/paperbasis.py:1.28     Tue Nov 26 13:46:35 2002
+++ gzz/gfx/demo/paperbasis.py  Tue Nov 26 15:18:14 2002
@@ -1,6 +1,7 @@
 from __future__ import nested_scopes
 
 from gfx.libutil import nvcode
+from gfx.libutil import saveanim
 
 from gzz.gfx.gl import GL,GLRen,Paper,PaperMill
 
@@ -57,13 +58,22 @@
        color = SPARE0
        alpha = 1
     """),
+    "BAND1_X" : nvcode.parseCombiner("""
+       SPARE0 = ((2*TEX0-1) . (2*TEX1-1)) * 4
+
+       SPARE0 = ((+SPARE0)*(+SPARE0)) * 2
+
+       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.blue)*(TEX0.blue)) * 4
+       SPARE1.a = ((TEX1.a)+(.5-TEX0.a)) * 4
 
        SPARE0 = ((+SPARE0)*(+SPARE0)) * 2
-       SPARE1 = ((SPARE1) * (SPARE1.a)) * 2
+       SPARE1 = ((SPARE1.a) * (SPARE1.a)) * 2
 
        color = SPARE0 * SPARE1
        alpha = 1
@@ -126,7 +136,7 @@
 }
 
 
-def getpaper(vecs, cols, t0, t1, tex0comb, isectcomb, tex1comb):
+def getpaper(vecs, cols, x0, y0, x1, y1, t0, t1, tex0comb, isectcomb, 
tex1comb):
     pap = Paper()
     pap.setNPasses(1)
     ppass = pap.getPass(0)
@@ -177,8 +187,8 @@
         CombinerParameterNV CONSTANT_COLOR1_NV %(r1)s
     """ % locals()
 
-    return GLRen.createBasisPaperQuad(pap, 0, 0, 1, 1,
-                                   3.0,
+    return GLRen.createBasisPaperQuad(pap, 0, 0, x0, y0,
+                               0, 0, x1, y1,
                                       constcode + texcodes[tex0comb],
                                       constcode + texcodes[tex1comb],
                                       constcode + texcodes[isectcomb])
@@ -187,7 +197,7 @@
 
 class PaperTemplate:
     def __init__(self):
-       self.deltac = .05
+       self.deltac = .01
         self.vecseed0 = 0
         self.vecseed1 = 1
         self.colseed = 2
@@ -195,15 +205,16 @@
         self.initvecs()
         self.initcols()
 
-        self.x0, self.y0 = 0, 0
+        self.x0, self.y0 = .12, .02
         self.x1, self.y1 = 0, 0
         self.texgen0 = TexGenXYRepeatUnit(vecs = [[.5,0], [0,.5]])
-        self.texgen1 = TexGenXYRepeatUnit(vecs = [[.25,.25], [.25,-.25]])
+        self.texgen1 = TexGenXYRepeatUnit(vecs = [[.25,.5], [.25,0]])
 
         self.frame = getDList("""
        Color 0 0 0
        Disable TEXTURE_2D
         Disable DEPTH_TEST
+       LineWidth 2
        Begin LINE_LOOP
        Vertex 0 0
        Vertex 0 1
@@ -251,8 +262,15 @@
         elif k == "Right": self.x0 += self.deltac
 
     def place(self, vs, into, t1, c, t2):
+       print self.x0,self.y0,self.x1,self.y1
+       sca = 1/3.0
+       x0s = 1 / sca
+       y0s = 1 / sca
+       x1s = 1 / sca
+       y1s = 2 / sca
         pq = getpaper(self.vecs, self.cols, 
-           "pyramid", "triangle",
+           x0s, y0s, x1s, y1s,
+           "cone", "triangle",
            t1, c, t2)
 
 
@@ -260,22 +278,24 @@
         # [0,1] x [0,1] to vertex coords, cs1 is for the first texture unit
         # and cs2 for the second
 
+       sca = 2 * sca
+
        cs1 = vs.coords.affineCoordsys(into, 10, self.x0, self.y0,
-                                       self.texgen0.vecs[0][0],
-                                       self.texgen0.vecs[1][0],
-                                       self.texgen0.vecs[0][1],
-                                       self.texgen0.vecs[1][1])
+                                       self.texgen0.vecs[0][0]*sca,
+                                       self.texgen0.vecs[1][0]*sca,
+                                       self.texgen0.vecs[0][1]*sca,
+                                       self.texgen0.vecs[1][1]*sca)
        vs.matcher.add(cs1, "1")
        cs2 = vs.coords.affineCoordsys(into, 10, self.x1, self.y1,
-                                       self.texgen1.vecs[0][0],
-                                       self.texgen1.vecs[1][0],
-                                       self.texgen1.vecs[0][1],
-                                       self.texgen1.vecs[1][1])
+                                       self.texgen1.vecs[0][0]*sca,
+                                       self.texgen1.vecs[1][0]*sca,
+                                       self.texgen1.vecs[0][1]*sca,
+                                       self.texgen1.vecs[1][1]*sca)
        vs.matcher.add(cs2, "2")
 
        vs.map.put(pq, cs1, cs2)
-       vs.map.put(self.frame, cs1)
-       vs.map.put(self.frame, cs2)
+       vs.map.put(self.frame, vs.scaleCS(cs1, "s", x0s, y0s))
+       vs.map.put(self.frame, vs.scaleCS(cs2, "s", x1s, y1s))
 
 class PaperScene:
     def __init__(self):
@@ -326,53 +346,76 @@
             vs.map.put(cq, cs)
             vs.map.put(self.pt.frame, cs)
 
+def shootImages():
+    pt = PaperTemplate()
+    def frame(fileprefix, t0, c, t1):
+       vs = w.createVobScene()
+       vs.map.put(background((0.7, 0.8, 0.6)))
+       pt.place(vs, vs.orthoCS(0, "A", 0, 10, 10, 650, 650), t0, c, t1)
+       w.renderStill(vs, 0)
+       saveanim.saveframe("shots/%s.png" % fileprefix, w)
+
+    frame("texcomb_a", "RGB0", "RGB0", "NONE")
+    frame("texcomb_b", "NONE", "RGB1", "RGB1")
+    frame("texcomb_c", "RGB0", "BAND0", "RGB1")
+    frame("texcomb_d", "RGB0", "BAND1", "RGB1")
+
 class PaperFlowScene(PaperTemplate):
     def __init__(self):
        self.bgcolor = (0.7, 0.8, 0.6)
        self.pt = PaperTemplate()
     def key(self, k):
-       self.pt.key(k)
+       if k == "s":
+           shootImages()
+       else:
+           self.pt.key(k)
 
     def scene(self, vs):
        putnoc(vs, background(self.bgcolor))
        
        self.pt.place(vs,
-           vs.orthoCS(0, "S1", 0, 100, 100, 200, 200),
+           vs.orthoCS(0, "S1", 0, 10, 10, 100, 100),
            "RGB0", "RGB0", "NONE")
        
        self.pt.place(vs,
-           vs.orthoCS(0, "S2", 0, 300, 100, 200, 200),
+           vs.orthoCS(0, "S2", 0, 300, 100, 100, 100),
            "NONE", "RGB1", "RGB1")
        
        self.pt.place(vs,
-           vs.orthoCS(0, "S3", 0, 200, 250, 200, 200),
+           vs.orthoCS(0, "S3", 0, 200, 250, 100, 100),
            "RGB0", "BAND0", "RGB1")
-       
+
        self.pt.place(vs,
            vs.orthoCS(0, "S4", 0, 200, 400, 200, 200),
            "RGB0", "BAND1", "RGB1")
        
-       self.pt.place(vs,
-           vs.orthoCS(0, "S5", 0, 200, 550, 200, 200),
-           "RGB0", "BAND2", "RGB1")
-       
-       self.pt.place(vs,
-           vs.orthoCS(0, "S6", 0, 500, 550, 200, 200),
-           "RGB0", "BAND3", "RGB1")
-       
-       self.pt.place(vs,
-           vs.orthoCS(0, "S8", 0, 500, 150, 400, 400),
-           "RGB0", "SHAPEX_2", "RGB1")
        
-       self.pt.place(vs,
-           vs.orthoCS(0, "S9", 0, 700, 200, 400, 400),
-           "RGB0", "SHAPEX_3C", "RGB1")
-
-       self.pt.place(vs,
-           vs.orthoCS(0, "S9S", 0, 700, 450, 400, 400),
-           "RGB0", "SHAPEX_3B", "RGB1")
+       if 0:
+           self.pt.place(vs,
+               vs.orthoCS(0, "S5", 0, 400, 400, 200, 200),
+               "RGB0", "BAND1_X", "RGB1")
+
+           self.pt.place(vs,
+               vs.orthoCS(0, "S5", 0, 400, 550, 200, 200),
+               "RGB0", "BAND2", "RGB1")
+           
+           self.pt.place(vs,
+               vs.orthoCS(0, "S6", 0, 500, 550, 200, 200),
+               "RGB0", "BAND3", "RGB1")
+           
+           self.pt.place(vs,
+               vs.orthoCS(0, "S8", 0, 500, 150, 400, 400),
+               "RGB0", "SHAPEX_2", "RGB1")
+           
+           self.pt.place(vs,
+               vs.orthoCS(0, "S9", 0, 700, 200, 400, 400),
+               "RGB0", "SHAPEX_3", "RGB1")
+
+           self.pt.place(vs,
+               vs.orthoCS(0, "S9S", 0, 700, 450, 400, 400),
+               "RGB0", "SHAPEX_3B", "RGB1")
 
-       print texcodes["SHAPEX_3"]
+       # print texcodes["SHAPEX_3"]
 
 currentScene = PaperFlowScene()        
 
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.154 
gzz/gfx/librenderables/renderables.py:1.155
--- gzz/gfx/librenderables/renderables.py:1.154 Tue Nov 26 04:30:44 2002
+++ gzz/gfx/librenderables/renderables.py       Tue Nov 26 15:18:14 2002
@@ -106,7 +106,7 @@
     "ParamCode" : "this->arr = arr; ",
     "RenderCode" : """
        glBegin(GL_LINE_STRIP);
-       for(int i=0; i+1<arr.size(); i+=2) {
+       for(unsigned i=0; i+1<arr.size(); i+=2) {
            ZPt p(arr[i], arr[i+1], 0);
            coords1.vertex(p);
        }
@@ -1007,19 +1007,28 @@
 {
     "Type" : "2",
     "Name": "BasisPaperQuad",
-    "Data": "Paper::Paper* paper; CallGLCode tex0code, tex1code, isectcode; 
float x0, y0, x1, y1; float paperScale; ",
+    "Data": """Paper::Paper* paper; CallGLCode tex0code, tex1code, isectcode; 
+           float x0_0, y0_0, x0_1, y0_1; 
+           float x1_0, y1_0, x1_1, y1_1; 
+           float nunits0, nunits1; """,
     "Params" : """
-           Paper paper, float x0, float y0, float x1, float y1,
-           float paperScale,
+           Paper paper, 
+           float x0_0, float y0_0, float x0_1, float y0_1,
+           float x1_0, float y1_0, float x1_1, float y1_1,
             UTF8String tex0, UTF8String tex1, UTF8String isect
        """,
     "ParamCode" : """
            this->paper = paper;
-            this->x0 = x0;
-            this->y0 = y0;
-            this->x1 = x1;
-            this->y1 = y1;
-            this->paperScale = paperScale;
+            this->x0_0 = x0_0;
+            this->y0_0 = y0_0;
+            this->x0_1 = x0_1;
+            this->y0_1 = y0_1;
+            this->x1_0 = x1_0;
+            this->y1_0 = y1_0;
+            this->x1_1 = x1_1;
+            this->y1_1 = y1_1;
+            this->nunits0 = nunits0;
+            this->nunits1 = nunits1;
             tex0code = CallGLCode(tex0.c_str());
             tex1code = CallGLCode(tex1.c_str());
             isectcode = CallGLCode(isect.c_str());
@@ -1036,7 +1045,8 @@
 
                GLERR
 
-                Pt p[] = { Pt(x0,y0), Pt(x0,y1), Pt(x1,y1), Pt(x1,y0) };
+                Pt p0[] = { Pt(x0_0,y0_0), Pt(x0_0,y0_1), Pt(x0_1,y0_1), 
Pt(x0_1,y0_0) };
+                Pt p1[] = { Pt(x1_0,y1_0), Pt(x1_0,y1_1), Pt(x1_1,y1_1), 
Pt(x1_1,y1_0) };
                 ZPt q;
 
                 // Draw the first texture
@@ -1047,13 +1057,11 @@
                 GLERR;
                glBegin(GL_QUADS);
                 for (int i = 0; i < 4; i++) {
-                    ZPt v = coords1.transform(p[i]);
-                    glMultiTexCoord2fARB(0, paperScale * p[i].x, 
-                                           paperScale * p[i].y);
+                    ZPt v = coords1.transform(p0[i]);
+                    glMultiTexCoord2fARB(0, p0[i].x, p0[i].y);
                     q = cs2inv.transform(v);
-                    glMultiTexCoord2fARB(1, paperScale * q.x, 
-                                           paperScale * q.y);
-                    coords1.vertex(p[i]);
+                    glMultiTexCoord2fARB(1, q.x, q.y);
+                    coords1.vertex(p0[i]);
                 }
                 glEnd();
                GLERR;
@@ -1068,13 +1076,11 @@
                GLERR;
                glBegin(GL_QUADS);
                 for (int i = 0; i < 4; i++) {
-                    ZPt v = coords2.transform(p[i]);
-                    glMultiTexCoord2fARB(1, paperScale * p[i].x, 
-                                           paperScale * p[i].y);
+                    ZPt v = coords2.transform(p1[i]);
+                    glMultiTexCoord2fARB(1, p1[i].x, p1[i].y);
                     q = cs1inv.transform(v);
-                    glMultiTexCoord2fARB(0, paperScale * q.x, 
-                                           paperScale * q.y);
-                    coords2.vertex(p[i]);
+                    glMultiTexCoord2fARB(0, q.x, q.y);
+                    coords2.vertex(p1[i]);
                 }
                 glEnd();
                GLERR
@@ -1089,13 +1095,11 @@
                GLERR
                glBegin(GL_QUADS);
                 for (int i = 0; i < 4; i++) {
-                    ZPt v = coords2.transform(p[i]);
-                    glMultiTexCoord2fARB(1, paperScale * p[i].x, 
-                                           paperScale * p[i].y);
+                    ZPt v = coords2.transform(p1[i]);
+                    glMultiTexCoord2fARB(1, p1[i].x, p1[i].y);
                     q = cs1inv.transform(v);
-                    glMultiTexCoord2fARB(0, paperScale * q.x, 
-                                           paperScale * q.y);
-                    coords2.vertex(p[i]);
+                    glMultiTexCoord2fARB(0, q.x, q.y);
+                    coords2.vertex(p1[i]);
                 }
                 glEnd();
                GLERR




reply via email to

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