1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#pragma once
#include "graphics/shape.h"
//#include "graphics/simpleshape.h"
//#include "graphics/oceanshape.h"
#include "Eigen/StdList"
#include "Eigen/StdVector"
#include "ocean/ocean.h"
#include "ocean/ocean_alt.h"
#include <Eigen/Core>
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <Eigen/SVD>
#include <QList>
#include <QtConcurrent>
class Shader;
class ARAP
{
private:
Shape m_shape;
Shape m_foam_shape;
// OceanShape m_oceanShape;
void initCausticsShape(int res);
public:
ARAP();
void init(Eigen::Vector3f &min, Eigen::Vector3f &max);
void move(int vertex, Eigen::Vector3f pos);
void update(double seconds);
ocean_alt m_ocean;
// ================== 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_causticsShape.draw(shader, mode);
m_shape.draw(shader, mode);
}
void drawFoam(Shader *shader, GLenum mode)
{
m_foam_shape.draw(shader, mode);
}
double getTime() {
return m_time;
}
void initGroundPlane(std::string texturePath, float depth, Shader* shader) {
m_shape.initGroundPlane(texturePath, depth, shader);
}
void initSkyPlane(std::string texturePath, float height, Shader* shader) {
m_shape.initSkyPlane(texturePath, height, shader);
}
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;
double m_time = 0.00;
double m_timestep = 0.3;
Eigen::Vector3f minCorner, maxCorner;
Shape m_causticsShape;
};
|