From 2ba27898535e01298ef8f0d0b9ffd4e69ce13458 Mon Sep 17 00:00:00 2001 From: jjesswan Date: Mon, 6 May 2024 00:01:04 -0400 Subject: uv mapping onto water good --- src/ocean/halftone.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/ocean/halftone.h | 19 +++++++++++++++++++ src/ocean/ocean_alt.cpp | 35 +++++++++++++++++++++++++++++++++-- src/ocean/ocean_alt.h | 29 +++++++++++++++++++++++++---- 4 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 src/ocean/halftone.cpp create mode 100644 src/ocean/halftone.h (limited to 'src/ocean') diff --git a/src/ocean/halftone.cpp b/src/ocean/halftone.cpp new file mode 100644 index 0000000..6aa59cb --- /dev/null +++ b/src/ocean/halftone.cpp @@ -0,0 +1,47 @@ +#include "halftone.h" +#include +#include + +halftone::halftone() +{ + +} + +//void halftone::init(int n, int m, float density){ +// N = n; +// M = m; +// // std::vector> m_halftone; +// // 1. intiialize pattern array with density +// for (int i=0; i +class halftone +{ +public: + halftone(); + +private: + int N = 0; + int M = 0; + float m_sigma = 24.f; + std::vector> m_halftone; + +}; + +#endif // HALFTONE_H diff --git a/src/ocean/ocean_alt.cpp b/src/ocean/ocean_alt.cpp index 025e89b..9ba0042 100644 --- a/src/ocean/ocean_alt.cpp +++ b/src/ocean/ocean_alt.cpp @@ -12,6 +12,7 @@ ocean_alt::ocean_alt() // initializes static constants (aka they are not time dependent) void ocean_alt::init_wave_index_constants(){ + float tex_step = 1.f/num_rows; for (int i=0; i ocean_alt::get_vertices() vertices.push_back(Eigen::Vector3f(horiz_pos[0] + disp[0], height, horiz_pos[1] + disp[1])); m_normals[i] = norm.normalized();//Eigen::Vector3f(-slope[0], 1.0, -slope[1]).normalized(); //std::cout << "normal: " << m_normals[i] << std::endl + + + } + + // populate foam constants + m_foam_constants.positions = vertices; + return vertices; } @@ -450,4 +481,4 @@ std::vector ocean_alt::fast_fft } return h; -} \ No newline at end of file +} diff --git a/src/ocean/ocean_alt.h b/src/ocean/ocean_alt.h index 4bb1d54..dc9bb33 100644 --- a/src/ocean/ocean_alt.h +++ b/src/ocean/ocean_alt.h @@ -20,6 +20,13 @@ struct WaveIndexConstant{ Eigen::Vector2d k_vector = Eigen::Vector2d(0.f, 0.f); // static horiz pos with no displacement }; +struct FoamConstants{ + std::vector positions; + std::vector k_vectors; + std::vector wavelengths; + std::vector texCoords; +}; + class ocean_alt { public: @@ -30,6 +37,10 @@ public: void fft_prime(double t); std::vector getNormals(); + FoamConstants getFoamConstants(){ + return m_foam_constants; + } + @@ -49,6 +60,10 @@ private: std::pair sample_complex_gaussian(); + // FOAM + std::vector m_saturation; + + @@ -63,11 +78,11 @@ 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 = 32; + const int num_cols = 32; const int N = num_rows*num_cols; // total number of grid points - const double lambda = 0; // how much displacement matters + const double lambda = 0.3; // how much displacement matters const double spacing = 35.0; // spacing between grid points const double A = 100; // numeric constant for the Phillips spectrum @@ -81,7 +96,13 @@ private: std::vector m_slopes; // current displacement vector for each K //std::vector m_slope_vectors; // current displacement vector for each K - std::vector m_normals; // current displacement vector for each K + std::vector m_normals; // normal calculations + + // FOR FOAM: + FoamConstants m_foam_constants; + + + -- cgit v1.2.3-70-g09d2