-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwsplat.h
127 lines (97 loc) · 2.23 KB
/
wsplat.h
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef WSPLAT_H
#define WSPLAT_H
#include <vector>
#include <gfx/geom3d.h>
#include "smf.h"
struct VertTree {
VertTree() {
left_subtree = right_subtree = 0;
}
VertTree(const Vert& v) : node(v) {
left_subtree = right_subtree = 0;
}
~VertTree() {
delete left_subtree;
delete right_subtree;
}
Vert node;
VertTree* left_subtree;
VertTree* right_subtree;
};
struct Camera {
float calc_projected_dist(const Vec3f& pos);
Vec3f pos;
Vec3f dir;
Vec3f up, left;
float screen_width;
};
class ColorChanger {
public:
ColorChanger();
void change();
void reset_index();
void set_color() const;
private:
std::vector<Vec3f> colors;
int current_index;
};
class WSplat {
public:
WSplat();
void load(const char* fn);
void draw();
void get_bounding_sphere(Vec3f& centroid, float& radius);
void set_camera(const Vec3f& pos, const Vec3f& dir, float screen_width);
void set_error(float tau);
// options exposed to GUI
bool draw_triangles;
bool draw_points;
bool draw_spheres;
bool draw_splats;
bool draw_normals;
bool round_points;
bool change_colors;
bool psychedelic;
bool always_subdivide;
bool abnormal;
bool draw_cones;
bool backface_culling;
bool project_size;
bool allow_quads;
bool quads_only;
bool draw_edges_only;
int max_point_size;
float silhouette_edge_thresh;
Camera cam;
// tree generation options
bool oriented_partition;
bool subdivide_large_tris;
bool subdivide_a_lot;
int num_points_drawn;
private:
TriMesh mesh;
// tree construction
void tessellate_faces();
void compute_bounding_spheres();
void store_normals();
void grow_tree();
VertTree* build_tree(VertIt begin, VertIt end);
// tree rendering
enum NormConeDir { DIR_TOWARD, DIR_UNTOWARD, DIR_UNDECIDED };
void draw_tree(VertTree* tree, NormConeDir cdir);
void draw_quad(const Vec3f& pos, const Vec3f& normal, float radius);
// other functions
void destroy();
// data
Vec3f centroid;
// splat tree of vertices
VertTree* splat_tree;
int num_nodes;
int num_ignored;
int num_zero_norms;
float max_pixel_error;
// rendering params
ColorChanger rainbow;
float normal_scale;
};
#endif //WSPLAT_H