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: Thu, 26 Sep 2002 09:15:21 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/09/26 09:15:21

Modified files:
        gfx/demo       : irregular2.py 
        gfx/librenderables: renderables.py 
        gfx/libutil    : effects.py 

Log message:
        Fix IrregularQuad; coords2.getInverse() does not seem to work properly 
and coordsys animation is broken at least in irregular2.py

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregular2.py.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.63&tr2=1.64&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/effects.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregular2.py
diff -c gzz/gfx/demo/irregular2.py:1.16 gzz/gfx/demo/irregular2.py:1.17
*** gzz/gfx/demo/irregular2.py:1.16     Thu Sep 26 04:31:24 2002
--- gzz/gfx/demo/irregular2.py  Thu Sep 26 09:15:21 2002
***************
*** 14,21 ****
          self.w, self.h = 2, 1.5
          self.initirregu()
  
!         self.x1, self.y1 = 600, 450
!         self.xs, self.ys = 200, 100
          self.scale = 1
  
      def initirregu(self):
--- 14,23 ----
          self.w, self.h = 2, 1.5
          self.initirregu()
  
!         #self.x1, self.y1 = 600, 450
!         #self.xs, self.ys = 200, 100
!         self.x1, self.y1 = 0, 0
!         self.xs, self.ys = 1, 1
          self.scale = 1
  
      def initirregu(self):
***************
*** 38,51 ****
  
      def key(self, k):
          if 0: pass
!         elif k == "Up": self.y1 -= 50
!         elif k == "Down": self.y1 += 50
!         elif k == "Left": self.x1 -= 50
!         elif k == "Right": self.x1 += 50
!         elif k == "x": self.xs += 50
!         elif k == "X": self.xs -= 50
!         elif k == "y": self.ys += 50
!         elif k == "Y": self.ys -= 50
          elif k == "+": self.scale += .1
          elif k == "-": self.scale -= .1
          elif k == "c":
--- 40,53 ----
  
      def key(self, k):
          if 0: pass
!         elif k == "Up": self.y1 -= .1
!         elif k == "Down": self.y1 += .1
!         elif k == "Left": self.x1 -= .1
!         elif k == "Right": self.x1 += .1
!         elif k == "x": self.xs += .1
!         elif k == "X": self.xs -= .1
!         elif k == "y": self.ys += .1
!         elif k == "Y": self.ys -= .1
          elif k == "+": self.scale += .1
          elif k == "-": self.scale -= .1
          elif k == "c":
***************
*** 72,85 ****
  
          #putnoc(vs, getDListNocoords("Translate -1000 -1000 0\nScale 4 4 
4\n"))
  
!         cs1 = vs.coords.affineCoordsys(0, 10, self.x1, self.y1, self.xs, 0, 
0, self.ys)
!       vs.matcher.add(cs1, "1")
!         cs2 = vs.coords.affineCoordsys(0, 10, 600, 450,
                                         self.scale * 150,
                                         self.scale * 32.3,
                                         self.scale * -14.2,
                                         self.scale * 150)
!       vs.matcher.add(cs2, "2")
          #vs.map.put(self.mask, cs2)
  
          if self.mode & 4:
--- 74,88 ----
  
          #putnoc(vs, getDListNocoords("Translate -1000 -1000 0\nScale 4 4 
4\n"))
  
!         #cs2 = vs.coords.affineCoordsys(0, 10, self.x1, self.y1, self.xs, 0, 
0, self.ys)
!         cs2 = vs.coords.affineCoordsys(0, 0, self.x1, self.y1, self.xs, 
-.3*self.ys, +.3*self.xs, self.ys)
!       vs.matcher.add(cs2, "2")
!         cs1 = vs.coords.affineCoordsys(0, 10, 600, 450,
                                         self.scale * 150,
                                         self.scale * 32.3,
                                         self.scale * -14.2,
                                         self.scale * 150)
