gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx demo/irregu4.py librenderables/renderab...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/irregu4.py librenderables/renderab...
Date: Mon, 11 Nov 2002 09:13:11 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/11/11 09:13:11

Modified files:
        gfx/demo       : irregu4.py 
        gfx/librenderables: renderables.py 
        gfx/libtexture : irregu.texture 
        gfx/libutil    : Irregu.hxx 

Log message:
        Start implementing different scalings

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu4.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.136&tr2=1.137&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtexture/irregu.texture.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/Irregu.hxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregu4.py
diff -u gzz/gfx/demo/irregu4.py:1.1 gzz/gfx/demo/irregu4.py:1.2
--- gzz/gfx/demo/irregu4.py:1.1 Mon Nov 11 07:46:49 2002
+++ gzz/gfx/demo/irregu4.py     Mon Nov 11 09:13:10 2002
@@ -184,12 +184,23 @@
         outer_code = code % {"tex" : texRGBA.getTexId(),
                              "color" : "0 0 0 0" }
 
+        texscale = 1.0
+        linewidth = 1./128
+        scale_pow = .5
+        border0 = -.5
+        border1 = .5
+        ripple_scale = .25
+
+        texscale, linewidth, scale_pow, border0, border1, ripple_scale
+
         self.inner = GLRen.createIrregularEdge(
-            1.0, -.5, .5, .25, "1 1 1 1", "0 0 0 0", 0, 0,
+            texscale, linewidth, scale_pow, border0, border1, ripple_scale,
+            "1 1 1 1", "0 0 0 0", 0, 0,
             Y_SECCOLOR + SLICE_1D,
             inner_code, 1.0); 
         self.outer = GLRen.createIrregularEdge(
-            1.0, -.5, .5, .25, "1 1 1 1", "0 0 0 0", 3, 0,
+            texscale, linewidth, scale_pow, border0, border1, ripple_scale,
+            "1 1 1 1", "0 0 0 0", 3, 0,
             Y_SECCOLOR + SLICE_1D + DOTVEC_COLOR + INTERP_DOTVEC,
             outer_code, 1.0);
 
@@ -199,7 +210,8 @@
             outer_code = code2 % {"tex" : texINTENSITY.getTexId(),
                                   "color" : "0 0 0 0" }
             self.outer = GLRen.createIrregularEdge(
-                1.0, -.5, .5, .25, "1 1 1 1", "0 0 0 0", 0, 1,
+                texscale, linewidth, scale_pow, border0, border1, ripple_scale,
+                "1 1 1 1", "0 0 0 0", 0, 1,
                 Y_SECCOLOR + SLICE_1D,
                 outer_code, 1.0);
         
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.136 
gzz/gfx/librenderables/renderables.py:1.137
--- gzz/gfx/librenderables/renderables.py:1.136 Mon Nov 11 07:46:49 2002
+++ gzz/gfx/librenderables/renderables.py       Mon Nov 11 09:13:10 2002
@@ -1248,7 +1248,7 @@
         float col0[] = {1,1,1,1};
         float col1[] = {0,0,0,0};
         if (!mode) glColor4f(0,0,0,1);
