#include "WaveMesh.h" float WaveMesh::heightMap(std::size_t nx, std::size_t ny) const { float x = _xs[nx]; float y = _xs[ny]; float d = 50*sqrtf(x*x + y*y); return cosf(d - _shift)*expf(-d/10.0f)/2; } float WaveMesh::heightMap(float fx, float fy) const { float d = 50*sqrtf(fx*fx + fy*fy); return cosf(d - _shift)*expf(-d/10.0f)/2; } void WaveMesh::setShift(float shift) { _shift = shift; update(); } WaveMesh::WaveMesh(ShaderProgram *shader, std::size_t size): Mesh(shader, size), _shift(0) { float step = 1.0f/size; for(std::size_t i = 0; i < size; ++i) { _xs[i] = step*i - 0.5f; _ys[i] = _xs[i]; } } WaveMesh::~WaveMesh() { }