-
Notifications
You must be signed in to change notification settings - Fork 0
/
PointCloud.pde
83 lines (78 loc) · 1.69 KB
/
PointCloud.pde
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
float lLim=0, uLim=1000000000;
int dir;
int skip, pLim;
int w, h;
int activeX, activeY, activeW, activeH;
int selector;
class Cloud {
ArrayList<PVector> points;
Cloud(int _w, int _h, int _skip) {
activeW = width;
activeH = height;
w = _w;
h = _h;
skip = _skip;
points = new ArrayList<PVector>();
}
boolean t = true;
void select() {
if (mousePressed && t) {
selector++;
t=false;
}
if (!mousePressed) {
t = true;
}
if (selector%3 == 1) {
activeX = mouseX*dir;
activeY = mouseY*dir;
selector ++;
} else if (selector%3 == 2) {
activeW = mouseX*dir-activeX;
activeH = mouseY*dir-activeY;
} else {
selector = 0;
//int[] tx = normalise(activeX,activeW);
//int[] ty = normalise(activeY,activeH);
//activeX = tx[0];
//activeY = ty[0];
//activeW = tx[1];
//activeH = ty[1];
}
pushStyle();
noFill();
rect(activeX, activeY, activeW, activeH);
popStyle();
}
int[] normalise(int a, int b){
if (b > a){
return new int[]{a, b};
}
return new int[]{b, a};
}
int y = 0;
void scan(int[] depth, int _dir) {
dir = _dir;
println(selector);
select();
pushMatrix();
if (dir == -1) {
translate(-w, 0, -462);
}
for (int i = 0; i < depth.length; i+=skip) {
int x = i%(512);
if (i>0 && i%w == 0){
y+= skip/2;
}
//int y =(int) map((i-x)/(512),0,h,0,height);
if (x > activeX && x < activeW+activeX &&
y > activeY && y < activeH+activeY &&
(depth[i]) > lLim &&
(depth[i]) < uLim) {
point(x, y);
}
}
y = 0;
popMatrix();
}
}