We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Wave on a simple grid... how to
Page Index Toggle Pages: 1
Wave on a simple grid... how to? (Read 1352 times)
Wave on a simple grid... how to?
Oct 6th, 2005, 12:11am
 
Hi. I'm trying ti implement a wave animation on a simple grid like this:

for(int i=0; i<height; i+=10) {
 for(int j=50; j<width-50; j+=10) {  
   rectMode(CENTER);
   rect(j, i, 5, 5);
 }
}

... the starting point of the wave it would be the center of the grid, and the "look and feel" it would be like a "rock droping on water"... using something like:

pushMatrix();
translate(0, 0 ,"wave thing values");
rect (......);
popMatrix();

the initial "power" of the wave could be generated from the amount of time the center square of the grid is "pressed" by the mouse..or some other kind of dinamic input.

can someone help me by pointing some examples of wave animation or the correct math/code to do this?

thanx


Re: Wave on a simple grid... how to?
Reply #1 - Oct 6th, 2005, 1:48am
 
Code:

float amplitude = 1.0;
float wavelength = 20.0;
float t = 0.0;
void setup(){
size(400,400,P3D);
ellipseMode(CENTER);
}
void draw(){
//background(200);
float waveHeight = sin((TWO_PI/wavelength)*t)*amplitude;
translate(width/2,height/2,waveHeight);
rotateX(PI/4);
ellipse(0,0,t,t);
t += 0.1;
}

Got a basic wave form for yer. I think the trick is to use sine to figure out how those waves are doing.

Haven't got an idea for a grid transformation this late in the day just yet. What would we have to do? Place listeners on grid points perhaps? What do you think guys?
Re: Wave on a simple grid... how to?
Reply #2 - Oct 7th, 2005, 7:36pm
 
I have a grid class and a wave transformation for the grid called ripple().

WaveGrid

I'm using a quad grid here noflux because you'll be able to manipulate the corners a bit easier. If you want to effect it across tiles just dump rects at those grid points. The advantage with quads though is that you can map textures to them and do some really funky stuff. All fairly straight forward. I can't figure out how to make the wave roll along the surface or die out though. I'm suffering a bit of a brain block. Any clues
Re: Wave on a simple grid... how to?
Reply #3 - Oct 8th, 2005, 12:23pm
 
Nevermind, fixed it. Same link.
Re: Wave on a simple grid... how to?
Reply #4 - Oct 10th, 2005, 9:59pm
 
Thanx for the math Cheesy this is a realy big help.
Page Index Toggle Pages: 1