506 |
{ |
{ |
507 |
"Type" : "2", |
"Type" : "2", |
508 |
"Name": "IrregularQuad", |
"Name": "IrregularQuad", |
509 |
"Data": "float border; float cs2w, cs2h, cs2p; int mode; CallGLCode setup;", |
"Data": "float border; float paperw, paperh, freq; int mode; CallGLCode setup;", |
510 |
"Params" : """ |
"Params" : """ |
511 |
float border, float cs2w, float cs2h, float cs2ripple_period, int mode, String setupcode |
float border, float paperw, float paperh, float ripple_period, int mode, String setupcode |
512 |
""", |
""", |
513 |
"ParamCode" : """ |
"ParamCode" : """ |
|
// Note: the parameters coords2.x, coords2.y, cs2w, cs2h, |
|
|
// and cs2ripple_period have one redundant variable |
|
|
this->cs2p = cs2ripple_period; |
|
514 |
this->border = border; |
this->border = border; |
515 |
this->cs2w = cs2w / cs2p; |
this->paperw = paperw; |
516 |
this->cs2h = cs2h / cs2p; |
this->paperh = paperh; |
517 |
|
this->freq = 1.0 / ripple_period; |
518 |
this->mode = mode; |
this->mode = mode; |
519 |
setup = CallGLCode(string(setupcode.begin(), setupcode.end()).c_str()); |
setup = CallGLCode(string(setupcode.begin(), setupcode.end()).c_str()); |
520 |
""", |
""", |
528 |
template <class Coords> |
template <class Coords> |
529 |
inline void vert(Coords& coords1, Coords& coords2, ZPt q) { |
inline void vert(Coords& coords1, Coords& coords2, ZPt q) { |
530 |
ZPt p = coords2.transform(q); |
ZPt p = coords2.transform(q); |
531 |
glMultiTexCoord2f(1, .25 / cs2w * p.x + .5, .25 / cs2h * p.y + .5); |
glMultiTexCoord2f(1, .25 / paperw * p.x + .5, .25 / paperh * p.y + .5); |
532 |
coords1.vertex(p); |
coords1.vertex(p); |
533 |
} |
} |
534 |
""", |
""", |
594 |
glEnable(GL_TEXTURE_2D); |
glEnable(GL_TEXTURE_2D); |
595 |
|
|
596 |
for (unsigned i = 0; i < sizeof(sides)/sizeof(sides[0]); i++) { |
for (unsigned i = 0; i < sizeof(sides)/sizeof(sides[0]); i++) { |
597 |
ZPt tex0 = coords2.transform(lerp(texf, sides[i][3], sides[i][0])); |
ZVec tex0 = freq * (coords2.transform(lerp(texf, sides[i][3], sides[i][0])) - ZPt(0,0,0)); |
598 |
ZPt tex1 = coords2.transform(lerp(texf, sides[i][2], sides[i][1])); |
ZVec tex1 = freq * (coords2.transform(lerp(texf, sides[i][2], sides[i][1])) - ZPt(0,0,0)); |
|
|
|
599 |
|
|
600 |
glBegin(GL_QUADS); |
glBegin(GL_QUADS); |
601 |
glSecondaryColor3fEXT(0, 0, 0); |
glSecondaryColor3fEXT(0, 0, 0); |