3
$\begingroup$

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...

$\endgroup$
2
  • 1
    $\begingroup$ 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. $\endgroup$ Apr 7 '17 at 19:12
  • $\begingroup$ @ArjanSingh Yes! I updated the question. $\endgroup$
    – Cu2S
    Apr 8 '17 at 2:49
2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.