!       vs.matcher.add(cs1, "1")
          #vs.map.put(self.mask, cs2)
  
          if self.mode & 4:
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.63 
gzz/gfx/librenderables/renderables.py:1.64
*** gzz/gfx/librenderables/renderables.py:1.63  Thu Sep 26 04:31:24 2002
--- gzz/gfx/librenderables/renderables.py       Thu Sep 26 09:15:21 2002
***************
*** 520,526 ****
              this->mode = mode;
              setup = CallGLCode(string(setupcode.begin(), 
setupcode.end()).c_str());
        """,
!     "RenderCode" : "int i=0; i++;",
      "BLAH" : """
          DBG(dbg) << "Irregular quad\\n";
  
--- 520,654 ----
              this->mode = mode;
              setup = CallGLCode(string(setupcode.begin(), 
setupcode.end()).c_str());
        """,
!     "ExtraClass" : """
!             ZPt lerp(float f, ZPt a, ZPt b) {
!                 return ZPt((1 - f) * a.x + f * b.x,
!                            (1 - f) * a.y + f * b.y,
!                            0);
!             }
! 
!             template <class Coords>
!             inline void vert(Coords& coords1, Coords& coords2, ZPt q) {
!                 ZPt p = coords2.transform(q);
!                 glMultiTexCoord2f(1, .25 / cs2w * p.x + .5, .25 / cs2h * p.y 
+ .5);
!                 coords1.vertex(p);
!             }
!     """,
!     "RenderCode" : """
! 
!         setup();
!         GLERR;
! 
!         
!         // Normalize tearaway part unit vectors in paper coords to get border 
widths
!         // Note: we assume that coords2 is an affine transform so that the 
border (ripple) width
!         //       is translation invariant
!         Coords &cs2inv = *coords2.getInverse();
!         ZVec xvec = (coords2.transform(ZPt(1,0,0)) - 
coords2.transform(ZPt(0,0,0))).normalize();
!         ZVec yvec = (coords2.transform(ZPt(0,1,0)) - 
coords2.transform(ZPt(0,0,0))).normalize();
! 
!         //cout << (coords2.transform(ZPt(1,0,0)) - 
coords2.transform(ZPt(0,0,0)))
!         //     << (coords2.transform(ZPt(0,1,0)) - 
coords2.transform(ZPt(0,0,0))) << "\\n";
!         
!         float bx = border * (cs2inv.transform(ZPt(0,0,0) + xvec) - 
cs2inv.transform(ZPt(0,0,0))).length();
!         float by = border * (cs2inv.transform(ZPt(0,0,0) + yvec) - 
cs2inv.transform(ZPt(0,0,0))).length();
! 
!         //cout << bx << "," << by << "\\n";
! 
!         float x0 = 1;
!         float x1 = 1 - bx;
!         float x2 = 1 - 2 * bx;
!         float y0 = 1;
!         float y1 = 1 - by;
!         float y2 = 1 - 2 * by;
!         float w = .5; 
! 
!         // scale of last two vertices of sides 
!         float wtbl[] = { 1, 1, 1, 1, w, w, w, w };
! 
!         ZPt sides[][4] =  { // The sides of the rectangle:
!                            { ZPt(-x0,-y2,0), ZPt(-x0,+y2,0), ZPt(-x1,+y2,0), 
ZPt(-x1,-y2,0) },
!                            { ZPt(+x0,-y2,0), ZPt(+x0,+y2,0), ZPt(+x1,+y2,0), 
ZPt(+x1,-y2,0) },
!                            { ZPt(-x2,-y0,0), ZPt(+x2,-y0,0), ZPt(+x2,-y1,0), 
ZPt(-x2,-y1,0) },
!                            { ZPt(-x2,+y0,0), ZPt(+x2,+y0,0), ZPt(+x2,+y1,0), 
ZPt(-x2,+y1,0) },
!                            // Corners:
!                            { ZPt(+x2,+y0,0), ZPt(+x0,+y2,0), ZPt(+x1,+y2,0), 
ZPt(+x2,+y1,0) },
!                            { ZPt(+x2,-y0,0), ZPt(+x0,-y2,0), ZPt(+x1,-y2,0), 
ZPt(+x2,-y1,0) },
!                            { ZPt(-x2,+y0,0), ZPt(-x0,+y2,0), ZPt(-x1,+y2,0), 
ZPt(-x2,+y1,0) },
!                            { ZPt(-x2,-y0,0), ZPt(-x0,-y2,0), ZPt(-x1,-y2,0), 
ZPt(-x2,-y1,0) }
!                            };
! 
!         /* 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
!          */
!         float texf = 0.5;
! 
!         for (int pass = 0; pass < (mode ? 4 : 1); pass++) {
! 
!         if (mode) {
!             glPushMatrix();
!             glTranslatef((pass & 1) ? -2 : 2,
!                          (pass & 2) ? -2 : 2,
!                          0);
!         }
!         
!         glEnable(GL_REGISTER_COMBINERS_NV);
!         glEnable(GL_TEXTURE_2D);
! 
!         for (unsigned i = 0; i < sizeof(sides)/sizeof(sides[0]); i++) {
!             ZPt tex0 = coords2.transform(lerp(texf, sides[i][3], 
sides[i][0]));
!             ZPt tex1 = coords2.transform(lerp(texf, sides[i][2], 
sides[i][1]));
! 
! 
!             glBegin(GL_QUADS);
!             glSecondaryColor3fEXT(0, 0, 0);
! 
!             glTexCoord2f(tex0.x, tex0.y);
!             vert(coords1, coords2, sides[i][0]);
! 
!             glTexCoord2f(tex1.x, tex1.y);
!             vert(coords1, coords2, sides[i][1]);
! 
!             glSecondaryColor3fEXT(1, 1, 1);
! 
!             float w = wtbl[i];
! 
!             glTexCoord4f(tex1.x * w, tex1.y * w, 0, w);
!             vert(coords1, coords2, sides[i][2]);
!                 
!             glTexCoord4f(tex0.x * w, tex0.y * w, 0, w);
!             vert(coords1, coords2, sides[i][3]);
!                 
!             glEnd();
!             GLERR;
! 
!         }
! 
!         glDisable(GL_REGISTER_COMBINERS_NV);
!         glDisable(GL_TEXTURE_2D);
! 
!         glBegin(GL_POLYGON);
!         
!         vert(coords1, coords2, ZPt(+x1,+y2,0));
!         vert(coords1, coords2, ZPt(+x2,+y1,0));
! 
!         vert(coords1, coords2, ZPt(-x2,+y1,0));
!         vert(coords1, coords2, ZPt(-x1,+y2,0));
! 
!         vert(coords1, coords2, ZPt(-x1,-y2,0));
!         vert(coords1, coords2, ZPt(-x2,-y1,0));
! 
!         vert(coords1, coords2, ZPt(+x2,-y1,0));
!         vert(coords1, coords2, ZPt(+x1,-y2,0));
!         glEnd();
! 
!         if (mode) glPopMatrix();
! 
!         }
! 
!         glPopAttrib();
! 
!         """,
      "BLAH" : """
          DBG(dbg) << "Irregular quad\\n";
  
