gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/irregular2.py librenderables/Rende...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/irregular2.py librenderables/Rende...
Date: Tue, 17 Sep 2002 07:14:05 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/09/17 07:14:05

Modified files:
        gfx/demo       : irregular2.py 
        gfx/librenderables: Renderables.hxx renderables.py 

Log message:
        Interpret border width inside coords2; use the unit square of cs1 as 
bounding box

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregular2.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/Renderables.hxx.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.38&tr2=1.39&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregular2.py
diff -c gzz/gfx/demo/irregular2.py:1.6 gzz/gfx/demo/irregular2.py:1.7
*** gzz/gfx/demo/irregular2.py:1.6      Tue Sep 17 03:35:55 2002
--- gzz/gfx/demo/irregular2.py  Tue Sep 17 07:14:05 2002
***************
*** 34,47 ****
              Enable TEXTURE_GEN_T
              ActiveTexture TEXTURE0
              Begin LINE_LOOP
!             Vertex -%(w)sr -1
              Vertex -%(w)s +1
              Vertex +%(w)s +1
              Vertex +%(w)s -1
              End
          """ % locals())
  
!       self.iq = GZZGL.createIrregularQuad(-1, -1, 1, 1, .5, """
                  PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT
                  Enable ALPHA_TEST
                  AlphaFunc GREATER 0.0
--- 34,47 ----
              Enable TEXTURE_GEN_T
              ActiveTexture TEXTURE0
              Begin LINE_LOOP
!             Vertex -%(w)s -1
              Vertex -%(w)s +1
              Vertex +%(w)s +1
              Vertex +%(w)s -1
              End
          """ % locals())
  
!       self.iq = GZZGL.createIrregularQuad(.2, """
                  PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT
                  Enable ALPHA_TEST
                  AlphaFunc GREATER 0.0
***************
*** 94,100 ****
        putnoc(vs, background((0.1,0.4,0.5)))
  
  
!         cs1 = vs.coords.affineCoordsys(0, "1", 10, self.x1, self.y1, 100, 0, 
0, 100)
          cs2 = vs.coords.affineCoordsys(0, "2", 10, 600, 450, 150, 32.3, 
-14.2, 150)
          vs.map.put(self.mask, cs2)
          vs.map.put(self.iq, cs1, cs2)
--- 94,100 ----
        putnoc(vs, background((0.1,0.4,0.5)))
  
  
!         cs1 = vs.coords.affineCoordsys(0, "1", 10, self.x1, self.y1, 200, 0, 
0, 100)
          cs2 = vs.coords.affineCoordsys(0, "2", 10, 600, 450, 150, 32.3, 
-14.2, 150)
          vs.map.put(self.mask, cs2)
          vs.map.put(self.iq, cs1, cs2)
Index: gzz/gfx/librenderables/Renderables.hxx
diff -c gzz/gfx/librenderables/Renderables.hxx:1.11 
gzz/gfx/librenderables/Renderables.hxx:1.12
*** gzz/gfx/librenderables/Renderables.hxx:1.11 Tue Sep 17 04:04:52 2002
--- gzz/gfx/librenderables/Renderables.hxx      Tue Sep 17 07:14:05 2002
***************
*** 159,164 ****
--- 159,167 ----
            Pt tmp = center + x * p.x + y * p.y;
            return ZPt(tmp.x, tmp.y, z + p.z);
        }
