/[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.33 by jvk, Mon Sep 16 14:39:27 2002 UTC revision 1.34 by jvk, Mon Sep 16 16:35:15 2002 UTC
# Line 707  rs = [ Line 707  rs = [
707                            inv[2] * v.x + inv[3] * v.y/*,                            inv[2] * v.x + inv[3] * v.y/*,
708                            v.z*/);                            v.z*/);
709              }              }
710                Pt lerp(float f, Pt a, Pt b) {
711                    return Pt((1 - f) * a.x + f * b.x,
712                              (1 - f) * a.y + f * b.y);
713                }
714      """,      """,
715      "RenderCode" : """      "RenderCode" : """
716          DBG(dbg) << "Irregular quad\\n";          DBG(dbg) << "Irregular quad\\n";
# Line 723  rs = [ Line 727  rs = [
727          float wy = (y1b - y0b) / (y1 - y0);          float wy = (y1b - y0b) / (y1 - y0);
728    
729    
730          Pt sides[4][4] = { { Pt(x0,y0), Pt(x1, y0), Pt(x1b, y0b), Pt(x0b, y0b) },          Pt sides[4][4] = { { Pt(x0,y0), Pt(x1, y0), Pt(x1, y0b), Pt(x0, y0b) },
731                             { Pt(x0,y1), Pt(x1, y1), Pt(x1b, y1b), Pt(x0b, y1b) },                             { Pt(x0,y1), Pt(x1, y1), Pt(x1, y1b), Pt(x0, y1b) },
732                             { Pt(x0,y0), Pt(x0, y1), Pt(x0b, y1b), Pt(x0b, y0b) },                             { Pt(x0,y0), Pt(x0, y1), Pt(x0b, y1), Pt(x0b, y0) },
733                             { Pt(x1,y0), Pt(x1, y1), Pt(x1b, y1b), Pt(x1b, y0b) } };                             { Pt(x1,y0), Pt(x1, y1), Pt(x1b, y1), Pt(x1b, y0) } };
734    
735            /* The distance (as a fraction of border) from the square where the 1D texture slice is taken.
736             * Smaller number lowers the frequency of the corner pieces
737             */
738            float texf = 0.5;
739    
740          glBegin(GL_QUADS);          glBegin(GL_QUADS);
741          for (int i = 0; i < 4; i++) {          for (int i = 0; i < 4; i++) {
742              Pt tex0 = invtransform(coords2, coords1.transform(sides[i][0]));              Pt tex0 = invtransform(coords2, coords1.transform(lerp(texf, sides[i][0], sides[i][3])));
743              Pt tex1 = invtransform(coords2, coords1.transform(sides[i][1]));              Pt tex1 = invtransform(coords2, coords1.transform(lerp(texf, sides[i][1], sides[i][2])));
744    
745              glSecondaryColor3fEXT(1, 1, 1);              glSecondaryColor3fEXT(1, 1, 1);
746    
# Line 744  rs = [ Line 753  rs = [
753              glSecondaryColor3fEXT(0, 0, 0);              glSecondaryColor3fEXT(0, 0, 0);
754    
755              float w = (i & 2) ? wy : wx;              float w = (i & 2) ? wy : wx;
756                w = 1;
757    
758              glTexCoord4f(tex1.x * w, tex1.y * w, 0, w);              glTexCoord4f(tex1.x * w, tex1.y * w, 0, w);
759              coords1.vertex(sides[i][2]);              coords1.vertex(sides[i][2]);
# Line 757  rs = [ Line 767  rs = [
767              //cout << tex0 << w << coords1.transform(sides[i][3]) << "\\n";              //cout << tex0 << w << coords1.transform(sides[i][3]) << "\\n";
768          }          }
769          glEnd();          glEnd();
770    
771            Pt corners[4][4] = { { Pt(x0, y0), Pt(x0b, y0), Pt(x0, y0b), Pt(x0b, y0b) },
772                                 { Pt(x1, y0), Pt(x1b, y0), Pt(x1, y0b), Pt(x1b, y0b) },
773                                 { Pt(x0, y1), Pt(x0b, y1), Pt(x0, y1b), Pt(x0b, y1b) },
774                                 { Pt(x1, y1), Pt(x1b, y1), Pt(x1, y1b), Pt(x1b, y1b) } };
775    
776            float w = 1E-4;
777            glBegin(GL_QUADS);
778            for (int i = 0; i < 4; i++) {
779               Pt tex0 = invtransform(coords2, coords1.transform(lerp(texf, corners[i][0], corners[i][1])));
780               Pt tex1 = invtransform(coords2, coords1.transform(lerp(texf, corners[i][0], corners[i][2])));
781    
782               glSecondaryColor3fEXT(1, 1, 1);
783    
784               glTexCoord4f(tex1.x * w, tex1.y * w, 0, w);
785               coords1.vertex(corners[i][0]);
786    
787               glTexCoord4f(tex0.x * w, tex0.y * w, 0, w);
788               coords1.vertex(corners[i][0]);
789    
790               glSecondaryColor3fEXT(0, 0, 0);
791    
792               glTexCoord2f(tex0.x, tex0.y);
793               coords1.vertex(corners[i][1]);
794    
795               glTexCoord2f(tex1.x, tex1.y);
796               coords1.vertex(corners[i][2]);
797    
798             }
799            glEnd();
800          GLERR;          GLERR;
801    
802          glDisable(GL_REGISTER_COMBINERS_NV);          glDisable(GL_REGISTER_COMBINERS_NV);

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

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