gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz ./Makefile gfx/libcallgl/callgl.hxx gfx/lib...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz ./Makefile gfx/libcallgl/callgl.hxx gfx/lib...
Date: Mon, 16 Sep 2002 09:59:42 -0400

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

Modified files:
        .              : Makefile 
        gfx/libcallgl  : callgl.hxx 
        gfx/librenderables: renderables.py 
Added files:
        gfx/demo       : irregular2.py 

Log message:
        Start IrregularQuad renderable; projective 1D slice texture mapping 
does not work properly

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Makefile.diff?tr1=1.169&tr2=1.170&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregular2.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.hxx.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.30&tr2=1.31&r1=text&r2=text

Patches:
Index: gzz/Makefile
diff -c gzz/Makefile:1.169 gzz/Makefile:1.170
*** gzz/Makefile:1.169  Mon Sep 16 06:09:03 2002
--- gzz/Makefile        Mon Sep 16 09:59:42 2002
***************
*** 402,407 ****
--- 402,409 ----
        $(GLLIB) $(JYTHON) $(GLDEMO) gfx/demo/opengl/stencil.py
  runirregu:
        $(GLLIB) $(JYTHON) $(GLDEMO) gfx/demo/irregularframe.py
+ runirregu2:
+       $(GLLIB) $(JYTHON) $(GLDEMO) gfx/demo/irregular2.py
  runbuoydev:
        $(GLLIB) $(JYTHON) $(GLDEMO) gfx/demo/buoydev.py
  runfisheye:
Index: gzz/gfx/libcallgl/callgl.hxx
diff -c gzz/gfx/libcallgl/callgl.hxx:1.14 gzz/gfx/libcallgl/callgl.hxx:1.15
*** gzz/gfx/libcallgl/callgl.hxx:1.14   Sun Sep 15 06:22:13 2002
--- gzz/gfx/libcallgl/callgl.hxx        Mon Sep 16 09:59:42 2002
***************
*** 121,126 ****
--- 121,127 ----
        //cout << "Calling list " << displist->name << "\n";
        if (displist.get()) glCallList(displist->name);  
        }