Index: gzz/gfx/libutil/effects.py
diff -c gzz/gfx/libutil/effects.py:1.4 gzz/gfx/libutil/effects.py:1.5
*** gzz/gfx/libutil/effects.py:1.4      Mon Sep 23 04:37:04 2002
--- gzz/gfx/libutil/effects.py  Thu Sep 26 09:15:21 2002
***************
*** 136,145 ****
                TexParameter TEXTURE_2D TEXTURE_MIN_FILTER NEAREST
                TexParameter TEXTURE_2D TEXTURE_MAG_FILTER NEAREST
  
!                 TexGen S TEXTURE_GEN_MODE EYE_LINEAR
!                 Enable TEXTURE_GEN_S
!                 TexGen T TEXTURE_GEN_MODE EYE_LINEAR
!                 Enable TEXTURE_GEN_T
  
                  ActiveTexture TEXTURE0
  
--- 136,145 ----
                TexParameter TEXTURE_2D TEXTURE_MIN_FILTER NEAREST
                TexParameter TEXTURE_2D TEXTURE_MAG_FILTER NEAREST
  
!                 #TexGen S TEXTURE_GEN_MODE EYE_LINEAR
!                 #Enable TEXTURE_GEN_S
!                 #TexGen T TEXTURE_GEN_MODE EYE_LINEAR
!                 #Enable TEXTURE_GEN_T
  
                  ActiveTexture TEXTURE0
  




reply via email to

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