I've got something that does similar to what you want I think.
The maths-y bit isn't easy to read, but if you split it up into it's components you shoudl be able to see what it's doing.
I think there's possibly some redundancy in the vertex part... the (x+1+y+1)/2.3246 and the like were from before I randomised the phase. I think. It's been a while since I wrote it.
The margin is specific to my needs as well I think, I wante dot make sure that the edge of the image was always onscreen, even if the top-left coordinate was the top left of the screen.
Code:class wavePlane
{
float phase;
float posx,posy;
float Width,Height;
int div;
float i;
float s;
float depth;
PImage tex;
wavePlane(float _x, float _y,float _w, float _h,int _d,float _i, float _s, float _depth,PImage _tex)
{
div=_d; // number of divisions
tex=_tex; // texture
i=_i; // intensity of the warping, in units
s=_s; // speed of the movement, in terms of how quickly it goes form one extreme to the other.
depth=_depth; // z value
posx=_x; // top left coordinate x
posy=_y; // top left coordinate y
Width=_w; // does what it says...
Height=_h; //
phase=random(0,TWO_PI); // don't want all subdivisions to move in sync.
}
void draw()
{
phase+=s;
float dx=(Width/(float)div)+i;
float dy=(Height/(float)div)+i;
float margin=div/2.0*i;
// stroke(0,255,0);
for(int x=0;x<div;x++)
{
for(int y=0;y<div;y++)
{
beginShape(QUADS);
texture(tex);
vertex(posx-margin+x*dx+i*sin(phase+((x+y)/2.3246)),posy-margin+y*dy+i*cos(phase+((x+y)/1.3246)),depth,x*tex.width/(float)div,y*tex.height/(float)div);
vertex(posx-margin+(x+1)*dx+i*sin(phase+((x+1+y)/2.3246)),posy-margin+y*dy+i*cos(phase+((x+1+y)/1.3246)),depth,(x+1)*tex.width/(float)div,y*tex.height/(float)div);
vertex(posx-margin+(x+1)*dx+i*sin(phase+((x+1+y+1)/2.3246)),posy-margin+(y+1)*dy+i*cos(phase+((x+1+y+1)/1.3246)),depth,(x+1)*tex.width/(float)div,(y+1)*tex.height/(float)div);
vertex(posx-margin+x*dx+i*sin(phase+((x+y+1)/2.3246)),posy-margin+(y+1)*dy+i*cos(phase+((x+y+1)/1.3246)),depth,x*tex.width/(float)div,(y+1)*tex.height/float(div));
endShape();
}
}
noStroke();
}
}