556 |
|
|
557 |
# coords1: paper => window |
# coords1: paper => window |
558 |
# coords2: tearaway => paper (assumed to be affine) |
# coords2: tearaway => paper (assumed to be affine) |
559 |
# The paper is [-paperw,paperw]x[-paperh,paperh] in paper coordinates and |
# The rectangular paper from which the tearaway is torn away |
560 |
|
# is [x0,y0]..[x1,y1] in paper coordinates (as in PaperQuad) and |
561 |
# the tearaway part is [-1,1]x[-1,1] in tearaway coordinates. |
# the tearaway part is [-1,1]x[-1,1] in tearaway coordinates. |
562 |
# border and ripple_period are relative to the ripple amplitude and period in |
# border and ripple_period are relative to the ripple amplitude and period in |
563 |
# paper coordinates |
# paper coordinates |
564 |
{ |
{ |
565 |
"Type" : "2", |
"Type" : "2", |
566 |
"Name": "IrregularQuad", |
"Name": "IrregularQuad", |
567 |
"Data": "float border; float paperw, paperh, freq; int mode; CallGLCode setup;", |
"Data": "float x0, y0, x1, y1; float border; float freq; int mode; CallGLCode setup;", |
568 |
"Params" : """ |
"Params" : """ |
569 |
float border, float paperw, float paperh, float ripple_period, int mode, String setupcode |
float x0, float y0, float x1, float y1, |
570 |
|
float border, float ripple_period, int mode, String setupcode |
571 |
""", |
""", |
572 |
"ParamCode" : """ |
"ParamCode" : """ |
573 |
|
this->x0 = x0; |
574 |
|
this->y0 = y0; |
575 |
|
this->x1 = x1; |
576 |
|
this->y1 = y1; |
577 |
this->border = border; |
this->border = border; |
|
this->paperw = paperw; |
|
|
this->paperh = paperh; |
|
578 |
this->freq = 1.0 / ripple_period; |
this->freq = 1.0 / ripple_period; |
579 |
this->mode = mode; |
this->mode = mode; |
580 |
setup = CallGLCode(string(setupcode.begin(), setupcode.end()).c_str()); |
setup = CallGLCode(string(setupcode.begin(), setupcode.end()).c_str()); |
583 |
template <class Coords> |
template <class Coords> |
584 |
inline void vert(Coords& coords1, Coords& coords2, ZPt q) { |
inline void vert(Coords& coords1, Coords& coords2, ZPt q) { |
585 |
ZPt p = coords2.transform(q); |
ZPt p = coords2.transform(q); |
586 |
glMultiTexCoord2f(1, .25 / paperw * p.x + .5, .25 / paperh * p.y + .5); |
float xrelp = (p.x - x0)/ (x1-x0); |
587 |
|
float yrelp = (p.y - y0)/ (y1-y0); |
588 |
|
glMultiTexCoord2f(1, |
589 |
|
.25 + .5 * xrelp, // the center texels of 4x4 are colored |
590 |
|
.25 + .5 * yrelp |
591 |
|
); |
592 |
coords1.vertex(p); |
coords1.vertex(p); |
593 |
DBG(dbg) << "Vert: " << q<<p<<coords1.transform(p) <<"\\n"; |
DBG(dbg) << "Vert: " << q<<p<<coords1.transform(p) <<"\\n"; |
594 |
} |
} |