[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz gfx/librenderables/Renderables.cxx gfx/libr...
From: |
Asko Soukka |
Subject: |
[Gzz-commits] gzz gfx/librenderables/Renderables.cxx gfx/libr... |
Date: |
Thu, 03 Oct 2002 14:13:32 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Asko Soukka <address@hidden> 02/10/03 14:13:32
Modified files:
gfx/librenderables: Renderables.cxx Renderables.hxx
renderables.py
gzz/view : pagespanview.py
Log message:
CulledPaperQuad
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/Renderables.cxx.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/Renderables.hxx.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.94&tr2=1.95&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/pagespanview.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
Patches:
Index: gzz/gfx/librenderables/Renderables.cxx
diff -c gzz/gfx/librenderables/Renderables.cxx:1.6
gzz/gfx/librenderables/Renderables.cxx:1.7
*** gzz/gfx/librenderables/Renderables.cxx:1.6 Tue Oct 1 13:05:32 2002
--- gzz/gfx/librenderables/Renderables.cxx Thu Oct 3 14:13:32 2002
***************
*** 15,20 ****
--- 15,21 ----
DBGVAR(dbg, "Renderable.general");
DBGVAR(dbg_horiztext2, "Renderable.horiztext2");
DBGVAR(dbg_paperquad, "Renderable.paperquad");
+ DBGVAR(dbg_culledpaperquad, "Renderable.culledpaperquad");
DBGVAR(dbg_irregularquad, "Renderable.irregularquad");
void setStandardCoordinates(Vec windowSize) {
Index: gzz/gfx/librenderables/Renderables.hxx
diff -c gzz/gfx/librenderables/Renderables.hxx:1.18
gzz/gfx/librenderables/Renderables.hxx:1.19
*** gzz/gfx/librenderables/Renderables.hxx:1.18 Wed Oct 2 07:43:44 2002
--- gzz/gfx/librenderables/Renderables.hxx Thu Oct 3 14:13:32 2002
***************
*** 66,71 ****
--- 66,72 ----
PREDBGVAR(dbg);
PREDBGVAR(dbg_paperquad);
+ PREDBGVAR(dbg_culledpaperquad);
PREDBGVAR(dbg_horiztext2);
PREDBGVAR(dbg_irregularquad);
Index: gzz/gfx/librenderables/renderables.py
diff -c gzz/gfx/librenderables/renderables.py:1.94
gzz/gfx/librenderables/renderables.py:1.95
*** gzz/gfx/librenderables/renderables.py:1.94 Wed Oct 2 08:23:48 2002
--- gzz/gfx/librenderables/renderables.py Thu Oct 3 14:13:32 2002
***************
*** 450,455 ****
--- 450,618 ----
""",
} ,
+ # CulledPaperQuad is renderable3 version of regular PaperQuad.
+ # CulledPaperQuad is rendered if and only if it and an IrregularQuad
+ # defined by coordsys3 intersect.
+ # cs1 is paperquad's object => window,
+ # cs2 is paperquad's paper => paperquad's object, and
+ # cs3 is irregularquad tearaways's => paperquad's object.
+ # Corners give the corners of the quad to render, in object coordinates.
+ {
+ "Type" : "3",
+ "Name": "CulledPaperQuad",
+ "Data": "float x0, y0, x1, y1; Paper::Paper* paper; float scale;float
dicefactor;",
+ "Params" : """
+ Paper paper, float x0, float y0, float x1, float y1,
+ float scale, float dicefactor
+ """,
+ "ParamCode" : """
+ this->paper = paper;
+ this->x0 = x0;
+ this->y0 = y0;
+ this->x1 = x1;
+ this->y1 = y1;
+ this->scale = scale;
+ this->dicefactor = dicefactor;
+ """,
+ "RenderCode" : """
+ Coords &coords2inv = *coords2.getInverse();
+
+ DBG(dbg_culledpaperquad) << "Corner comparison (if one or more of
the " <<
+ "following statements are true,
renderable " <<
+ "will be skipped):"
+ "\\n" <<
+ coords2.transform(ZPt(x1, y1, 0)).x << "<=" <<
+ coords3.transform(ZPt(-1, -1, 0)).x << " | " <<
+ coords3.transform(ZPt(1, 1, 0)).x << "<=" <<
+ coords2.transform(ZPt(x0, y0, 0)).x << " | " <<
+ coords2.transform(ZPt(x1, y1, 0)).y << "<=" <<
+ coords3.transform(ZPt(-1, -1, 0)).y << " | " <<
+ coords3.transform(ZPt(1, 1, 0)).y << "<=" <<
+ coords2.transform(ZPt(x0, y0, 0)).y <<
+ "\\n";
+
+ /** Checks if the IrregularQuad and CulledPaperQuad intersects.
+ * "Two rectangles, represented by lower left and upper right
points (p1, p2)
+ * and (p3, p4), intersects if and only if the conjunction
+ * (x1 >= x3) && (x4 >= x1) && (y2 >= y3) && (y4 >= y1)
+ * is true. (The rectangles must intersect in both dimensions.)"
+ */
+ if (coords2.transform(ZPt(x1, y1, 0)).x <=
coords3.transform(ZPt(-1, -1, 0)).x
+ || coords3.transform(ZPt(1, 1, 0)).x <= coords2.transform(ZPt(x0,
y0, 0)).x
+ || coords2.transform(ZPt(x1, y1, 0)).y <=
coords3.transform(ZPt(-1, -1, 0)).y
+ || coords3.transform(ZPt(1, 1, 0)).y <= coords2.transform(ZPt(x0,
y0, 0)).y) {
+ DBG(dbg_culledpaperquad) << "No need to render? Skipping..."
<<
+ "\\n";
+ return;
+ }
+
+ 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;
+ lightParam.e2 = ZVec(0,0,paperx.length()) * scale;
+
+ lightParam.Light = ZVec(-1,-1,1);
+ lightParam.Light_w = 0.0;
+
+ DBG(dbg_culledpaperquad) << "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 * dicefactor) + 2;
+ DBG(dbg_paperquad) << "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_paperquad) << " 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) {
+
+ DBG(dbg_paperquad) << "Pass\\n";
+ (*it).setUp_VP(&lightParam);
+
+ DBG(dbg_paperquad) << "Going to multidraw\\n";
+ GLERR
+ glMultiDrawElementsEXT(GL_QUAD_STRIP,
+ counts, GL_UNSIGNED_INT, (const GLvoid **)indps,
dice-1);
+
+ DBG(dbg_paperquad) << "Teardown\\n";
+ GLERR
+ (*it).tearDown_VP();
+ GLERR
+ DBG(dbg_paperquad) << "Pass over\\n";
+
+ }
+
+ glUnlockArraysEXT();
+ glPopClientAttrib();
+ DBG(dbg_paperquad) << "Passes over\\n";
+
+ GLERR
+ """,
+ } ,
+
+
{
"Type" : "2",
"Name": "BasisPaperQuad",
***************
*** 1146,1151 ****
--- 1309,1319 ----
public static PaperQuad createPaperQuad(Paper paper,
float x0, float y0, float x1, float y1, float dicefactor) {
return createPaperQuad(paper, x0, y0, x1, y1, 1, dicefactor);
+ }
+
+ public static CulledPaperQuad createCulledPaperQuad(Paper paper,
+ float x0, float y0, float x1, float y1, float dicefactor) {
+ return createCulledPaperQuad(paper, x0, y0, x1, y1, 1, dicefactor);
}
public static gzz.vob.Vob createCallList(String s) {
Index: gzz/gzz/view/pagespanview.py
diff -c gzz/gzz/view/pagespanview.py:1.10 gzz/gzz/view/pagespanview.py:1.11
*** gzz/gzz/view/pagespanview.py:1.10 Thu Oct 3 12:12:31 2002
--- gzz/gzz/view/pagespanview.py Thu Oct 3 14:13:32 2002
***************
*** 160,175 ****
# create always all cs, gets interpolation better
cs1 = vs.coords.affineCoordsys(cs1into, 100,
self.curx, ycoord, self.scale, 0, 0, self.scale)
! vs.matcher.add(cs1, key+"_p_"+str(i))
if onlypages == None or i in onlypages:
if fancy:
! pq = GLRen.createPaperQuad(
! papers[i][3], *corners)
! vs.map.put(pq, cs1, cs2)
else:
! pq = GLRen.createPaperQuad(
! papers[i][0], *corners)
! vs.map.put(pq, cs1, cs2)
self.curx += self.scaledsheetsize[0]
pp = PutPapers()
--- 160,201 ----
# create always all cs, gets interpolation better
cs1 = vs.coords.affineCoordsys(cs1into, 100,
self.curx, ycoord, self.scale, 0, 0, self.scale)
! vs.matcher.add(cs1, key+"_p_"+str(i))
! # If cliprect is defined, create coordsys transformation
from
! # IrregularQuad's object coordsys into CulledPaperQuad's
object
! # coordsys. Then create CulledPaperQuad's instead of
! # regular renderable2 PaperQuads.
! if cliprect:
! irreg_orig_x = (cliprect[0]+cliprect[2])/2
! irreg_orig_y = (cliprect[1]+cliprect[3])/2
! irreg_orig_x_on_pq = (irreg_orig_x - self.curx) /
self.scale
! irreg_orig_y_on_pq = (irreg_orig_y - ycoord) /
self.scale
! cs3 = vs.coords.affineCoordsys(0, 0,
! irreg_orig_x_on_pq, irreg_orig_y_on_pq,
! ((cliprect[2]-cliprect[0])/2) / self.scale, 0, 0,
! ((cliprect[3]-cliprect[1])/2) / self.scale)
!
! vs.matcher.add(cs3, key+"_cp_"+str(i))
if onlypages == None or i in onlypages:
if fancy:
! if cliprect:
! pq = GLRen.createCulledPaperQuad(
! papers[i][3], *corners)
! vs.map.put(pq, cs1, cs2, cs3)
! else:
! pq = GLRen.createPaperQuad(
! papers[i][3], *corners)
! vs.map.put(pq, cs1, cs2)
else:
! if cliprect:
! pq = GLRen.createCulledPaperQuad(
! papers[i][0], *corners)
! vs.map.put(pq, cs1, cs2, cs3)
! else:
! pq = GLRen.createPaperQuad(
! papers[i][0], *corners)
! vs.map.put(pq, cs1, cs2)
!
self.curx += self.scaledsheetsize[0]
pp = PutPapers()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz gfx/librenderables/Renderables.cxx gfx/libr...,
Asko Soukka <=