diff options
author | Sebastian Park <SebPark03@gmail.com> | 2024-04-10 02:45:04 -0400 |
---|---|---|
committer | Sebastian Park <SebPark03@gmail.com> | 2024-04-10 02:45:04 -0400 |
commit | 47cd8a592ecad52c1b01f27d23476c0a5afeb7f1 (patch) | |
tree | 36b9abaff4e92a4a6df0d5ecb0e43e05c3aefd48 /src | |
parent | fd19124693bb32835ad97802ba1950cd5202dbd2 (diff) |
initial
Diffstat (limited to 'src')
-rw-r--r-- | src/arap.cpp | 4 | ||||
-rwxr-xr-x | src/glwidget.cpp | 20 | ||||
-rw-r--r-- | src/graphics/shape.cpp | 6 | ||||
-rw-r--r-- | src/graphics/shape.h | 2 | ||||
-rw-r--r-- | src/ocean/ocean.h | 8 |
5 files changed, 26 insertions, 14 deletions
diff --git a/src/arap.cpp b/src/arap.cpp index 3ebdf64..5d8a373 100644 --- a/src/arap.cpp +++ b/src/arap.cpp @@ -34,10 +34,10 @@ void ARAP::init // m_shape.init(vertices, triangles); // } - vertices = m_ocean.get_vertices(); triangles = m_ocean.get_faces(); m_shape.init(vertices, triangles); + m_shape.setColor(0.27f, .803f, .96f); // Students, please don't touch this code: get min and max for viewport stuff MatrixX3f all_vertices = MatrixX3f(vertices.size(), 3); @@ -67,7 +67,7 @@ void ARAP::update(double seconds) m_shape.setVertices(m_ocean.get_vertices()); m_time += m_timestep; - std::cout << m_time << std::endl; +// std::cout << m_time << std::endl; } // Move an anchored vertex, defined by its index, to targetPosition diff --git a/src/glwidget.cpp b/src/glwidget.cpp index 2a7a452..2801251 100755 --- a/src/glwidget.cpp +++ b/src/glwidget.cpp @@ -112,23 +112,27 @@ void GLWidget::initializeGL() void GLWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable( GL_BLEND ); m_defaultShader->bind(); m_defaultShader->setUniform("proj", m_camera.getProjection()); m_defaultShader->setUniform("view", m_camera.getView()); + Eigen::Matrix4f inverseView = m_camera.getView().inverse(); + m_defaultShader->setUniform("inverseView", inverseView); m_arap.draw(m_defaultShader, GL_TRIANGLES); m_defaultShader->unbind(); glClear(GL_DEPTH_BUFFER_BIT); - m_pointShader->bind(); - m_pointShader->setUniform("proj", m_camera.getProjection()); - m_pointShader->setUniform("view", m_camera.getView()); - m_pointShader->setUniform("vSize", m_vSize); - m_pointShader->setUniform("width", width()); - m_pointShader->setUniform("height", height()); - m_arap.draw(m_pointShader, GL_POINTS); - m_pointShader->unbind(); +// m_pointShader->bind(); +// m_pointShader->setUniform("proj", m_camera.getProjection()); +// m_pointShader->setUniform("view", m_camera.getView()); +// m_pointShader->setUniform("vSize", m_vSize); +// m_pointShader->setUniform("width", width()); +// m_pointShader->setUniform("height", height()); +// m_arap.draw(m_pointShader, GL_POINTS); +// m_pointShader->unbind(); } void GLWidget::resizeGL(int w, int h) diff --git a/src/graphics/shape.cpp b/src/graphics/shape.cpp index 8fe35b1..9459306 100644 --- a/src/graphics/shape.cpp +++ b/src/graphics/shape.cpp @@ -104,6 +104,12 @@ void Shape::setModelMatrix(const Affine3f &model) { m_modelMatrix = model.matrix // ================== General Graphics Stuff +void Shape::setColor(float r, float g, float b) { + m_red = r; + m_green = g; + m_blue = b; +} + void Shape::draw(Shader *shader, GLenum mode) { Eigen::Matrix3f m3 = m_modelMatrix.topLeftCorner(3, 3); diff --git a/src/graphics/shape.h b/src/graphics/shape.h index 3ba81fb..1451c85 100644 --- a/src/graphics/shape.h +++ b/src/graphics/shape.h @@ -31,6 +31,8 @@ public: void setModelMatrix(const Eigen::Affine3f &model); + void setColor(float r, float g, float b); + void draw(Shader *shader, GLenum mode); SelectMode select(Shader *shader, int vertex); bool selectWithSpecifiedMode(Shader *shader, int vertex, SelectMode mode); diff --git a/src/ocean/ocean.h b/src/ocean/ocean.h index a576c44..b3197f8 100644 --- a/src/ocean/ocean.h +++ b/src/ocean/ocean.h @@ -23,12 +23,12 @@ public: private: - const int length = 32; // length of grid - const int width = 32; // width of grid + const int length = 256; // length of grid + const int width = 256; // width of grid const int N = length * width; // total number of grid points - const double A = 10; // numeric constant for the Phillips spectrum - const double V = 5.0; // wind speed + const double A = 30; // numeric constant for the Phillips spectrum + const double V = 0.5; // wind speed const std::pair<double, double> omega_wind = std::make_pair(1.0, 0.0); // wind direction |