3

I'm confused by the Waves class implementation in the source code of the book Introduction to 3D Game Programming with DirecX11:

float d = damping*dt+2.0f;
float e = (speed*speed)*(dt*dt)/(dx*dx);
mK1     = (damping*dt-2.0f)/ d;
mK2     = (4.0f-8.0f*e) / d;
mK3     = (2.0f*e) / d;

What do the parameters mean? How are the waves generated? I've tried searching waves implementation and found https://stackoverflow.com/questions/6716887/how-to-render-ocean-wave-using-opengl-in-3d , I looked up the links mentioned by the answer but I couldn't understand the complicated equations and it seems that the equations have no relation with the code above. I also tried searching "spatially damped wave", and then I found https://physics.stackexchange.com/questions/223366/wave-equation-with-spatial-damping, that didn't help me, neither...

Cu2S
  • 167
  • 4
  • 1
    Could you be a little more specific as to what you don't really understand? Is it how the waves are generated and the parameters? I'm sure many people here could help you. – Arjan Singh Apr 07 '17 at 19:12
  • @ArjanSingh Yes! I updated the question. – Cu2S Apr 08 '17 at 02:49

1 Answers1

2

This implementation represents the water as a regular height field grid. The function parameters m and n are the dimensions of the grid, dx is the regular distance between the water vertices, dt is the time step, speed is the speed of the movement and damping is a constant to ease disturbance as the water flows from the disturbance center.