+       Vec transform(const Vec &p) const {
+           return x * p.x + y * p.y;
+       }
  
        void performGL_xy() {
            GLfloat matrix[16] = {
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.38 
gzz/gfx/librenderables/renderables.py:1.39
*** gzz/gfx/librenderables/renderables.py:1.38  Tue Sep 17 06:13:06 2002
--- gzz/gfx/librenderables/renderables.py       Tue Sep 17 07:14:05 2002
***************
*** 656,670 ****
  {
      "Type" : "2",
      "Name": "IrregularQuad",
!     "Data": "float x0, y0, x1, y1, border; CallGLCode setup;",
      "Params" : """
!           float x0, float y0, float x1, float y1, float border, String 
setupcode
        """,
      "ParamCode" : """
-             this->x0 = x0;
-             this->y0 = y0;
-             this->x1 = x1;
-             this->y1 = y1;
              this->border = border;
              setup = CallGLCode(string(setupcode.begin(), 
setupcode.end()).c_str());
        """,
--- 656,666 ----
  {
      "Type" : "2",
      "Name": "IrregularQuad",
!     "Data": "float border; CallGLCode setup;",
      "Params" : """
!           float border, String setupcode
        """,
      "ParamCode" : """
              this->border = border;
              setup = CallGLCode(string(setupcode.begin(), 
setupcode.end()).c_str());
        """,
***************
*** 680,700 ****
          setup();
          GLERR;
  
          AffineCoords cs2inv = coords2.getInverse();
  
!         float x0b = x0 - border;
!         float y0b = y0 - border;
!         float x1b = x1 + border;
!         float y1b = y1 + border;
! 
!         float wx = (x1b - x0b) / (x1 - x0);
!         float wy = (y1b - y0b) / (y1 - y0);
! 
! 
!         Pt sides[4][4] = { { Pt(x0,y0), Pt(x1, y0), Pt(x1, y0b), Pt(x0, y0b) 
},
!                            { Pt(x0,y1), Pt(x1, y1), Pt(x1, y1b), Pt(x0, y1b) 
},
!                            { Pt(x0,y0), Pt(x0, y1), Pt(x0b, y1), Pt(x0b, y0) 
},
!                            { Pt(x1,y0), Pt(x1, y1), Pt(x1b, y1), Pt(x1b, y0) 
} };
  
          /* The distance (as a fraction of border) from the square where the 
1D texture slice is taken.
           * Smaller number lowers the frequency of the corner pieces
--- 676,710 ----
          setup();
          GLERR;
  
+         AffineCoords cs1inv = coords1.getInverse();
          AffineCoords cs2inv = coords2.getInverse();
  
!         // Normalize unit vectors inside coords2 to get border widths
!         float bx = border * 
cs1inv.transform(coords2.transform(cs2inv.transform(coords1.transform(Vec(1,0))).normalize())).length();
!         float by = border * 
cs1inv.transform(coords2.transform(cs2inv.transform(coords1.transform(Vec(0,1))).normalize())).length();
! 
!         const float x0 = 1;
!         const float x1 = 1 - bx;
!         const float x2 = 1 - 2 * bx;
!         const float y0 = 1;
!         const float y1 = 1 - by;
!         const float y2 = 1 - 2 * by;
!         const float w = .5; 
! 
!         // scale of last two vertices of sides 
!         float wtbl[] = { 1, 1, 1, 1, w, w, w, w };
! 
!         Pt sides[][4] =  { // The sides of the rectangle:
!                            { Pt(-x0, -y2), Pt(-x0, +y2), Pt(-x1, +y2), 
Pt(-x1, -y2) },
!                            { Pt(+x0, -y2), Pt(+x0, +y2), Pt(+x1, +y2), 
Pt(+x1, -y2) },
!                            { Pt(-x2, -y0), Pt(+x2, -y0), Pt(+x2, -y1), 
Pt(-x2, -y1) },
!                            { Pt(-x2, +y0), Pt(+x2, +y0), Pt(+x2, +y1), 
Pt(-x2, +y1) },
!                            // Corners:
!                            { Pt(+x2, +y0), Pt(+x0, +y2), Pt(+x1, +y2), 
Pt(+x2, +y1) },
!                            { Pt(+x2, -y0), Pt(+x0, -y2), Pt(+x1, -y2), 
Pt(+x2, -y1) },
!                            { Pt(-x2, +y0), Pt(-x0, +y2), Pt(-x1, +y2), 
Pt(-x2, +y1) },
!                            { Pt(-x2, -y0), Pt(-x0, -y2), Pt(-x1, -y2), 
Pt(-x2, -y1) }
!                            };
  
          /* The distance (as a fraction of border) from the square where the 
1D texture slice is taken.
           * Smaller number lowers the frequency of the corner pieces
***************
*** 702,712 ****
          float texf = 0.5;
  
          glBegin(GL_QUADS);
!         for (int i = 0; i < 4; i++) {
!             ZPt tex0 = cs2inv.transform(coords1.transform(lerp(texf, 
sides[i][0], sides[i][3])));
!             ZPt tex1 = cs2inv.transform(coords1.transform(lerp(texf, 
sides[i][1], sides[i][2])));
  
!             glSecondaryColor3fEXT(1, 1, 1);
  
              glTexCoord2f(tex0.x, tex0.y);
              coords1.vertex(sides[i][0]);
--- 712,722 ----
          float texf = 0.5;
  
          glBegin(GL_QUADS);
!         for (unsigned i = 0; i < sizeof(sides)/sizeof(sides[0]); i++) {
!             ZPt tex0 = cs2inv.transform(coords1.transform(lerp(texf, 
sides[i][3], sides[i][0])));
!             ZPt tex1 = cs2inv.transform(coords1.transform(lerp(texf, 
sides[i][2], sides[i][1])));
  
!             glSecondaryColor3fEXT(0, 0, 0);
  
              glTexCoord2f(tex0.x, tex0.y);
              coords1.vertex(sides[i][0]);
***************
*** 714,723 ****
              glTexCoord2f(tex1.x, tex1.y);
              coords1.vertex(sides[i][1]);
  
!             glSecondaryColor3fEXT(0, 0, 0);
  
!             float w = (i & 2) ? wy : wx;
!             w = 1;
  
              glTexCoord4f(tex1.x * w, tex1.y * w, 0, w);
              coords1.vertex(sides[i][2]);
--- 724,732 ----
              glTexCoord2f(tex1.x, tex1.y);
              coords1.vertex(sides[i][1]);
  
!             glSecondaryColor3fEXT(1, 1, 1);
  
!             float w = wtbl[i];
  
              glTexCoord4f(tex1.x * w, tex1.y * w, 0, w);
              coords1.vertex(sides[i][2]);
***************
*** 725,780 ****
              glTexCoord4f(tex0.x * w, tex0.y * w, 0, w);
              coords1.vertex(sides[i][3]);
  
-             //cout << tex0 << coords1.transform(sides[i][0]) << "\\n";
-             //cout << tex1 << coords1.transform(sides[i][1]) << "\\n";
-             //cout << tex1 << w << coords1.transform(sides[i][2]) << "\\n";
-             //cout << tex0 << w << coords1.transform(sides[i][3]) << "\\n";
          }
          glEnd();
  
-         Pt corners[4][4] = { { Pt(x0, y0), Pt(x0b, y0), Pt(x0, y0b), Pt(x0b, 
y0b) },
-                              { Pt(x1, y0), Pt(x1b, y0), Pt(x1, y0b), Pt(x1b, 
y0b) },
-                              { Pt(x0, y1), Pt(x0b, y1), Pt(x0, y1b), Pt(x0b, 
y1b) },
-                              { Pt(x1, y1), Pt(x1b, y1), Pt(x1, y1b), Pt(x1b, 
y1b) } };
- 
-         float w = 1E-4;
-         glBegin(GL_QUADS);
-         for (int i = 0; i < 4; i++) {
-            ZPt tex0 = cs2inv.transform(coords1.transform(lerp(texf, 
corners[i][0], corners[i][1])));
-            ZPt tex1 = cs2inv.transform(coords1.transform(lerp(texf, 
corners[i][0], corners[i][2])));
- 
-            glSecondaryColor3fEXT(1, 1, 1);
- 
-            glTexCoord4f(tex1.x * w, tex1.y * w, 0, w);
-            coords1.vertex(corners[i][0]);
- 
-            glTexCoord4f(tex0.x * w, tex0.y * w, 0, w);
-            coords1.vertex(corners[i][0]);
- 
-            glSecondaryColor3fEXT(0, 0, 0);
- 
-            glTexCoord2f(tex0.x, tex0.y);
-            coords1.vertex(corners[i][1]);
- 
-            glTexCoord2f(tex1.x, tex1.y);
-            coords1.vertex(corners[i][2]);
- 
-          }
-         glEnd();
-         GLERR;
- 
          glDisable(GL_REGISTER_COMBINERS_NV);
          glDisable(GL_TEXTURE_2D);
          glBegin(GL_QUADS);
!         coords1.vertex(Pt(x0,y0));
!         coords1.vertex(Pt(x1,y0));
!         coords1.vertex(Pt(x1,y1));
!         coords1.vertex(Pt(x0,y1));
          glEnd();
          GLERR;
  
          glPopAttrib();
- 
      """,
  }    ,
  
--- 734,763 ----
              glTexCoord4f(tex0.x * w, tex0.y * w, 0, w);
              coords1.vertex(sides[i][3]);
  
          }
          glEnd();
  
          glDisable(GL_REGISTER_COMBINERS_NV);
          glDisable(GL_TEXTURE_2D);
          glBegin(GL_QUADS);
!         coords1.vertex(Pt(-x2,-y1));
!         coords1.vertex(Pt(+x2,-y1));
!         coords1.vertex(Pt(+x2,+y1));
!         coords1.vertex(Pt(-x2,+y1));
! 
!         coords1.vertex(Pt(-x1,-y2));
!         coords1.vertex(Pt(-x1,+y2));
!         coords1.vertex(Pt(-x2,+y1));
!         coords1.vertex(Pt(-x2,-y1));
! 
!         coords1.vertex(Pt(+x1,-y2));
!         coords1.vertex(Pt(+x1,+y2));
!         coords1.vertex(Pt(+x2,+y1));
!         coords1.vertex(Pt(+x2,-y1));
          glEnd();
          GLERR;
  
          glPopAttrib();
      """,
  }    ,
  




reply via email to

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