[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz ./TODO gfx/demo/papertest.py gfx/libcoords/...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz ./TODO gfx/demo/papertest.py gfx/libcoords/... |
Date: |
Thu, 26 Sep 2002 14:39:24 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/09/26 14:39:24
Modified files:
. : TODO
gfx/demo : papertest.py
gfx/libcoords : Coords.cxx Coords.hxx
gfx/librenderables: renderables.py
gzz/gfx/gl : GLVobCoorder.java
Log message:
Make paperquad rendering work on new framework
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.147&tr2=1.148&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/papertest.py.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.hxx.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.65&tr2=1.66&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLVobCoorder.java.diff?tr1=1.30&tr2=1.31&r1=text&r2=text
Patches:
Index: gzz/TODO
diff -c gzz/TODO:1.147 gzz/TODO:1.148
*** gzz/TODO:1.147 Thu Sep 26 10:26:10 2002
--- gzz/TODO Thu Sep 26 14:39:24 2002
***************
*** 35,50 ****
- fix utf8 string non-null end bug found by Benja
- move mstmpimg/ to ..
jvk:
- fix irregularquad to work with new coordsys stuff
tjl:
- make distorted and rotated coordinate systems work from Java
! - demo using hierarchical rotations
! - make paperquad use nonlinearity
! + fix coordsys to take an iterator, which does the lerping,
! so we can store parameters more naturally and also create
coordsys independently of the CoordSet stuff.
- move coordsys into their own header file, or at least
coords header file...
- distorted multi-page PDF view with xu links
- abstract distortion out into libfisheye, for buoy edges etc.
- use templates to make sure that we get performance
--- 35,51 ----
- fix utf8 string non-null end bug found by Benja
- move mstmpimg/ to ..
jvk:
+ - javadoc Paper.hxx: how to use Vertex Program interface.
- fix irregularquad to work with new coordsys stuff
tjl:
- make distorted and rotated coordinate systems work from Java
! - make paperquad use nonlinearity
! - fix coordsys to take an iterator, which does the lerping,
! so we can store parameters more naturally and also create
coordsys independently of the CoordSet stuff.
- move coordsys into their own header file, or at least
coords header file...
+ - this is needed also by making the inversions
- distorted multi-page PDF view with xu links
- abstract distortion out into libfisheye, for buoy edges etc.
- use templates to make sure that we get performance
***************
*** 391,399 ****
so the effect is like moving the mouse in Quake. (note: all
gzz'ers should try Quake3 with the highest quality settings
at 1600x1200 on a high-end graphics card)
jvk:
- paper:
- - reaction diffusion textures
- 3D textures
- new parametrization of texgen
- moving light
--- 392,404 ----
so the effect is like moving the mouse in Quake. (note: all
gzz'ers should try Quake3 with the highest quality settings
at 1600x1200 on a high-end graphics card)
+ - think about texture shading for font rendering
+ - the point is that if you zoom into a mipmapped 1-texel
+ wide line, you get a blurred wedge with bi/trilinear
+ filtering. For a font, that's not what you want.
+ Should we just abandon filtering?
jvk:
- paper:
- 3D textures
- new parametrization of texgen
- moving light
Index: gzz/gfx/demo/papertest.py
diff -c gzz/gfx/demo/papertest.py:1.28 gzz/gfx/demo/papertest.py:1.29
*** gzz/gfx/demo/papertest.py:1.28 Wed Sep 25 07:28:11 2002
--- gzz/gfx/demo/papertest.py Thu Sep 26 14:39:24 2002
***************
*** 82,88 ****
zoom = [100, 500, 650, 800, 2000]
! paperzoom = [0.2, 1, 3, 0.05]
passmask = [1,1,1,1]
--- 82,88 ----
zoom = [100, 500, 650, 800, 2000]
! paperzoom = [2, 10, 33, 100]
passmask = [1,1,1,1]
***************
*** 160,168 ****
# vs.put(rectangle((1, 0.2, 0.4)), "re", 10, 100, 100, 300, 100)
! cs1 = vs.coords.affineCoordsys(0, "1", 10, 700, 500, 700, 0, 0, 450)
scale = zoom[0] / paperzoom[0]
! cs2 = vs.coords.affineCoordsys(0, "2", 1, 400, 400, scale, 0, 0, scale)
pscale = zoom[0]
--- 160,171 ----
# vs.put(rectangle((1, 0.2, 0.4)), "re", 10, 100, 100, 300, 100)
! cs1 = vs.coords.affineCoordsys(0, 10, 700, 500, 700, 0, 0, 450)
scale = zoom[0] / paperzoom[0]
! cs2 = vs.coords.affineCoordsys(0, 1, 0, 0, scale, 0, 0, scale)
!
! vs.matcher.add(cs1, "1")
! vs.matcher.add(cs2, "2")
pscale = zoom[0]
***************
*** 184,191 ****
Enable TEXTURE_2D
Disable ALPHA_TEST
"""))
! cs3 = vs.coords.affineCoordsys(0, "3",
! 1, 400, 400, pscale, 0, 0, pscale)
vs.map.put(self.qua, cs3)
vs.map.put(rectangle((0,0,0)), cs3)
--- 187,195 ----
Enable TEXTURE_2D
Disable ALPHA_TEST
"""))
! cs3 = vs.coords.affineCoordsys(0,
! 1, 0, 0, pscale, 0, 0, pscale)
! vs.matcher.add(cs3, "3")
vs.map.put(self.qua, cs3)
vs.map.put(rectangle((0,0,0)), cs3)
***************
*** 304,310 ****
def scene(self, vs):
putnoc(vs, background(self.bgcolor))
! cs1 = vs.coords.affineCoordsys(0, "1", 10, 600, 500, 450, 0, 0, 450)
putText(vs, cs1, "F1, F2", color=(0,0,0), w=.005, h=.005)
--- 308,315 ----
def scene(self, vs):
putnoc(vs, background(self.bgcolor))
! cs1 = vs.coords.affineCoordsys(0, 10, 600, 500, 450, 0, 0, 450)
! vs.matcher.add(cs1, "1")
putText(vs, cs1, "F1, F2", color=(0,0,0), w=.005, h=.005)
Index: gzz/gfx/libcoords/Coords.cxx
diff -c gzz/gfx/libcoords/Coords.cxx:1.10 gzz/gfx/libcoords/Coords.cxx:1.11
*** gzz/gfx/libcoords/Coords.cxx:1.10 Thu Sep 26 07:27:58 2002
--- gzz/gfx/libcoords/Coords.cxx Thu Sep 26 14:39:24 2002
***************
*** 22,29 ****
--- 22,34 ----
* Parameter layout: x, y, depth, xx, xy, yx, yy
*/
class AffineXYCoords : public CoordSys {
+ float params[7];
public:
enum { NParams = 7 };
+ virtual void setParams(float *params) {
+ for(int i=0; i<7; i++)
+ this->params[i] = params[i];
+ }
/** Perform the internal transformation of this
* coordsys.
*/
***************
*** 55,60 ****
--- 60,85 ----
return true;
}
+ protected:
+ virtual CoordSys *createInverse() {
+ CoordSys *sup = super->createInverse();
+ AffineXYCoords *inv = new AffineXYCoords();
+ inv->setSuper(sup);
+ double det = params[3] * params[6] - params[4] * params[5];
+ // XXX If det small, trouble!!
+ inv->params[3] = params[6] / det;
+ inv->params[4] = -params[4] / det;
+ inv->params[5] = -params[5] / det;
+ inv->params[6] = params[3] / det;
+
+ inv->params[0] = -(params[0] * inv->params[3] +
+ params[1] * inv->params[4]);
+ inv->params[1] = -(params[0] * inv->params[5] +
+ params[1] * inv->params[6]);
+ inv->params[2] = -params[2];
+ return inv;
+ }
+
};
/** Rotation clockwise.
***************
*** 129,134 ****
--- 154,162 ----
to = distort(from);
to.x *= mmin;
to.y *= mmin;
+ }
+ virtual float nonlinearity(const ZPt &p, float radius) {
+ return 10;
}
};
Index: gzz/gfx/libcoords/Coords.hxx
diff -c gzz/gfx/libcoords/Coords.hxx:1.6 gzz/gfx/libcoords/Coords.hxx:1.7
*** gzz/gfx/libcoords/Coords.hxx:1.6 Thu Sep 26 04:31:24 2002
--- gzz/gfx/libcoords/Coords.hxx Thu Sep 26 14:39:24 2002
***************
*** 14,20 ****
CoordSys *super;
float *params;
CoordSys *inverse;
- virtual CoordSys *createInverse() ;
public:
virtual void setSuper(CoordSys *super) {
this->super = super;
--- 14,19 ----
***************
*** 35,40 ****
--- 34,43 ----
return inverse;
}
+ /** Don't use; use getInverse instead!
+ */
+ virtual CoordSys *createInverse() ;
+
// For Pt as well?
/** Call glVertex with the given ZPt transformed
***************
*** 53,59 ****
* The return value is 1/l where l would be a reasonable length for
dicing.
* Returns 0 if dicing is required.
*/
! virtual float nonlinearity(const ZPt &p) { return 0; }
/** Whether this transformation can be performed by OpenGL
* alone.
--- 56,62 ----
* The return value is 1/l where l would be a reasonable length for
dicing.
* Returns 0 if dicing is required.
*/
! virtual float nonlinearity(const ZPt &p, float radius) { return 0; }
/** Whether this transformation can be performed by OpenGL
* alone.
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.65
gzz/gfx/librenderables/renderables.py:1.66
*** gzz/gfx/librenderables/renderables.py:1.65 Thu Sep 26 13:37:11 2002
--- gzz/gfx/librenderables/renderables.py Thu Sep 26 14:39:24 2002
***************
*** 321,348 ****
{
"Type" : "2",
"Name": "PaperQuad",
! "Data": "Pt corners[4]; Paper::Paper* paper; float scale;",
"Params" : """
Paper paper, float x0, float y0, float x1, float y1,
float scale
""",
"ParamCode" : """
this->paper = paper;
! corners[0].x = corners[1].x = x0;
! corners[0].y = corners[3].y = y0;
! corners[2].x = corners[3].x = x1;
! corners[1].y = corners[2].y = y1;
this->scale = scale;
""",
"RenderCode" : """
! DBG(dbg) << "Paper\\n";
GLERR
ZPt paperorigin = coords2.transform(ZPt(0, 0, 0));
ZVec paperx = coords2.transform(ZPt(1, 0, 0)) - paperorigin;
ZVec papery = coords2.transform(ZPt(0, 1, 0)) - paperorigin;
Paper::LightParam lightParam;
lightParam.orig = paperorigin-ZPt(0,0,0);
lightParam.e0 = paperx * scale;
lightParam.e1 = papery * scale;
--- 321,353 ----
{
"Type" : "2",
"Name": "PaperQuad",
! "Data": "float x0, y0, x1, y1; Paper::Paper* paper; float scale;",
"Params" : """
Paper paper, float x0, float y0, float x1, float y1,
float scale
""",
"ParamCode" : """
this->paper = paper;
! this->x0 = x0;
! this->y0 = y0;
! this->x1 = x1;
! this->y1 = y1;
this->scale = scale;
""",
"RenderCode" : """
! Coords &coords2inv = *coords2.getInverse();
!
GLERR
+
ZPt paperorigin = coords2.transform(ZPt(0, 0, 0));
ZVec paperx = coords2.transform(ZPt(1, 0, 0)) - paperorigin;
ZVec papery = coords2.transform(ZPt(0, 1, 0)) - paperorigin;
+
Paper::LightParam lightParam;
+
+ // These are now irrelevant
lightParam.orig = paperorigin-ZPt(0,0,0);
lightParam.e0 = paperx * scale;
lightParam.e1 = papery * scale;
***************
*** 351,395 ****
lightParam.Light = ZVec(-1,-1,1);
lightParam.Light_w = 0.0;
! if(dbg) {
! cout << "Paperquad: " <<
lightParam.orig << " " <<
lightParam.e0 << " " <<
lightParam.e1 << " " <<
lightParam.e2 << " " <<
"\\nCorners" <<
! corners[0] <<
! corners[1] <<
! corners[2] <<
! corners[3] <<
! "\\nCorners trans:" <<
! coords1.transform(corners[0]) <<
! coords1.transform(corners[1]) <<
! coords1.transform(corners[2]) <<
! coords1.transform(corners[3]) <<
"\\n"
;
- }
GLERR
for(Paper::Paper::iterator it = paper->begin(); it != paper->end();
++it) {
if (dbg) cout << "Pass\\n";
! (*it).setUp(&lightParam);
GLERR
! glBegin(GL_QUADS);
! coords1.vertex(corners[0]);
! coords1.vertex(corners[1]);
! coords1.vertex(corners[2]);
! coords1.vertex(corners[3]);
! glEnd();
GLERR
! (*it).tearDown();
GLERR
}
GLERR
""",
--- 356,439 ----
lightParam.Light = ZVec(-1,-1,1);
lightParam.Light_w = 0.0;
! DBG(dbg) << "Paperquad: " <<
lightParam.orig << " " <<
lightParam.e0 << " " <<
lightParam.e1 << " " <<
lightParam.e2 << " " <<
"\\nCorners" <<
! x0 << " " <<
! y0 << " " <<
! x1 << " " <<
! y1 << " " <<
"\\n"
;
GLERR
+ ZPt ctr = ZPt(lerp(x0, x1, 0.5), lerp(y0, y1, 0.5), 0);
+ double len = hypot(x1-x0, y1-y0);
+ double nonl = coords1.nonlinearity(ctr, len);
+
+ int dice = (int)(len * nonl) + 2;
+ DBG(dbg) << "Dice: " << dice <<"\\n";
+
+ float vertices[dice][dice][5];
+ int indices[dice-1][2*dice];
+ int *indps[dice-1];
+ int counts[dice-1];
+ for(int ix = 0; ix<dice; ix++) {
+ if(ix < dice-1) {
+ counts[ix] = 2*dice;
+ indps[ix] = indices[ix];
+ }
+ for(int iy = 0; iy<dice; iy++) {
+ if(ix < dice-1) {
+ indices[ix][2*iy] = dice * ix + iy;
+ indices[ix][2*iy+1] = dice * (ix+1) + iy;
+ }
+ float x = ix / (dice - 1.0);
+ float y = iy / (dice - 1.0);
+ ZPt p(lerp(x0, x1, x), lerp(y0, y1, y), 0);
+ ZPt v = coords1.transform(p);
+ vertices[ix][iy][2] = v.x;
+ vertices[ix][iy][3] = v.y;
+ vertices[ix][iy][4] = v.z;
+ ZPt t = coords2inv.transform(p);
+ vertices[ix][iy][0] = t.x;
+ vertices[ix][iy][1] = t.y;
+ DBG(dbg) << " vert: " <<
+ ix << " " <<
+ iy << " : " <<
+ vertices[ix][iy][0] << " " <<
+ vertices[ix][iy][1] << " " <<
+ vertices[ix][iy][2] << " " <<
+ vertices[ix][iy][3] << " " <<
+ vertices[ix][iy][4] << " " <<
+ "\\n";
+ }
+ }
+
+ glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+ glInterleavedArrays(GL_T2F_V3F, 5*sizeof(float), vertices);
+ glLockArraysEXT(0, dice*dice);
+
for(Paper::Paper::iterator it = paper->begin(); it != paper->end();
++it) {
if (dbg) cout << "Pass\\n";
! (*it).setUpVP(&lightParam);
GLERR
! glMultiDrawElementsEXT(GL_QUAD_STRIP,
! counts, GL_UNSIGNED_INT, (const GLvoid **)indps,
dice-1);
GLERR
! (*it).tearDownVP();
GLERR
}
+
+ glUnlockArraysEXT();
+ glPopClientAttrib();
GLERR
""",
Index: gzz/gzz/gfx/gl/GLVobCoorder.java
diff -c gzz/gzz/gfx/gl/GLVobCoorder.java:1.30
gzz/gzz/gfx/gl/GLVobCoorder.java:1.31
*** gzz/gzz/gfx/gl/GLVobCoorder.java:1.30 Thu Sep 26 07:01:47 2002
--- gzz/gzz/gfx/gl/GLVobCoorder.java Thu Sep 26 14:39:24 2002
***************
*** 29,35 ****
import gzz.client.gl.*;
public class GLVobCoorder extends AffineVobCoorder {
! public static final String rcsid = "$Id: GLVobCoorder.java,v 1.30 2002/09/26
11:01:47 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
--- 29,35 ----
import gzz.client.gl.*;
public class GLVobCoorder extends AffineVobCoorder {
! public static final String rcsid = "$Id: GLVobCoorder.java,v 1.31 2002/09/26
18:39:24 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
***************
*** 81,86 ****
--- 81,106 ----
int was = ninds / 3;
ninds += 3;
+ return was;
+ }
+
+ public int distort(int into, float x, float y, float w, float h, float
mag, float min) {
+
+ floats[nfloats + 0] = x;
+ floats[nfloats + 1] = y;
+ floats[nfloats + 2] = (float)Math.log(mag);
+ floats[nfloats + 3] = (float)Math.log(min);
+ floats[nfloats + 4] = w;
+ floats[nfloats + 5] = h;
+ int paramInd = nfloats;
+ nfloats += 6;
+
+ inds[ninds + 0] = 3; // distort
+ inds[ninds + 1] = into;
+ inds[ninds + 2] = paramInd;
+
+ int was = ninds / 3;
+ ninds += 3;
return was;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz ./TODO gfx/demo/papertest.py gfx/libcoords/...,
Tuomas J. Lukka <=