-        Irregu::draw(coords1, vert, norm, texscale,
+        Irregu::draw(coords1, vert, norm, texscale, 1.0/128, 0,
                      -.5, .5, col0, col1, 3, 0, 
                      Irregu::SLICE_1D + Irregu::Y_SECCOLOR +
                      mode * Irregu::DOTVEC_COLOR + Irregu::INTERP_DOTVEC);
@@ -1278,17 +1278,20 @@
 {
     "Type" : "2",
     "Name": "IrregularEdge",
-    "Data": """float texscale, border0, border1, ripple_scale;
+    "Data": """float texscale, linewidth, scale_pow, border0, border1, 
ripple_scale;
             float col0[4], col1[4]; int angles, multi, flags;
             CallGLCode setup;
            float dicefactor;""",
     "Params" : """
-           float texscale, float border0, float border1, float ripple_scale,
+           float texscale, float linewidth, float scale_pow,
+            float border0, float border1, float ripple_scale,
             String col0, String col1, int angles, int multi, int flags,
             String setupcode, float dicefactor
        """,
     "ParamCode" : """
             this->texscale = texscale;
+            this->linewidth = linewidth;
+            this->scale_pow = scale_pow;
             this->border0 = border0;
             this->border1 = border1;
             this->ripple_scale = ripple_scale;
@@ -1332,7 +1335,7 @@
 
         setup();
         GLERR;
-        Irregu::draw(coords1, vert, norm, texscale,
+        Irregu::draw(coords1, vert, norm, texscale, linewidth, scale_pow,
                      border0, border1, col0, col1, angles, multi, flags);
 
         GLERR;
Index: gzz/gfx/libtexture/irregu.texture
diff -u gzz/gfx/libtexture/irregu.texture:1.15 
gzz/gfx/libtexture/irregu.texture:1.16
--- gzz/gfx/libtexture/irregu.texture:1.15      Sat Nov  2 06:42:42 2002
+++ gzz/gfx/libtexture/irregu.texture   Mon Nov 11 09:13:10 2002
@@ -32,19 +32,16 @@
     FPARAM(quantize, 255);
     FPARAM(angle, 0);
     FPARAM(refsize, 256);
-    enum e_scaling { CONST, LINEAR, SQRT } 
-    scaling = (e_scaling)params->getStringEnum("scaling", 0, 
-                                              "const", "linear", "sqrt", 0);
+    float scaling;
+    scaling = params->getStringEnum("scaling", -1, "const", "sqrt", "linear", 
0) * 0.5;
+    if (scaling < 0) scaling = params->getFloat("scaling", 0);
+
     int angles = (int)params->getFloat("angles", 0);
     
     // Note: radius is specified in texels
     FPARAM(radius, 2);
 
-    switch (scaling) {
-    case CONST: break;
-    case LINEAR: radius *= (width / refsize); break;
-    case SQRT: radius *= sqrt(width / refsize); break;
-    }
+    radius *= pow(width / refsize, scaling);
 
     // Ripple amplitude in texture coordinates
     FPARAM(ripple_scale, 0.25); 
Index: gzz/gfx/libutil/Irregu.hxx
diff -u gzz/gfx/libutil/Irregu.hxx:1.3 gzz/gfx/libutil/Irregu.hxx:1.4
--- gzz/gfx/libutil/Irregu.hxx:1.3      Mon Nov 11 07:46:49 2002
+++ gzz/gfx/libutil/Irregu.hxx  Mon Nov 11 09:13:10 2002
@@ -70,7 +70,7 @@
     template <class Coords>
     void draw(Coords &coords, 
              const vector<ZPt> &pt, const vector<ZVec> &norm, 
-             float texscale,
+             float texscale, float linewidth, float scale_pow,
              float border0, float border1,
              const float col0[], const float col1[],
              int angles, int multi,
@@ -96,7 +96,7 @@
 
        if (flags & SLICE_2D) {
            glBegin(GL_QUAD_STRIP);
-           for (unsigned i = 0; i < pt.size() - 1; i++) {
+           for (unsigned i = 0; i < pt.size(); i++) {
 
                if (flags & DOTVEC_COLOR) {
                    // angle(norm.cw90())
@@ -122,23 +122,27 @@
            for (unsigned i = 0, j = 1; j < pt.size(); i++, j++) {
 
                ZVec d0, d1;
-               float dy;
+               float dy0, dy1;
 
                if (multi > 0) {
                    ZVec dv0 = vert2[j][0] - vert2[i][0];
                    ZVec dv1 = vert2[j][1] - vert2[i][1];
                    ZVec dt = pt[j] - pt[i];
 
+                   float scale0 = linewidth * dv0.length() / dt.length();
+                   float scale1 = linewidth * dv1.length() / dt.length();
+                   scale0 = pow(scale0, scale_pow);
+                   scale1 = pow(scale1, scale_pow);
+
                    // XXX: 1.5 hardcoded
-                   d0 = dt * (1.5 / dv0.length());
-                   d1 = dt * (1.5 / dv1.length());
+                   d0 = scale0 * dt * (1.5 / dv0.length());
+                   d1 = scale1 * dt * (1.5 / dv1.length());
 
-                   dy = 1.0 / 
+                   float dy = 1.0 / 
                        dv0.cw90().normalize().dot(vert2[i][1] - vert2[i][0]);
+                   dy0 = scale0 * dy;
+                   dy1 = scale1 * dy;
                    //std::cout << dy << "\n";
-
-                   // XXX: should not be hardcoded
-                   glColor4f(0,0,dy,dy);
                }
 
                ZVec dv0 = vert[i][0] - vert[j][0];
@@ -159,15 +163,17 @@
 
                GLenum u;
 
+               if (multi > 0) glColor4f(0,0,dy1,dy1);
                colorfv(col1);
                texCoord(a1q, texscale * q1);
                u = GL_TEXTURE1;
                for (int d = 1; d <= multi; d++) {
-                   multiTexCoord(u++, a1q + d * d1, texscale * q1);
-                   multiTexCoord(u++, a1q - d * d1, texscale * q1);
+                   multiTexCoord(u++, a1q + d * q1 * d1, texscale * q1);
+                   multiTexCoord(u++, a1q - d * q1 * d1, texscale * q1);
                }
                vertex(vert2[i][1]);
 
+               if (multi > 0) glColor4f(0,0,dy0,dy0);
                colorfv(col0);
                texCoord(pt[i], texscale);
                u = GL_TEXTURE1;
@@ -193,12 +199,13 @@
                }
                vertex(vert2[j][0]);
                
+               if (multi > 0) glColor4f(0,0,dy1,dy1);
                colorfv(col1);
                texCoord(b1q, texscale * q1);
                u = GL_TEXTURE1;
                for (int d = 1; d <= multi; d++) {
-                   multiTexCoord(u++, b1q + d * d1, texscale * q1);
-                   multiTexCoord(u++, b1q - d * d1, texscale * q1);
+                   multiTexCoord(u++, b1q + d * q1 * d1, texscale * q1);
+                   multiTexCoord(u++, b1q - d * q1 * d1, texscale * q1);
                }
                vertex(vert2[j][1]);
            }




reply via email to

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