+       GLuint getListName() const { return displist.get() ? displist->name : 
0; }
  
      protected:
        void compile() { 
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.30 
gzz/gfx/librenderables/renderables.py:1.31
*** gzz/gfx/librenderables/renderables.py:1.30  Mon Sep 16 01:33:36 2002
--- gzz/gfx/librenderables/renderables.py       Mon Sep 16 09:59:42 2002
***************
*** 449,454 ****
--- 449,496 ----
              b0 = 1.0 / (b0.x * b0.x + b0.y * b0.y) * b0;
              b1 = 1.0 / (b1.x * b1.x + b1.y * b1.y) * b1;
  
+             #if 0
+             {
+                 /* Find out where the corners will be in
+                  * non-distorted paper coordinates when distorted
+                  */
+                 ZPt p[4] = { coords1.transform(Pt(x0, y0)),
+                              coords1.transform(Pt(x0, y1)),
+                              coords1.transform(Pt(x1, y0)),
+                              coords1.transform(Pt(x1, y1)) };
+                 Pt q[4];
+ 
+                 for (int i = 0; i < 4; i++) {
+                     float x = p[i].x, y = p[i].y;
+ 
+                       ZPt pos = coords1.transform(Pt(x,y));
+                       float a = b0.dot(pos - borig);
+                       float b = b1.dot(pos - borig);
+                       float c = pos.z - borig.z;
+ 
+                       // Modulate distance from coords2 origin
+                       float t = (1 + a * a + b * b);
+                       float m = 1 + c / t;
+                       m = 1;
+                       ZPt v = coords2.transform(ZPt(m*a, m*b, c));
+ 
+                       q[i] = Pt(paperx.dot(v - paperorigin) *
+                                 (1 / (paperx.x * paperx.x + paperx.y * 
paperx.y)),
+                                 papery.dot(v - paperorigin) *
+                                 (1 / (papery.x * papery.x + papery.y * 
papery.y)));
+                 }
+ 
+                 cout << Pt(x0,y0) << q[0] << "\\n";
+                 cout << Pt(x0,y1) << q[1] << "\\n";
+                 cout << Pt(x1,y0) << q[2] << "\\n";
+                 cout << Pt(x1,y1) << q[3] << "\\n";
+ 
+                 // XXX: unfinished code
+             }
+             #endif
+             
+ 
+ 
            Paper::LightParam lightParam;
            lightParam.orig = paperorigin-ZPt(0,0,0);
            lightParam.e0 = paperx;
***************
*** 630,635 ****
--- 672,793 ----
  
            GLERR
        """,
+ }    ,
+ 
+ {
+     "Type" : "2",
+     "Name": "IrregularQuad",
+     "Data": "float x0, y0, x1, y1, border; int texid;",
+     "Params" : """
+           int texid, float x0, float y0, float x1, float y1, float border
+       """,
+     "ParamCode" : """
+             this->texid = texid;
+             this->x0 = x0;
+             this->y0 = y0;
+             this->x1 = x1;
+             this->y1 = y1;
+             this->border = border;
+       """,
+     "ExtraClass" : """
+             template <class Coords>
+             Pt invtransform(Coords cs, ZPt p) {
+                 ZPt orig = cs.transform(Pt(0, 0));
+                 ZVec e0 =  cs.transform(Pt(1, 0)) - orig;
+                 ZVec e1 =  cs.transform(Pt(0, 1)) - orig;
+ 
+                 ZVec v = p - orig;
+ 
+                 float m = 1.0 / (e0.x * e1.y - e1.x * e0.y);
+                 float inv[4] = {
+                   m * e1.y, -m * e1.x,
+                   -m * e0.y, m * e0.x
+                 };
+                 return Pt(inv[0] * v.x + inv[1] * v.y,
+                           inv[2] * v.x + inv[3] * v.y/*,
+                           v.z*/);
+             }
+     """,
+     "RenderCode" : """
+         DBG(dbg) << "Irregular quad\\n";
+ 
+         glPushAttrib(GL_ENABLE_BIT);
+         glEnable(GL_ALPHA_TEST);
+         glAlphaFunc(GL_GREATER, 0.2);
+         GLERR;
+ 
+         static CallGLCode setup;
+         if (setup.getListName() == 0)
+             setup = CallGLCode(
+                 "Enable REGISTER_COMBINERS_NV\\n"
+                 "CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1\\n"
+                 "CombinerInputNV COMBINER0_NV ALPHA VARIABLE_A_NV ZERO 
UNSIGNED_INVERT_NV ALPHA\\n"
+                 "CombinerInputNV COMBINER0_NV ALPHA VARIABLE_B_NV TEXTURE0 
SIGNED_NEGATE_NV ALPHA\\n"
+                 "CombinerInputNV COMBINER0_NV ALPHA VARIABLE_C_NV ZERO 
UNSIGNED_INVERT_NV ALPHA\\n"
+                 "CombinerInputNV COMBINER0_NV ALPHA VARIABLE_D_NV 
SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV BLUE\\n"
+                 "CombinerOutputNV COMBINER0_NV ALPHA DISCARD_NV DISCARD_NV 
SPARE0_NV NONE NONE FALSE FALSE FALSE\\n"
+                 "FinalCombinerInputNV VARIABLE_A_NV ZERO UNSIGNED_IDENTITY_NV 
RGB\\n"
+                 "FinalCombinerInputNV VARIABLE_B_NV ZERO UNSIGNED_IDENTITY_NV 
RGB\\n"
+                 "FinalCombinerInputNV VARIABLE_C_NV ZERO UNSIGNED_IDENTITY_NV 
RGB\\n"
+                 "FinalCombinerInputNV VARIABLE_D_NV PRIMARY_COLOR_NV 
UNSIGNED_IDENTITY_NV RGB\\n"
+                 "FinalCombinerInputNV VARIABLE_G_NV SPARE0_NV 
UNSIGNED_IDENTITY_NV ALPHA\\n"
+                 );
+ 
+         setup();
+         GLERR;
+ 
+         float x0b = x0 - border;
+         float y0b = y0 - border;
+         float x1b = x1 + border;
+         float y1b = y1 + border;
+ 
+         float wx = (x1b - x0b) / (x1 - x0);
+         float wy = (y1b - y0b) / (y1 - y0);
+ 
+ 
+         Pt sides[4][4] = { { Pt(x0,y0), Pt(x1, y0), Pt(x1b, y0b), Pt(x0b, 
y0b) },
+                            { Pt(x0,y1), Pt(x1, y1), Pt(x1b, y1b), Pt(x0b, 
y1b) },
+                            { Pt(x0,y0), Pt(x0, y1), Pt(x0b, y1b), Pt(x0b, 
y0b) },
+                            { Pt(x1,y0), Pt(x1, y1), Pt(x1b, y1b), Pt(x1b, 
y0b) } };
+ 
+         glBindTexture(GL_TEXTURE_2D, texid);
+         glEnable(GL_TEXTURE_2D);
+ 
+ 
+         glBegin(GL_QUADS);
+         for (int i = 0; i < 4; i++) {
+             Pt tex0 = invtransform(coords2, coords1.transform(sides[i][0]));
+             Pt tex1 = invtransform(coords2, coords1.transform(sides[i][1]));
+ 
+             glSecondaryColor3fEXT(1, 1, 1);
+ 
+             glTexCoord2f(tex0.x, tex0.y);
+             coords1.vertex(sides[i][0]);
+ 
+             glTexCoord2f(tex1.x, tex1.y);
+             coords1.vertex(sides[i][1]);
+ 
+             glSecondaryColor3fEXT(0, 0, 0);
+ 
+             float w = (i & 2) ? wy : wx;
+ 
+             glTexCoord3f(tex1.x * w, tex1.y * w, w);
+             coords1.vertex(sides[i][2]);
+ 
+             glTexCoord3f(tex0.x * w, tex0.y * w, w);
+             coords1.vertex(sides[i][3]);
+ 
+             //cout << tex0 << coords1.transform(sides[i][0]) << "\\n";
+             //cout << tex1 << coords1.transform(sides[i][1]) << "\\n";
+             //cout << tex1 << w << coords1.transform(sides[i][2]) << "\\n";
+             //cout << tex0 << w << coords1.transform(sides[i][3]) << "\\n";
+         }
+         glEnd();
+         GLERR;
+ 
+         glPopAttrib();
+         GLERR;
+     """,
  }    ,
  
  {




reply via email to

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