Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit 37df716

Browse files
committed
updates examples
1 parent 14d4fbb commit 37df716

File tree

3 files changed

+130
-10
lines changed

3 files changed

+130
-10
lines changed

examples/Basic/Basic.pde

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
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;
2427
void 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.
4050
void 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

6474
void 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

6979
void 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
}

examples/Overlay/Overlay.pde

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// The planetarium library is designed to create real-time projections on
2+
// spherical domes. It is based on the FullDome project by Christopher
3+
// Warnow (ch.warnow@gmx.de):
4+
// https://github.com/mphasize/FullDome
5+
//
6+
// A brief descrition on how it works: a 360° view of the scene is generated
7+
// by rendering the scene 6 times from each direction: positive x, negative x,
8+
// positive y, and so on. The output of each rendering is stored inside a cube map
9+
// texture, which is then rendered on to a quad using a raytraced fisheye lens.
10+
//
11+
// Hence, the library calls the draw() method 6 times per frame in order to update
12+
// the corresponding side of the cube map texture (in reality, only 5 times since
13+
// 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+
//
16+
// So, it is important to keep in mind that if you need to perform some calculation
17+
// only one time per frame, then the code for those calculations should be put inside
18+
// the pre() method.
19+
20+
import codeanticode.planetarium.*;
21+
22+
float cubeX, cubeY, cubeZ;
23+
PImage grid;
24+
25+
DomeCamera dc;
26+
int gridMode = Dome.NORMAL;
27+
28+
void setup() {
29+
// For the time being, only use square windows
30+
size(1024, 1024, Dome.RENDERER);
31+
32+
dc = new DomeCamera(this);
33+
grid = loadImage("DomeGrid_2k.png");
34+
}
35+
36+
// Called one time per frame.
37+
void pre() {
38+
// The dome projection is centered at (0, 0), so the mouse coordinates
39+
// need to be offset by (width/2, height/2)
40+
cubeX += ((mouseX - width * 0.5) - cubeX) * 0.2;
41+
cubeY += ((mouseY - height * 0.5) - cubeY) * 0.2;
42+
dc.imageToForeground(grid,0,0,width,height);
43+
}
44+
45+
// Called five times per frame.
46+
void draw() {
47+
background(0, 0, 0, 0);
48+
49+
pushMatrix();
50+
51+
translate(width/2, height/2, -300);
52+
lights();
53+
54+
stroke(0);
55+
fill(150);
56+
pushMatrix();
57+
translate(cubeX, cubeY, cubeZ);
58+
box(50);
59+
popMatrix();
60+
61+
stroke(255);
62+
int linesAmount = 10;
63+
for (int i = 0; i < linesAmount; i++) {
64+
float ratio = (float)i/(linesAmount-1);
65+
line(0, 0, cos(ratio*TWO_PI) * 50, sin(ratio*TWO_PI) * 50);
66+
}
67+
popMatrix();
68+
}
69+
70+
void keyPressed() {
71+
if (key == CODED) {
72+
if (keyCode == UP) cubeZ -= 5;
73+
else if (keyCode == DOWN) cubeZ += 5;
74+
}
75+
}
1.04 MB
Loading

0 commit comments

Comments
 (0)