-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSphere.pde
More file actions
62 lines (58 loc) · 1.97 KB
/
Sphere.pde
File metadata and controls
62 lines (58 loc) · 1.97 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
class Sphere {
private int radius = 500;
private int[] nClipsInLayer = {1, 7, 12, 14, 12, 7, 1};
//private int[] nClipsInLayer = {0, 3, 7, 9, 11, 13, 11, 9, 7, 3, 0};
private float[] startingFi = new float[nClipsInLayer.length];
private float[] theta = new float[nClipsInLayer.length];
private Clip[] clips;
public float cameraRotX = 0;
public float cameraRotY = 0;
public float cameraTransZ = 0;
public float transZSensibility = 1;
public int currentVideo = 0;
public boolean isPlaying = false;
Sphere (PApplet pApplet, float clipDensity) {// clipDensity:Percentage of sphere area covered with clips.
int totalNumberOfClips = 0;
for (int layer=0; layer<nClipsInLayer.length; layer++){
totalNumberOfClips+=nClipsInLayer[layer];
this.startingFi[layer] = random(QUARTER_PI);
this.theta[layer] = layer*PI/(nClipsInLayer.length-1);
}
float sumOfMovieAreas = clipDensity*PI*4*sq(this.radius);
float areaPerMovie = sumOfMovieAreas/totalNumberOfClips;
float movieSize = sqrt(areaPerMovie); // Average size of the video
this.clips = new Clip[totalNumberOfClips];
int clip=0;
for (int layer = 0; layer < nClipsInLayer.length; layer++) {
float fi = startingFi[layer]; // fi: "horizontal".
for (float c = 0; c < nClipsInLayer[layer]; c++) {
this.clips[clip] = new Clip(pApplet, this, movieSize, fi, this.theta[layer]);
clip++;
fi += TWO_PI/nClipsInLayer[layer];
}
}
}
public void display() {
background(0);
this.setCamera();
this.isPlaying = false;
for(Clip clip:this.clips){
clip.display();
if(clip.isFocus){
this.isPlaying = true;
this.currentVideo = clip.indexVideo;
}
}
if(!isPlaying){
this.currentVideo = 0;
}
}
private void setCamera(){
beginCamera();
camera();
translate(width/2, height/2, this.cameraTransZ);
rotateX(this.cameraRotX);
rotateY(this.cameraRotY);
endCamera();
}
}