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: Sat, 28 Sep 2002 06:03:16 -0400

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

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

Log message:
        Do dicing-preserving explicit clipping of the inside of IrregularQuad

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregular2.py.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.77&tr2=1.78&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregular2.py
diff -c gzz/gfx/demo/irregular2.py:1.21 gzz/gfx/demo/irregular2.py:1.22
*** gzz/gfx/demo/irregular2.py:1.21     Fri Sep 27 14:22:59 2002
--- gzz/gfx/demo/irregular2.py  Sat Sep 28 06:03:16 2002
***************
*** 38,44 ****
              End
          """ % locals())
  
!       self.irreguframe = IrreguFrame(self.border, w, h, self.period)
  
      def key(self, k):
          if 0: pass
--- 38,44 ----
              End
          """ % locals())
  
!       self.irreguframe = IrreguFrame(-w, -h, w, h, self.border, self.period)
  
      def key(self, k):
          if 0: pass
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.77 
gzz/gfx/librenderables/renderables.py:1.78
*** gzz/gfx/librenderables/renderables.py:1.77  Sat Sep 28 05:59:03 2002
--- gzz/gfx/librenderables/renderables.py       Sat Sep 28 06:03:16 2002
***************
*** 592,597 ****
--- 592,623 ----
                  coords1.vertex(p);
                DBG(dbg) << "Vert: " << q<<p<<coords1.transform(p) <<"\\n";
              }
+ 
+ 
+             // Slide v1 into [x0,x1]x[y0,y1]
+             template <class Coords>
+             void vert(Coords& coords1, ZPt v1) {
+                 if (v1.x < x0) v1.x = x0;
+                 if (v1.x > x1) v1.x = x1;
+                 if (v1.y < y0) v1.y = y0;
+                 if (v1.y > y1) v1.y = y1;
+                 coords1.vertex(v1);
+             }
+ 
+             // Do vert(coords1, v) for any crossings and then vert(coords1, 
v1)
+             template <class Coords>
+             void vert(Coords& coords1, ZPt v0, ZPt v1) {
+                 ZPt v;
+                      if ((v0.x - x0) * (v1.x - x0) < 0) v = lerp(v0, v1, (x0 
- v0.x) / (v1.x - v0.x));
+                 else if ((v0.x - x1) * (v1.x - x1) < 0) v = lerp(v0, v1, (x1 
- v0.x) / (v1.x - v0.x));
+                 else if ((v0.y - y0) * (v1.y - y0) < 0) v = lerp(v0, v1, (y0 
- v0.y) / (v1.y - v0.y));
+                 else if ((v0.y - y1) * (v1.y - y1) < 0) v = lerp(v0, v1, (y1 
- v0.y) / (v1.y - v0.y));
+                 else {
+                     return vert(coords1, v1);
+                 }
+                 vert(coords1, v0, v);
+                 vert(coords1, v, v1);
+             }
      """,
      "RenderCode" : """
          DBG(dbg) << "Irregular quad\\n";
***************
*** 705,710 ****
--- 731,759 ----
                         ZPt(+x2,-y1,0), ZPt(+x1,-y2,0), ZPt(+x1,+y2,0) };
          int dice[] = { diceb, dicex, diceb, dicey, diceb, dicex, diceb, dicey 
};
  
+         #if 1
+         ZPt poly2[9];
+         for (int i = 0; i < 9; i++) poly2[i] = coords2.transform(poly[i]);
+ 
+         // Disable the effect of TEXTURE1 as the clipping is done explicitly
+         glMultiTexCoord2f(1, .5, .5);
+         
+         glBegin(GL_TRIANGLE_FAN);
+         vert(coords1, coords2.transform(ZPt(0,0,0)));
+         ZPt prev = poly2[0];
+         for (int i = 0; i < 8; i++) {
+             for (int d = 0; d < dice[i]; d++) {
+                 float t = (float)d / dice[i];
+                 ZPt v = lerp(poly2[i], poly2[i+1], t);
+                 vert(coords1, prev, v);
+                 prev = v;
+             }
+         }
+         vert(coords1, prev, poly2[0]);
+         glEnd();
+ 
+         #else
+ 
          glBegin(GL_TRIANGLE_FAN);
          vert(coords1, coords2, ZPt(0,0,0));
          for (int i = 0; i < 8; i++) {
***************
*** 714,719 ****
--- 763,769 ----
              }
          }
          glEnd();
+         #endif
  
          if (mode) glPopMatrix();
  




reply via email to

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