Skip to main content

Do you have a water simulation?

My suggestions are

  • fake it with springs. Each vertex on the water surface is coupled together into a spring mesh. Pull one down and they all start oscillating. You could constrain x,z motion and only allow y (or up/down motion)

  • fake it by summing sinewaves of different amplitudes and frequencies. Some thing like this:

     rez = 32;
     for(i=-rez; i<rez; i++)
        for(j=-rez; j<rez; j++)
        {
           yofs = 0;
           yofs += 1.0 * sin( t + j*0.5 + i*0.125);
           yofs += 2.0 * sin( t + (rez-j)*0.125 + i*0.25 );
           yofs += 2.0 * sin( t + (j)*0.125 + (rez-i)*0.125 );
           yofs += 0.5 * sin( t + (rez+j)*0.125 + (rez+i)*0.125 );
           glVertex(i/rez, yofs, j/rez);
        }
    
  • simulate the 2D wave equation, this can be very fast on the GPU. See this page for a java applet and some pseudo code. Also check this version, the same but even simpler. A processing sketch with code.

From the wave equation sim you can get the direction (dx,dz) of the wave is traveling in

dx = h[x-1][z] - h[x+1][z] 
dz = h[x][z-1]- h[x][x+1] 

where h a 2D array with the height of the wave at [x][z]

You could add this to the boats position to make it travel with the wave... I've tried, but the movement becomes jerky, so I smoothed it out with a simple 3x3 box filter (smoothing the differences/velocities dx dz)

Do you have a water simulation?

