diff options
Diffstat (limited to 'src/ocean')
-rw-r--r-- | src/ocean/ocean_alt.cpp | 18 | ||||
-rw-r--r-- | src/ocean/ocean_alt.h | 12 |
2 files changed, 18 insertions, 12 deletions
diff --git a/src/ocean/ocean_alt.cpp b/src/ocean/ocean_alt.cpp index dcc3e42..58e76f8 100644 --- a/src/ocean/ocean_alt.cpp +++ b/src/ocean/ocean_alt.cpp @@ -330,6 +330,7 @@ void ocean_alt::update_ocean() // reset normals & vertices arrays for the single tile m_vertices = std::vector<Eigen::Vector3f>(N); m_normals = std::vector<Eigen::Vector3f>(N); + m_heights.clear(); for (int i = 0; i < N; i++){ Eigen::Vector2d horiz_pos = spacing*m_waveIndexConstants[i].base_horiz_pos; Eigen::Vector2d amplitude = m_current_h[i]; @@ -357,9 +358,10 @@ void ocean_alt::update_ocean() Eigen::Vector2d disp = lambda*Eigen::Vector2d(m_displacements_x[i][0], m_displacements_z[i][0]) + Eigen::Vector2d(vertex_displacement, vertex_displacement); // set corner at 0,0 for retiling + Eigen::Vector3f v = Eigen::Vector3f(horiz_pos[0] + disp[0], height, horiz_pos[1] + disp[1]); // for final vertex position, use the real number component of amplitude vector - m_vertices[i] = {horiz_pos[0] + disp[0], height, horiz_pos[1] + disp[1]}; + m_vertices[i] = v; m_normals[i] = norm.normalized();//Eigen::Vector3f(-slope[0], 1.0, -slope[1]).normalized(); //std::cout << "normal: " << m_normals[i] << std::endl Eigen::Vector2i m_n = index_1d_to_2d(i); @@ -367,14 +369,14 @@ void ocean_alt::update_ocean() // m_foam_constants.wavelengths[i] = 2.f* M_PI * m_slopes[i].dot(m_slopes[i]) / Lx; float h_0 = m_waveIndexConstants[i].h0_prime[0]; // min*.2f; - float h_max = max*.01f; // the smaller the constant, the more foam there is - m_foam_constants.wavelengths[i] = (height - h_0 ) / (h_max - h_0); - -// if (i < 5){ -// std::cout << h_0 << ", " << h_max << std::endl; -// std::cout << m_foam_constants.wavelengths[i] << std::endl; -// } + float h_max = max*.001f; // the smaller the constant, the more foam there is + float waveheight = (height - h_0 ) / (h_max - h_0); + m_foam_constants.wavelengths[i] = waveheight; + if (waveheight >= height_threshold){ + //std::cout << "push" << std::endl; + m_heights.push_back(v); + } } diff --git a/src/ocean/ocean_alt.h b/src/ocean/ocean_alt.h index 9c5e4e2..a5bcd12 100644 --- a/src/ocean/ocean_alt.h +++ b/src/ocean/ocean_alt.h @@ -43,6 +43,8 @@ public: } std::vector<Eigen::Vector3f> m_vertices; // current displacement vector for each K + std::vector<Eigen::Vector3f> m_heights; // stores height above threshold + @@ -71,8 +73,8 @@ private: const double Lx = 512.0; const double Lz = 512.0; - const int num_rows = 256; - const int num_cols = 256; + const int num_rows = 128; + const int num_cols = 128; const int num_tiles_x = 1; const int num_tiles_z = 1; @@ -83,8 +85,8 @@ private: const double lambda = .5; // how much displacement matters const double spacing = 1.0; // spacing between grid points - const double A = 10000; // numeric constant for the Phillips spectrum - const double V = 500; // wind speed + const double A = 100; // numeric constant for the Phillips spectrum + const double V = 50; // wind speed const double gravity = 9.81; const double L = V*V/gravity; const Eigen::Vector2d omega_wind = Eigen::Vector2d(1.0, 0.0); // wind direction, used in Phillips equation @@ -102,6 +104,8 @@ private: // FOR FOAM: FoamConstants m_foam_constants; + float height_threshold = 2.f; + float max = 0; |