66// A brief descrition on how it works: a 360° view of the scene is generated
77// by rendering the scene 6 times from each direction: positive x, negative x,
88// positive y, and so on. The output of each rendering is stored inside a cube map
9- // texture, which is then applied on a sphere representing the dome.
9+ // texture, which is then rendered on to a quad using a raytraced fisheye lens.
10+ //
1011// Hence, the library calls the draw() method 6 times per frame in order to update
1112// the corresponding side of the cube map texture (in reality, only 5 times since
1213// the bottom side of the cube map is not invisible on the dome).
14+ // Now you can manually set which face should render using domeCamera's toggleFaceDraw() method.
15+ //
1316// So, it is important to keep in mind that if you need to perform some calculation
1417// only one time per frame, then the code for those calculations should be put inside
1518// the pre() method.
@@ -24,8 +27,15 @@ int gridMode = Dome.NORMAL;
2427void setup () {
2528 // For the time being, only use square windows
2629 size (1024 , 1024 , Dome . RENDERER );
27-
30+ // initial default camera, i.e. interface to interact with the renderer.
2831 dc = new DomeCamera (this );
32+ // Set the aperture, or radial coverage of the dome.
33+ // 1 is default, 2 would show the contents of an entire sphere.
34+ dc. setDomeAperture(2f );
35+ // we enable the sixth side, sothat we see what is happenning
36+ dc. setFaceDraw(DomeCamera . NEGATIVE_Z , true );
37+ // This method unfortunately doesn't work yet.
38+ // dc.setCubemapSize(2048);
2939}
3040
3141// Called one time per frame.
@@ -38,13 +48,13 @@ void pre() {
3848
3949// Called five times per frame.
4050void draw () {
41- background (0 );
42-
43- pushMatrix ();
51+ background (0 , 0 , 0 , 0 );
52+
53+ pushMatrix ();
54+
4455 translate (width / 2 , height / 2 , - 300 );
45-
4656 lights ();
47-
57+
4858 stroke (0 );
4959 fill (150 );
5060 pushMatrix ();
@@ -54,7 +64,7 @@ void draw() {
5464
5565 stroke (255 );
5666 int linesAmount = 10 ;
57- for (int i = 0 ; i < linesAmount;i++ ) {
67+ for (int i = 0 ; i < linesAmount; i++ ) {
5868 float ratio = (float )i/ (linesAmount- 1 );
5969 line (0 , 0 , cos (ratio* TWO_PI ) * 50 , sin (ratio* TWO_PI ) * 50 );
6070 }
@@ -63,16 +73,51 @@ void draw() {
6373
6474void mouseDragged () {
6575 // exaggerating dome aperture. 1f <=> 180°
66- dc. setDomeAperture(map (mouseY ,0 , height ,0.1f ,4f ));
76+ dc. setDomeAperture(map (mouseY , 0 , height , 0.1f , 2f ));
6777}
6878
6979void keyPressed () {
7080 if (key == CODED ) {
7181 if (keyCode == UP ) cubeZ -= 5 ;
7282 else if (keyCode == DOWN ) cubeZ += 5 ;
7383 }
74- if (key == ' ' ) {
84+ switch (key ) {
85+ case ' ' :
7586 gridMode = gridMode == Dome . GRID ? Dome . NORMAL : Dome . GRID ;
87+ // enables rendering of a reference grid (happens inside the shader)
7688 dc. setMode(gridMode);
89+ break ;
90+ case ' e' :
91+ // fulldome-conform rendering
92+ dc. enable();
93+ break ;
94+ case ' d' :
95+ // rendering only into a single, conventional camera
96+ dc. disable();
97+ break ;
98+ case ' 0' :
99+ // toggles rendering into the X+ side of the cubemap
100+ dc. toggleFaceDraw(0 );
101+ break ;
102+ case ' 1' :
103+ // toggles rendering into the X- side of the cubemap
104+ dc. toggleFaceDraw(1 );
105+ break ;
106+ case ' 2' :
107+ // toggles rendering into the Y+ side of the cubemap
108+ dc. toggleFaceDraw(2 );
109+ break ;
110+ case ' 3' :
111+ // toggles rendering into the Y- side of the cubemap
112+ dc. toggleFaceDraw(3 );
113+ break ;
114+ case ' 4' :
115+ // toggles rendering into the Z+ side of the cubemap
116+ dc. toggleFaceDraw(4 );
117+ break ;
118+ case ' 5' :
119+ // toggles rendering into the Z- side of the cubemap
120+ dc. toggleFaceDraw(5 );
121+ break ;
77122 }
78123}
0 commit comments