My suggestions are

  • fake it with springs. Each vertex on the water surface is coupled together into a spring mesh. Pull one down and they all start oscillating. You could constrain x,z motion and only allow y (or up/down motion)

  • fake it by summing sinewaves of different amplitudes and frequencies. Some thing like this:

    rez = 32;
    for(i=-rez; i<rez; i++)
    for(j=-rez; j<rez; j++)
    {
       yofs = 0;
       yofs += 1.0 * sin( t + j*0.5 + i*0.125);
       yofs += 2.0 * sin( t + (rez-j)*0.125 + i*0.25 );
       yofs += 2.0 * sin( t + (j)*0.125 + (rez-i)*0.125 );
       yofs += 0.5 * sin( t + (rez+j)*0.125 + (rez+i)*0.125 );
       glVertex(i/rez, yofs, j/rez);
    
  • simulate the 2D wave equation, this can be very fast on the GPU. See this page for a java applet and some pseudo code. Also check this version, the same but even simpler. A processing sketch with code.

From the wave equation sim you can get the direction (dx,dz) of the wave is traveling in

dx = h[x-1][z] - h[x+1][z] 
dz = h[x][z-1]- h[x][x+1] 

where h a 2D array with the height of the wave at [x][z]

You could add this to the boats position to make it travel with the wave... I've tried, but the movement becomes jerky, so I smoothed it out with a simple 3x3 box filter (smoothing the differences/velocities dx dz)

Do you have a water simulation?

My suggestions are

  • fake it with springs. Each vertex on the water surface is coupled together into a spring mesh. Pull one down and they all start oscillating. You could constrain x,z motion and only allow y (or up/down motion)

  • fake it by summing sinewaves of different amplitudes and frequencies. Some thing like this:

     rez = 32;
     for(i=-rez; i<rez; i++)
        for(j=-rez; j<rez; j++)
        {
           yofs = 0;
           yofs += 1.0 * sin( t + j*0.5 + i*0.125);
           yofs += 2.0 * sin( t + (rez-j)*0.125 + i*0.25 );
           yofs += 2.0 * sin( t + (j)*0.125 + (rez-i)*0.125 );
           yofs += 0.5 * sin( t + (rez+j)*0.125 + (rez+i)*0.125 );
           glVertex(i/rez, yofs, j/rez);
        }
    
  • simulate the 2D wave equation, this can be very fast on the GPU. See this page for a java applet and some pseudo code. Also check this version, the same but even simpler. A processing sketch with code.

From the wave equation sim you can get the direction (dx,dz) of the wave is traveling in

dx = h[x-1][z] - h[x+1][z] 
dz = h[x][z-1]- h[x][x+1] 

where h a 2D array with the height of the wave at [x][z]

You could add this to the boats position to make it travel with the wave... I've tried, but the movement becomes jerky, so I smoothed it out with a simple 3x3 box filter (smoothing the differences/velocities dx dz)

formatting; added 40 characters in body
Source Link

Do you have a water simulation?

My suggestions are

  • fake it with springs. Each vertex on the water surface is couledcoupled together into a spring mesh. Pull one down and they all start oscilatingoscillating. You could constrain x,z motion and only allow y (or up/down motion)

  • fake it by summing sinewaves of harmonic (?)different amplitudes and frequencies. Some thing like this:

    rez = 32;
    for(i=-32;rez; i<32;i<rez; i++)
    for(j=-32;rez; j<32;j<rez; j++)
    {
       yofs = 0;
       yofs += 1.0*sin0 * sin( 1*tt + j/2j*0.5 + i/16i*0.125);
       yofs += 2.0*sin0 * sin( 1*tt + (32rez-j)/4*0.125 + (i)/8i*0.25 );
       yofs += 2.0*sin0 * sin( 1*tt + (j)/4*0.125 + (32rez-i)/4*0.125 );
       yofs += 0.5*sin5 * sin( 1*tt + (32+jrez+j)/4*0.125 + (32+irez+i)/4*0.125 );
       glVertex(i/32.0rez, yofs, j/32.0rez);
    
  • simulate the 2D wave equation, this can be very fast on the GPU. See this page for a java applet and some pseudo code. Also check this version, the same but even simpler. A processing sketch with code.

From the wave equation sim you can get the direction (dx,dz) of the wave is traveling in

dx = h[x-1][z] - h[x+1][z] 
dz = h[x][z-1]- h[x][x+1] 

where h a 2D array with the height of the wave at [x][z]

You could add this to the boats position to make it travel with the wave... I've tried, but the movement becomes jerky, so I smoothed it out with a simple 3x3 box filter (smoothing the differences/velocities dx dz)

Do you have a water simulation?

My suggestions are

  • fake it with springs. Each vertex on the water surface is couled together into a spring mesh. Pull one down and they all start oscilating. You could constrain x,z motion and only allow y (or up/down motion)

  • fake it by summing sinewaves of harmonic (?) frequencies. Some thing like this:

    for(i=-32; i<32; i++)
    for(j=-32; j<32; j++)
    {
       yofs = 0;
       yofs += 1.0*sin( 1*t + j/2 + i/16);
       yofs += 2.0*sin( 1*t + (32-j)/4 + (i)/8 );
       yofs += 2.0*sin( 1*t + (j)/4 + (32-i)/4 );
       yofs += .5*sin( 1*t + (32+j)/4 + (32+i)/4 );
       glVertex(i/32.0,yofs,j/32.0)
    
  • simulate the 2D wave equation, this can be very fast on the GPU. See this page for a java applet and some pseudo code. Also check this version, the same but even simpler. A processing sketch with code.

From the wave equation sim you can get the direction (dx,dz) of the wave is traveling in

dx = h[x-1][z] - h[x+1][z] 
dz = h[x][z-1]- h[x][x+1] 

where h a 2D array with the height of the wave at [x][z]

You could add this to the boats position to make it travel with the wave... I've tried, but the movement becomes jerky, so I smoothed it out with a simple 3x3 box filter (smoothing the differences/velocities dx dz)

Do you have a water simulation?

My suggestions are

  • fake it with springs. Each vertex on the water surface is coupled together into a spring mesh. Pull one down and they all start oscillating. You could constrain x,z motion and only allow y (or up/down motion)

  • fake it by summing sinewaves of different amplitudes and frequencies. Some thing like this:

    rez = 32;
    for(i=-rez; i<rez; i++)
    for(j=-rez; j<rez; j++)
    {
       yofs = 0;
       yofs += 1.0 * sin( t + j*0.5 + i*0.125);
       yofs += 2.0 * sin( t + (rez-j)*0.125 + i*0.25 );
       yofs += 2.0 * sin( t + (j)*0.125 + (rez-i)*0.125 );
       yofs += 0.5 * sin( t + (rez+j)*0.125 + (rez+i)*0.125 );
       glVertex(i/rez, yofs, j/rez);
    
  • simulate the 2D wave equation, this can be very fast on the GPU. See this page for a java applet and some pseudo code. Also check this version, the same but even simpler. A processing sketch with code.

From the wave equation sim you can get the direction (dx,dz) of the wave is traveling in

dx = h[x-1][z] - h[x+1][z] 
dz = h[x][z-1]- h[x][x+1] 

where h a 2D array with the height of the wave at [x][z]

You could add this to the boats position to make it travel with the wave... I've tried, but the movement becomes jerky, so I smoothed it out with a simple 3x3 box filter (smoothing the differences/velocities dx dz)

Source Link

Do you have a water simulation?

My suggestions are

  • fake it with springs. Each vertex on the water surface is couled together into a spring mesh. Pull one down and they all start oscilating. You could constrain x,z motion and only allow y (or up/down motion)

  • fake it by summing sinewaves of harmonic (?) frequencies. Some thing like this:

    for(i=-32; i<32; i++)
    for(j=-32; j<32; j++)
    {
       yofs = 0;
       yofs += 1.0*sin( 1*t + j/2 + i/16);
       yofs += 2.0*sin( 1*t + (32-j)/4 + (i)/8 );
       yofs += 2.0*sin( 1*t + (j)/4 + (32-i)/4 );
       yofs += .5*sin( 1*t + (32+j)/4 + (32+i)/4 );
       glVertex(i/32.0,yofs,j/32.0)
    
  • simulate the 2D wave equation, this can be very fast on the GPU. See this page for a java applet and some pseudo code. Also check this version, the same but even simpler. A processing sketch with code.

From the wave equation sim you can get the direction (dx,dz) of the wave is traveling in

dx = h[x-1][z] - h[x+1][z] 
dz = h[x][z-1]- h[x][x+1] 

where h a 2D array with the height of the wave at [x][z]

You could add this to the boats position to make it travel with the wave... I've tried, but the movement becomes jerky, so I smoothed it out with a simple 3x3 box filter (smoothing the differences/velocities dx dz)