/[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.40 by jvk, Tue Sep 17 13:13:38 2002 UTC revision 1.41 by jvk, Tue Sep 17 14:51:18 2002 UTC
# Line 656  rs = [ Line 656  rs = [
656  {  {
657      "Type" : "2",      "Type" : "2",
658      "Name": "IrregularQuad",      "Name": "IrregularQuad",
659      "Data": "float border; int mode; CallGLCode setup;",      "Data": "float border; float cs2w; int mode; CallGLCode setup;",
660      "Params" : """      "Params" : """
661              float border, int mode, String setupcode              float border, float cs2w, int mode, String setupcode
662          """,          """,
663      "ParamCode" : """      "ParamCode" : """
664              this->border = border;              this->border = border;
665                this->cs2w = cs2w;
666              this->mode = mode;              this->mode = mode;
667              setup = CallGLCode(string(setupcode.begin(), setupcode.end()).c_str());              setup = CallGLCode(string(setupcode.begin(), setupcode.end()).c_str());
668          """,          """,
# Line 680  rs = [ Line 681  rs = [
681          AffineCoords cs1inv = coords1.getInverse();          AffineCoords cs1inv = coords1.getInverse();
682          AffineCoords cs2inv = coords2.getInverse();          AffineCoords cs2inv = coords2.getInverse();
683    
         Vec xvec = coords1.transform(Vec(1,0));  
         Vec yvec = coords1.transform(Vec(0,1));  
   
684          // Normalize unit vectors inside coords2 to get border widths          // Normalize unit vectors inside coords2 to get border widths
685          float bx = border * cs1inv.transform(coords2.transform(cs2inv.transform(xvec).normalize())).length();          float bx = border * cs1inv.transform(coords2.transform(cs2inv.transform(coords1.x).normalize())).x;
686          float by = border * cs1inv.transform(coords2.transform(cs2inv.transform(yvec).normalize())).length();          float by = border * cs1inv.transform(coords2.transform(cs2inv.transform(coords1.y).normalize())).y;
687          Vec xpix = xvec.normalize()*2;          const float TWO = 2;
688          Vec ypix = yvec.normalize()*2;          Vec xpix = coords1.x.normalize()*TWO;
689            Vec ypix = coords1.y.normalize()*TWO;
690          const float x0 = 1;  
691          const float x1 = 1 - bx;          float x0 = 1;
692          const float x2 = 1 - 2 * bx;          float x1 = 1 - bx;
693          const float y0 = 1;          float x2 = 1 - 2 * bx;
694          const float y1 = 1 - by;          float y0 = 1;
695          const float y2 = 1 - 2 * by;          float y1 = 1 - by;
696          const float w = .5;          float y2 = 1 - 2 * by;
697            float w = .5;
698    
699          // scale of last two vertices of sides          // scale of last two vertices of sides
700          float wtbl[] = { 1, 1, 1, 1, w, w, w, w };          float wtbl[] = { 1, 1, 1, 1, w, w, w, w };
# Line 729  rs = [ Line 728  rs = [
728          float texf = 0.5;          float texf = 0.5;
729    
730          glActiveTexture(GL_TEXTURE1);          glActiveTexture(GL_TEXTURE1);
731          float svec[4] = { cs2inv.x.x*.25, cs2inv.y.x*.25, 0, cs2inv.center.x*.25+.5 };          glPushMatrix();
732          float tvec[4] = { cs2inv.x.y*.25, cs2inv.y.y*.25, 0, cs2inv.center.y*.25+.5 };          AffineCoords cs2 = coords2;
733          glTexGenfv(GL_S, GL_OBJECT_PLANE, svec);          if (mode) {
734          glTexGenfv(GL_T, GL_OBJECT_PLANE, tvec);              // Make the bounding box 2 pixels larger when drawing the boundary
735                cs2.x = cs2.x + TWO / cs2w * cs2.x.normalize();
736                cs2.y = cs2.y + TWO * cs2.y.normalize();
737            }
738            cs2.performGL();
739            float svec[4] = { .25 / cs2w, 0, 0, .5 };
740            float tvec[4] = { 0, .25, 0, .5 };
741            glTexGenfv(GL_S, GL_EYE_PLANE, svec);
742            glTexGenfv(GL_T, GL_EYE_PLANE, tvec);
743            glPopMatrix();
744          glActiveTexture(GL_TEXTURE0);          glActiveTexture(GL_TEXTURE0);
745    
746          for (unsigned i = 0; i < sizeof(sides)/sizeof(sides[0]); i++) {          for (unsigned i = 0; i < sizeof(sides)/sizeof(sides[0]); i++) {
# Line 774  rs = [ Line 782  rs = [
782          glDisable(GL_REGISTER_COMBINERS_NV);          glDisable(GL_REGISTER_COMBINERS_NV);
783          glDisable(GL_TEXTURE_2D);          glDisable(GL_TEXTURE_2D);
784    
785          for (int t = 0; t < (mode ? 4 : 1); t++) {          // The inside octagon needs to be drawn for the border, too,
786              if (mode) {          // because of cs2-clipping
787                  glPushMatrix();  
788                  Vec trans = ((t & 1) ? xpix : -xpix) + ((t & 2) ? ypix : -ypix);          // Draw the inside two pixels larger when drawing the border
789                  glTranslatef(trans.x, trans.y, 0);          // Note: the two pixels are only visible when the ripple function
790              }          // clamps against the inside octagon
791                        if (mode) {
792               float dx = cs1inv.transform(xpix).x;
793               float dy = cs1inv.transform(ypix).y;
794               x1 += dx;
795               x2 += dx;
796               y1 += dy;
797               y2 += dy;
798            }
799            
800              glBegin(GL_QUADS);              glBegin(GL_QUADS);
801              coords1.vertex(Pt(-x2,-y1));              coords1.vertex(Pt(-x2,-y1));
802              coords1.vertex(Pt(+x2,-y1));              coords1.vertex(Pt(+x2,-y1));
# Line 799  rs = [ Line 815  rs = [
815              glEnd();              glEnd();
816              GLERR;              GLERR;
817    
             if (mode) glPopMatrix();  
         }  
818    
819          glPopAttrib();          glPopAttrib();
820      """,      """,

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

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