gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/paperbasis.py librenderables/rende...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/paperbasis.py librenderables/rende...
Date: Sun, 15 Sep 2002 06:49:07 -0400

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

Modified files:
        gfx/demo       : paperbasis.py 
        gfx/librenderables: renderables.py 

Log message:
        Add proper inverse transformation of an affine coordsys so that 
BasisPaperQuad works for non-orthogonal texcoord mappings

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/paperbasis.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.28&tr2=1.29&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/paperbasis.py
diff -c gzz/gfx/demo/paperbasis.py:1.3 gzz/gfx/demo/paperbasis.py:1.4
*** gzz/gfx/demo/paperbasis.py:1.3      Sun Sep 15 06:22:13 2002
--- gzz/gfx/demo/paperbasis.py  Sun Sep 15 06:49:06 2002
***************
*** 111,116 ****
--- 111,117 ----
          self.pq = getpaper(self.seed)
  
      def key(self, k):
+         global tex0comb,tex1comb,isectcomb
          global x0, y0, x1, y1
          oldseed = self.seed
          if k == "v":
***************
*** 120,138 ****
          elif k == "Left": x0 -= 20
          elif k == "Right": x0 += 20
          elif k == "F1":
-             global tex0comb
              list = tex0codes.keys()
              tex0comb = list[(list.index(tex0comb) + 1) % len(list)]
              print "Using", tex0comb, tex1comb, isectcomb, "combiners"
              self.initpaper()
          elif k == "F2":
-             global tex1comb
              list = tex1codes.keys()
              tex1comb = list[(list.index(tex1comb) + 1) % len(list)]
              print "Using", tex0comb, tex1comb, isectcomb, "combiners"
              self.initpaper()
          elif k == "F3":
-             global isectcomb
              list = isectcodes.keys()
              isectcomb = list[(list.index(isectcomb) + 1) % len(list)]
              print "Using", tex0comb, tex1comb, isectcomb, "combiners"
--- 121,136 ----
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.28 
gzz/gfx/librenderables/renderables.py:1.29
*** gzz/gfx/librenderables/renderables.py:1.28  Sun Sep 15 06:22:13 2002
--- gzz/gfx/librenderables/renderables.py       Sun Sep 15 06:49:06 2002
***************
*** 526,554 ****
        """,
      "ExtraClass" : """
              //#include "../demo/clamptexture.cxx"
      """,
      "RenderCode" : """
            DBG(dbg) << "Paper\\n";
            GLERR
  
-             ZPt c1orig = coords1.transform(Pt(0, 0));
-             ZVec c1x =  coords1.transform(Pt(1, 0)) - c1orig;
-             ZVec c1y =  coords1.transform(Pt(0, 1)) - c1orig;
- 
-             c1x = 1.0 / (c1x.x * c1x.x + c1x.y * c1x.y) * c1x;
-             c1y = 1.0 / (c1y.x * c1y.x + c1y.y * c1y.y) * c1y;
- 
-             ZPt c2orig = coords2.transform(Pt(0, 0));
-             ZVec c2x =  coords2.transform(Pt(1, 0)) - c2orig;
-             ZVec c2y =  coords2.transform(Pt(0, 1)) - c2orig;
- 
-             c2x = 1.0 / (c2x.x * c2x.x + c2x.y * c2x.y) * c2x;
-             c2y = 1.0 / (c2y.x * c2y.x + c2y.y * c2y.y) * c2y;
- 
- 
-             //cout << c1orig << c1x << c1y << "\\n";
-             //cout << c2orig << c2x << c2y << "\\n";
- 
            for(Paper::Paper::iterator it = paper->begin(); it != paper->end(); 
++it) {
                if (dbg) cout << "Pass\\n";
  
--- 526,553 ----
        """,
      "ExtraClass" : """
              //#include "../demo/clamptexture.cxx"
+             template <class Coords>
+             Pt invtransform(Coords cs, ZPt p) {
+                 ZPt orig = cs.transform(Pt(0, 0));
+                 ZVec e0 =  cs.transform(Pt(1, 0)) - orig;
+                 ZVec e1 =  cs.transform(Pt(0, 1)) - orig;
+ 
+                 ZVec v = p - orig;
+ 
+                 float m = 1.0 / (e0.x * e1.y - e1.x * e0.y);
+                 float inv[4] = {
+                   m * e1.y, -m * e1.x,
+                   -m * e0.y, m * e0.x
+                 };
+                 return Pt(inv[0] * v.x + inv[1] * v.y,
+                           inv[2] * v.x + inv[3] * v.y/*,
+                           v.z*/);
+             }
      """,
      "RenderCode" : """
            DBG(dbg) << "Paper\\n";
            GLERR
  
            for(Paper::Paper::iterator it = paper->begin(); it != paper->end(); 
++it) {
                if (dbg) cout << "Pass\\n";
  
***************
*** 560,565 ****
--- 559,565 ----
                  //clampTexture2D(1.0);
  
                  Pt p[] = { Pt(0,0), Pt(0,1), Pt(1,1), Pt(1,0) };
+                 Pt q;
  
                  // Draw the first texture
                  (*it).setupcode();
***************
*** 571,580 ****
                  for (int i = 0; i < 4; i++) {
                      ZPt v = coords1.transform(p[i]);
                      glMultiTexCoord2fARB(0, p[i].x, p[i].y);
!                     glMultiTexCoord2fARB(1, c2x.dot(v - c2orig),
!                                             c2y.dot(v - c2orig));
!                     //cout << Pt(c2x.dot(v - c2orig),
!                     //           c2y.dot(v - c2orig)) << "\\n";
                      coords1.vertex(p[i]);
                  }
                  glEnd();
--- 571,578 ----
                  for (int i = 0; i < 4; i++) {
                      ZPt v = coords1.transform(p[i]);
                      glMultiTexCoord2fARB(0, p[i].x, p[i].y);
!                     q = invtransform(coords2, v);
!                     glMultiTexCoord2fARB(1, q.x, q.y);
                      coords1.vertex(p[i]);
                  }
                  glEnd();
***************
*** 592,601 ****
                  for (int i = 0; i < 4; i++) {
                      ZPt v = coords2.transform(p[i]);
                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);
!                     glMultiTexCoord2fARB(0, c1x.dot(v - c1orig),
!                                             c1y.dot(v - c1orig));
!                     //cout << Pt(c1x.dot(v - c1orig),
!                     //           c1y.dot(v - c1orig)) << "\\n";
                      coords2.vertex(p[i]);
                  }
                  glEnd();
--- 590,597 ----
                  for (int i = 0; i < 4; i++) {
                      ZPt v = coords2.transform(p[i]);
                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);
!                     q = invtransform(coords1, v);
!                     glMultiTexCoord2fARB(0, q.x, q.y);
                      coords2.vertex(p[i]);
                  }
                  glEnd();
***************
*** 613,622 ****
                  for (int i = 0; i < 4; i++) {
                      ZPt v = coords2.transform(p[i]);
                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);
!                     glMultiTexCoord2fARB(0, c1x.dot(v - c1orig),
!                                             c1y.dot(v - c1orig));
!                     //cout << Pt(c1x.dot(v - c1orig),
!                     //           c1y.dot(v - c1orig)) << "\\n";
                      coords2.vertex(p[i]);
                  }
                  glEnd();
--- 609,616 ----
                  for (int i = 0; i < 4; i++) {
                      ZPt v = coords2.transform(p[i]);
                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);
!                     q = invtransform(coords1, v);
!                     glMultiTexCoord2fARB(0, q.x, q.y);
                      coords2.vertex(p[i]);
                  }
                  glEnd();




reply via email to

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