summaryrefslogtreecommitdiff
path: root/src/arap.h
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2024-04-09 03:14:17 -0400
committersotech117 <michael_foiani@brown.edu>2024-04-09 03:14:17 -0400
commit7a8d0d8bc2572707c9d35006f30ea835c86954b0 (patch)
treededb9a65c1698202ad485378b4186b667008abe5 /src/arap.h
parent818324678bd5dca790c57048e5012d2937a4b5e5 (diff)
first draft to generate waves
Diffstat (limited to 'src/arap.h')
-rw-r--r--src/arap.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/arap.h b/src/arap.h
new file mode 100644
index 0000000..1d58f07
--- /dev/null
+++ b/src/arap.h
@@ -0,0 +1,69 @@
+#pragma once
+
+#include "graphics/shape.h"
+#include "Eigen/StdList"
+#include "Eigen/StdVector"
+#include <Eigen/Core>
+#include <Eigen/Dense>
+#include <Eigen/Sparse>
+#include <Eigen/SVD>
+#include <QList>
+#include <QtConcurrent>
+
+class Shader;
+
+class ARAP
+{
+private:
+ Shape m_shape;
+
+public:
+ ARAP();
+
+ void init(Eigen::Vector3f &min, Eigen::Vector3f &max);
+ void move(int vertex, Eigen::Vector3f pos);
+
+ // ================== Students, If You Choose To Modify The Code Below, It's On You
+
+ int getClosestVertex(Eigen::Vector3f start, Eigen::Vector3f ray, float threshold)
+ {
+ return m_shape.getClosestVertex(start, ray, threshold);
+ }
+
+ void draw(Shader *shader, GLenum mode)
+ {
+ m_shape.draw(shader, mode);
+ }
+
+ SelectMode select(Shader *shader, int vertex)
+ {
+ return m_shape.select(shader, vertex);
+ }
+
+ bool selectWithSpecifiedMode(Shader *shader, int vertex, SelectMode mode)
+ {
+ return m_shape.selectWithSpecifiedMode(shader, vertex, mode);
+ }
+
+ bool getAnchorPos(int lastSelected, Eigen::Vector3f& pos, Eigen::Vector3f ray, Eigen::Vector3f start)
+ {
+ return m_shape.getAnchorPos(lastSelected, pos, ray, start);
+ }
+
+ // for determinig when to recompute
+ int num_anchors;
+
+ typedef Eigen::Matrix<float, 3, Eigen::Dynamic> PM; // position matrix
+ typedef Eigen::Matrix<float, 3, 3> RM; // rotation matrix
+ typedef Eigen::SparseMatrix<float, Eigen::RowMajor> Sparse;
+
+ std::vector<RM> m_rotations;
+ Sparse m_edge_weights;
+ PM m_b, m_b_fixed;
+ std::vector<Eigen::Index> m_vtx_to_free_vtx;
+ Eigen::SimplicialLDLT<Eigen::SparseMatrix<float>> m_solver;
+
+ int m_num_iterations;
+ const char * m_mesh_path;
+};
+