Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - Wave Pool

Author
Message
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 6th Oct 2012 04:26 Edited at: 6th Oct 2012 04:39
No interactivity yet, but I just managed to pick up this awesome method of wave simulation from http://www.falstad.com/ripple/. It's WAY faster and more stable than my previous attempts. The grid displayed is 80x80=6400 elements, and you can actually run the simulation about 20 times faster before you start to notice a slowdown.

[EDIT] Added comments so you can look at it and change values. ALL CAPS = changeme. [/EDIT]



The setup is this: 80x80 blocks, one horizontal wave is generated from blocks (0,0) to (0,60ish), with a period of 360 frames (limited to 60fps=6 seconds). There's a triangle in the center, with a SLOWER wave speed. Part of the generated wave goes through this prism-triangle, and then most of it is internally reflected in the triangle by a 90 degree angle. There's also a wall (wave speed=0) preventing waves from getting through and messing up the nice, pretty reflected wave


I'm pretty new to everything involving waves, so I can't say exactly the reasoning behind the integration xD
Basically, what I was doing before was taking a grid of heights and velocities (f(x,y).h and f(x,y).v), calculating force as if the current height was attached to four adjacent springs:
force=(f(x-1,h)-f(x,h))*spring_constant+(f(x+1,h)-f(x,h))*spring_constant+ etc. for f(x,h-1) and f(x,h+1).
For reasons that I'm unaware of, this is a bad way to do it, and the numerical simulation seems to inevitably blow up. Since my simulation was so bad, and the ripple tank one so awesome, I checked out the source code, and instead, he takes the current position and velocity as a complex number, f(x,h)=h+vi, and then rotates this complex number around the average height of all adjacent tiles.

noobnerd
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 7th Oct 2012 17:54 Edited at: 7th Oct 2012 18:03
Cool

i dont know why your spring based model didnt work, this one uses springs :




i did it a while ago and it requires d3d plugin for the 3d lines. If you dont have it, just unrem the commands that have something to do with vertexdata or objects and put this in a folder with an
image
and load it where the "load image hexa.jpg is now.

move forward with W and steer with mouse, click with leftmouse to grab a spot and move it up and down or just let the 2 "stirrers" do the job of making waves. press rightmouse to position the light at you coordinates, press space to pause simulation ( this zeroes all the velocities so press repeatedly to calm it down )

but yours is really cool for having medium based reflections and such dont thin they can be handled by spring so easily


use this one if you have a high end computer and the d3dplugin

Login to post a reply

Server time is: 2024-04-25 05:24:37
Your offset time is: 2024-04-25 05:24:37