/[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.39 by jvk, Tue Sep 17 11:14:05 2002 UTC revision 1.40 by jvk, Tue Sep 17 13:13:38 2002 UTC
# Line 656  rs = [ Line 656  rs = [
656  {  {
657      "Type" : "2",      "Type" : "2",
658      "Name": "IrregularQuad",      "Name": "IrregularQuad",
659      "Data": "float border; CallGLCode setup;",      "Data": "float border; int mode; CallGLCode setup;",
660      "Params" : """      "Params" : """
661              float border, String setupcode              float border, int mode, String setupcode
662          """,          """,
663      "ParamCode" : """      "ParamCode" : """
664              this->border = border;              this->border = border;
665                this->mode = mode;
666              setup = CallGLCode(string(setupcode.begin(), setupcode.end()).c_str());              setup = CallGLCode(string(setupcode.begin(), setupcode.end()).c_str());
667          """,          """,
668      "ExtraClass" : """      "ExtraClass" : """
# Line 679  rs = [ Line 680  rs = [
680          AffineCoords cs1inv = coords1.getInverse();          AffineCoords cs1inv = coords1.getInverse();
681          AffineCoords cs2inv = coords2.getInverse();          AffineCoords cs2inv = coords2.getInverse();
682    
683            Vec xvec = coords1.transform(Vec(1,0));
684            Vec yvec = coords1.transform(Vec(0,1));
685    
686          // Normalize unit vectors inside coords2 to get border widths          // Normalize unit vectors inside coords2 to get border widths
687          float bx = border * cs1inv.transform(coords2.transform(cs2inv.transform(coords1.transform(Vec(1,0))).normalize())).length();          float bx = border * cs1inv.transform(coords2.transform(cs2inv.transform(xvec).normalize())).length();
688          float by = border * cs1inv.transform(coords2.transform(cs2inv.transform(coords1.transform(Vec(0,1))).normalize())).length();          float by = border * cs1inv.transform(coords2.transform(cs2inv.transform(yvec).normalize())).length();
689            Vec xpix = xvec.normalize()*2;
690            Vec ypix = yvec.normalize()*2;
691    
692          const float x0 = 1;          const float x0 = 1;
693          const float x1 = 1 - bx;          const float x1 = 1 - bx;
# Line 706  rs = [ Line 712  rs = [
712                             { Pt(-x2, -y0), Pt(-x0, -y2), Pt(-x1, -y2), Pt(-x2, -y1) }                             { Pt(-x2, -y0), Pt(-x0, -y2), Pt(-x1, -y2), Pt(-x2, -y1) }
713                             };                             };
714    
715            float m = 1 / sqrt(2);
716            Vec trans[][3] = { { -xpix, -ypix,  ypix },
717                               {  xpix, -ypix,  ypix },
718                               { -ypix, -xpix,  xpix },
719                               {  ypix, -xpix,  xpix },
720                               { m * ( xpix + ypix), m * ( xpix - ypix), m * (-xpix + ypix) },
721                               { m * ( xpix - ypix), m * ( xpix + ypix), m * (-xpix - ypix) },
722                               { m * (-xpix + ypix), m * (-xpix - ypix), m * ( xpix + ypix) },
723                               { m * (-xpix - ypix), m * (-xpix + ypix), m * ( xpix - ypix) } };
724            
725    
726          /* The distance (as a fraction of border) from the square where the 1D texture slice is taken.          /* The distance (as a fraction of border) from the square where the 1D texture slice is taken.
727           * Smaller number lowers the frequency of the corner pieces           * Smaller number lowers the frequency of the corner pieces
728           */           */
729          float texf = 0.5;          float texf = 0.5;
730    
731          glBegin(GL_QUADS);          glActiveTexture(GL_TEXTURE1);
732            float svec[4] = { cs2inv.x.x*.25, cs2inv.y.x*.25, 0, cs2inv.center.x*.25+.5 };
733            float tvec[4] = { cs2inv.x.y*.25, cs2inv.y.y*.25, 0, cs2inv.center.y*.25+.5 };
734            glTexGenfv(GL_S, GL_OBJECT_PLANE, svec);
735            glTexGenfv(GL_T, GL_OBJECT_PLANE, tvec);
736            glActiveTexture(GL_TEXTURE0);
737    
738          for (unsigned i = 0; i < sizeof(sides)/sizeof(sides[0]); i++) {          for (unsigned i = 0; i < sizeof(sides)/sizeof(sides[0]); i++) {
739              ZPt tex0 = cs2inv.transform(coords1.transform(lerp(texf, sides[i][3], sides[i][0])));              ZPt tex0 = cs2inv.transform(coords1.transform(lerp(texf, sides[i][3], sides[i][0])));
740              ZPt tex1 = cs2inv.transform(coords1.transform(lerp(texf, sides[i][2], sides[i][1])));              ZPt tex1 = cs2inv.transform(coords1.transform(lerp(texf, sides[i][2], sides[i][1])));
741    
742              glSecondaryColor3fEXT(0, 0, 0);              for (int t = 0; t < (mode ? 3 : 1); t++) {
743                    if (mode) {
744              glTexCoord2f(tex0.x, tex0.y);                      glPushMatrix();
745              coords1.vertex(sides[i][0]);                      glTranslatef(trans[i][t].x, trans[i][t].y, 0);
746                    }
747              glTexCoord2f(tex1.x, tex1.y);              
748              coords1.vertex(sides[i][1]);                  glBegin(GL_QUADS);
749                    glSecondaryColor3fEXT(0, 0, 0);
750              glSecondaryColor3fEXT(1, 1, 1);  
751                    glTexCoord2f(tex0.x, tex0.y);
752              float w = wtbl[i];                  coords1.vertex(sides[i][0]);
753    
754              glTexCoord4f(tex1.x * w, tex1.y * w, 0, w);                  glTexCoord2f(tex1.x, tex1.y);
755              coords1.vertex(sides[i][2]);                  coords1.vertex(sides[i][1]);
756    
757              glTexCoord4f(tex0.x * w, tex0.y * w, 0, w);                  glSecondaryColor3fEXT(1, 1, 1);
758              coords1.vertex(sides[i][3]);  
759                    float w = wtbl[i];
760    
761                    glTexCoord4f(tex1.x * w, tex1.y * w, 0, w);
762                    coords1.vertex(sides[i][2]);
763                    
764                    glTexCoord4f(tex0.x * w, tex0.y * w, 0, w);
765                    coords1.vertex(sides[i][3]);
766                    
767                    glEnd();
768                    GLERR;
769    
770                    if (mode) glPopMatrix();
771                }
772          }          }
773          glEnd();          
   
774          glDisable(GL_REGISTER_COMBINERS_NV);          glDisable(GL_REGISTER_COMBINERS_NV);
775          glDisable(GL_TEXTURE_2D);          glDisable(GL_TEXTURE_2D);
776          glBegin(GL_QUADS);  
777          coords1.vertex(Pt(-x2,-y1));          for (int t = 0; t < (mode ? 4 : 1); t++) {
778          coords1.vertex(Pt(+x2,-y1));              if (mode) {
779          coords1.vertex(Pt(+x2,+y1));                  glPushMatrix();
780          coords1.vertex(Pt(-x2,+y1));                  Vec trans = ((t & 1) ? xpix : -xpix) + ((t & 2) ? ypix : -ypix);
781                    glTranslatef(trans.x, trans.y, 0);
782          coords1.vertex(Pt(-x1,-y2));              }
783          coords1.vertex(Pt(-x1,+y2));              
784          coords1.vertex(Pt(-x2,+y1));              glBegin(GL_QUADS);
785          coords1.vertex(Pt(-x2,-y1));              coords1.vertex(Pt(-x2,-y1));
786                coords1.vertex(Pt(+x2,-y1));
787          coords1.vertex(Pt(+x1,-y2));              coords1.vertex(Pt(+x2,+y1));
788          coords1.vertex(Pt(+x1,+y2));              coords1.vertex(Pt(-x2,+y1));
789          coords1.vertex(Pt(+x2,+y1));              
790          coords1.vertex(Pt(+x2,-y1));              coords1.vertex(Pt(-x1,-y2));
791          glEnd();              coords1.vertex(Pt(-x1,+y2));
792          GLERR;              coords1.vertex(Pt(-x2,+y1));
793                coords1.vertex(Pt(-x2,-y1));
794                
795                coords1.vertex(Pt(+x1,-y2));
796                coords1.vertex(Pt(+x1,+y2));
797                coords1.vertex(Pt(+x2,+y1));
798                coords1.vertex(Pt(+x2,-y1));
799                glEnd();
800                GLERR;
801    
802                if (mode) glPopMatrix();
803            }
804    
805          glPopAttrib();          glPopAttrib();
806      """,      """,

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.40

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