-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerspection.pde
More file actions
180 lines (149 loc) · 3.51 KB
/
Perspection.pde
File metadata and controls
180 lines (149 loc) · 3.51 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import processing.dxf.*;
import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.geometry.*;
PeasyCam cam;
boolean record;
boolean controlZoom=false;
boolean orbit = false;
boolean recordEnt=false;
PImage[] pictures= new PImage[722];
ArrayList<IntList> picArray = new ArrayList<IntList>();
int val=0;
int step=0;
int weight=1;
int threshold=-200;
int index=0;
int counter=0;
int tempVal=997;
float rotation =90;
float zoom=0;
void setup() {
size(1500, 800, P3D);
cam = new PeasyCam(this, 550);
for (int i=0; i<pictures.length; i++) {
if (i<=8) {
pictures[i]=loadImage("thumb000"+(i+1)+".png");
}
if (i>=9&&i<=98) {
// println("thumb00"+(i+1)+".png");
pictures[i]=loadImage("thumb00"+(i+1)+".png");
}
if (i>=99) {
//println("thumb0"+(i+1)+".png");
pictures[i]=loadImage("thumb0"+(i+1)+".png");
}
}
//-----------------------//
//make an array of arrays//
//-----------------------//
int dimension = pictures[0].width * pictures[0].height;
for (int i=0; i<pictures.length; i++) {
IntList points1 = new IntList();
IntList points2 = new IntList();
pictures[i].loadPixels();
// IntList points1 = new IntList();
for (int u = 0; u < dimension; u += 1) {
points1.append(int(map(pictures[i].pixels[u], -16777216, -1, 200, 0)));
points2.append(pictures[i].pixels[u]);
}
picArray.add(points1);
picArray.add(points2);
pictures[i].updatePixels();
}
println("Entering Draw");
}
void draw() {
background(255);
if (orbit) {
float orbitRadius= 550-zoom;//mouseX/2+100;
float ypos= 0;//mouseY/3;
float xpos= cos(radians(rotation))*orbitRadius;
float zpos= sin(radians(rotation))*orbitRadius;
camera(xpos, ypos, zpos, 0, 0, 0, 0, 1, 0);
if (zoom>=0&&zoom<150&&!controlZoom) {
zoom+=1;
if (zoom>148) {
controlZoom=true;
}
} else if (zoom>1&&controlZoom) {
zoom-=1;
}
println(zoom);
rotation++;
}
if (record) {
beginRaw(DXF, "pointCloud"+tempVal+".dxf");
}
int i=0;
lights();
pushMatrix();
rotate(PI/2);
for (int x=-pictures[0].height/2; x<pictures[0].height/2; x+=1) {
for (int y=-pictures[0].width/2; y<pictures[0].width/2; y+=1) {
stroke(picArray.get(index+1).get(i));
point(x, y, picArray.get(index).get(i));
counter++;
strokeWeight(weight);
if (i<picArray.get(index).size()) {
i++;
}
}
}
popMatrix();
if (index+2<picArray.size()) {
index+=2;
}
if (recordEnt) {
saveFrame("entrance"+frameCount+".png");
}
if (keyPressed) {
if (key == 'b' || key == 'B') {
step-=100;
}
if (key == 'e' || key == 'E') {
index+=2;
i=0;
println("index is "+index);
}
if (key == 'r' || key == 'R') {
if (index>0) {
index-=2;
i=0;
println("index is "+index);
}
}
if (key == 'g' || key == 'G') {
if (tempVal>1) {
tempVal-=1;
}
}
if (key == 'j' || key == 'J') {
recordEnt=true;
}
if (key == 'o' || key == 'O') {
orbit=true;
}
}
if (record) {
endRaw();
record = false;
}
}
void keyPressed() {
if (key == CODED) {
if (keyCode == UP) {
threshold+=5;
} else if (keyCode == DOWN) {
threshold-=5;
} else if (keyCode == LEFT) {
weight-=1;
println(weight);
} else if (keyCode == RIGHT) {
weight+=1;
println(weight);
}
} else if (key == 't') {
record = true;
}
}