/[gzz]/gzz/gfx/librenderables/renderables.py
ViewVC logotype

Diff of /gzz/gfx/librenderables/renderables.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28 by jvk, Sun Sep 15 10:22:13 2002 UTC revision 1.29 by jvk, Sun Sep 15 10:49:06 2002 UTC
# Line 526  rs = [ Line 526  rs = [
526          """,          """,
527      "ExtraClass" : """      "ExtraClass" : """
528              //#include "../demo/clamptexture.cxx"              //#include "../demo/clamptexture.cxx"
529                template <class Coords>
530                Pt invtransform(Coords cs, ZPt p) {
531                    ZPt orig = cs.transform(Pt(0, 0));
532                    ZVec e0 =  cs.transform(Pt(1, 0)) - orig;
533                    ZVec e1 =  cs.transform(Pt(0, 1)) - orig;
534    
535                    ZVec v = p - orig;
536    
537                    float m = 1.0 / (e0.x * e1.y - e1.x * e0.y);
538                    float inv[4] = {
539                      m * e1.y, -m * e1.x,
540                      -m * e0.y, m * e0.x
541                    };
542                    return Pt(inv[0] * v.x + inv[1] * v.y,
543                              inv[2] * v.x + inv[3] * v.y/*,
544                              v.z*/);
545                }
546      """,      """,
547      "RenderCode" : """      "RenderCode" : """
548              DBG(dbg) << "Paper\\n";              DBG(dbg) << "Paper\\n";
549              GLERR              GLERR
550    
             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";  
   
551              for(Paper::Paper::iterator it = paper->begin(); it != paper->end(); ++it) {              for(Paper::Paper::iterator it = paper->begin(); it != paper->end(); ++it) {
552                  if (dbg) cout << "Pass\\n";                  if (dbg) cout << "Pass\\n";
553    
# Line 560  rs = [ Line 559  rs = [
559                  //clampTexture2D(1.0);                  //clampTexture2D(1.0);
560    
561                  Pt p[] = { Pt(0,0), Pt(0,1), Pt(1,1), Pt(1,0) };                  Pt p[] = { Pt(0,0), Pt(0,1), Pt(1,1), Pt(1,0) };
562                    Pt q;
563    
564                  // Draw the first texture                  // Draw the first texture
565                  (*it).setupcode();                  (*it).setupcode();
# Line 571  rs = [ Line 571  rs = [
571                  for (int i = 0; i < 4; i++) {                  for (int i = 0; i < 4; i++) {
572                      ZPt v = coords1.transform(p[i]);                      ZPt v = coords1.transform(p[i]);
573                      glMultiTexCoord2fARB(0, p[i].x, p[i].y);                      glMultiTexCoord2fARB(0, p[i].x, p[i].y);
574                      glMultiTexCoord2fARB(1, c2x.dot(v - c2orig),                      q = invtransform(coords2, v);
575                                              c2y.dot(v - c2orig));                      glMultiTexCoord2fARB(1, q.x, q.y);
                     //cout << Pt(c2x.dot(v - c2orig),  
                     //           c2y.dot(v - c2orig)) << "\\n";  
576                      coords1.vertex(p[i]);                      coords1.vertex(p[i]);
577                  }                  }
578                  glEnd();                  glEnd();
# Line 592  rs = [ Line 590  rs = [
590                  for (int i = 0; i < 4; i++) {                  for (int i = 0; i < 4; i++) {
591                      ZPt v = coords2.transform(p[i]);                      ZPt v = coords2.transform(p[i]);
592                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);
593                      glMultiTexCoord2fARB(0, c1x.dot(v - c1orig),                      q = invtransform(coords1, v);
594                                              c1y.dot(v - c1orig));                      glMultiTexCoord2fARB(0, q.x, q.y);
                     //cout << Pt(c1x.dot(v - c1orig),  
                     //           c1y.dot(v - c1orig)) << "\\n";  
595                      coords2.vertex(p[i]);                      coords2.vertex(p[i]);
596                  }                  }
597                  glEnd();                  glEnd();
# Line 613  rs = [ Line 609  rs = [
609                  for (int i = 0; i < 4; i++) {                  for (int i = 0; i < 4; i++) {
610                      ZPt v = coords2.transform(p[i]);                      ZPt v = coords2.transform(p[i]);
611                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);                      glMultiTexCoord2fARB(1, p[i].x, p[i].y);
612                      glMultiTexCoord2fARB(0, c1x.dot(v - c1orig),                      q = invtransform(coords1, v);
613                                              c1y.dot(v - c1orig));                      glMultiTexCoord2fARB(0, q.x, q.y);
                     //cout << Pt(c1x.dot(v - c1orig),  
                     //           c1y.dot(v - c1orig)) << "\\n";  
614                      coords2.vertex(p[i]);                      coords2.vertex(p[i]);
615                  }                  }
616                  glEnd();                  glEnd();

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26