├── Java └── DomeTools │ ├── data │ ├── cubemapfrag.glsl │ └── cubemapvert.glsl │ ├── lib │ ├── GLGraphics.jar │ ├── core.jar │ ├── gluegen-rt.jar │ ├── jogl.jar │ ├── opengl.jar │ └── oscP5.jar │ └── src │ ├── charts │ ├── Chart.java │ ├── ChartDemo.java │ ├── ChartImp.java │ ├── Node.java │ └── PieChart.java │ ├── dome │ ├── Dome.java │ ├── Integrator.java │ └── InteractiveDome.java │ ├── domeExamples │ ├── DomeSketch.java │ ├── DomeSketchImp.java │ ├── Example1.java │ └── Example2.java │ ├── domeapp │ ├── DomeModOriginal.java │ ├── DomeTester.java │ └── P5.java │ └── kinedome │ ├── KineDome.java │ └── Skeleton.java ├── Processing ├── FullDomeTemplate │ ├── CubeMapUtils.pde │ ├── FullDomeTemplate.pde │ ├── README.md │ ├── code │ │ ├── GLGraphics.jar │ │ └── libjAppleMenuBar.jnilib │ └── data │ │ ├── cubemapfrag.glsl │ │ └── cubemapvert.glsl └── SimulationTemplate │ ├── Beispiel1.pde │ ├── Beispiel2.pde │ ├── Dome.pde │ ├── DomeSketch.pde │ ├── Integrator.pde │ ├── InteractiveDome.pde │ ├── README.md │ └── SimulationTemplate.pde └── README.md /Java/DomeTools/data/cubemapfrag.glsl: -------------------------------------------------------------------------------- 1 | uniform vec3 BaseColor; uniform float MixRatio; uniform samplerCube EnvMap; varying vec3 ReflectDir; varying float LightIntensity; 2 | void main() { // Look up environment map value in cube map vec3 envColor = vec3(textureCube(EnvMap, ReflectDir)); // Add lighting to base color and mix vec3 base = LightIntensity * BaseColor; envColor = mix(envColor, base, MixRatio); 3 | gl_FragColor = vec4(envColor, 1.0); } -------------------------------------------------------------------------------- /Java/DomeTools/data/cubemapvert.glsl: -------------------------------------------------------------------------------- 1 | varying vec3 ReflectDir; varying float LightIntensity; uniform vec3 LightPos; 2 | void main() { gl_Position = ftransform(); vec3 normal = normalize(gl_NormalMatrix * gl_Normal); vec4 pos = gl_ModelViewMatrix * gl_Vertex; vec3 eyeDir = pos.xyz; ReflectDir = reflect(eyeDir, normal); LightIntensity = max(dot(normalize(LightPos - eyeDir), normal),0.0); } -------------------------------------------------------------------------------- /Java/DomeTools/lib/GLGraphics.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mphasize/FullDome/e8e270ca3a7c7e43b5714d9f8916ea09f8be246d/Java/DomeTools/lib/GLGraphics.jar -------------------------------------------------------------------------------- /Java/DomeTools/lib/core.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mphasize/FullDome/e8e270ca3a7c7e43b5714d9f8916ea09f8be246d/Java/DomeTools/lib/core.jar -------------------------------------------------------------------------------- /Java/DomeTools/lib/gluegen-rt.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mphasize/FullDome/e8e270ca3a7c7e43b5714d9f8916ea09f8be246d/Java/DomeTools/lib/gluegen-rt.jar -------------------------------------------------------------------------------- /Java/DomeTools/lib/jogl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mphasize/FullDome/e8e270ca3a7c7e43b5714d9f8916ea09f8be246d/Java/DomeTools/lib/jogl.jar -------------------------------------------------------------------------------- /Java/DomeTools/lib/opengl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mphasize/FullDome/e8e270ca3a7c7e43b5714d9f8916ea09f8be246d/Java/DomeTools/lib/opengl.jar -------------------------------------------------------------------------------- /Java/DomeTools/lib/oscP5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mphasize/FullDome/e8e270ca3a7c7e43b5714d9f8916ea09f8be246d/Java/DomeTools/lib/oscP5.jar -------------------------------------------------------------------------------- /Java/DomeTools/src/charts/Chart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package charts; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * 11 | * @author mphasize 12 | */ 13 | public interface Chart { 14 | 15 | public ArrayList getNodes(); 16 | 17 | public void setNodes(ArrayList nodes); 18 | 19 | public void draw(); 20 | 21 | public void addNode(Node node); 22 | 23 | public void setScale(float scale); 24 | 25 | public void setScale(float scaleV, float scaleH); 26 | } 27 | -------------------------------------------------------------------------------- /Java/DomeTools/src/charts/ChartDemo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package charts; 6 | 7 | import java.util.ArrayList; 8 | import processing.core.PApplet; 9 | import processing.core.PConstants; 10 | 11 | /** 12 | * 13 | * @author mphasize 14 | */ 15 | public class ChartDemo extends PApplet implements PConstants { 16 | 17 | private ArrayList nodes = new ArrayList(); 18 | private PieChart pie; 19 | private BarChart bars; 20 | 21 | /** 22 | * @param args the command line arguments 23 | */ 24 | public static void main(String[] args) { 25 | PApplet.main(new String[]{"charts.ChartDemo"}); 26 | } 27 | 28 | @Override 29 | public void setup() { 30 | size(800, 600, JAVA2D); 31 | smooth(); 32 | 33 | nodes.add(new Node(13, "Hunde")); 34 | nodes.add(new Node(24, "Katzen")); 35 | nodes.add(new Node(37, "Hühner")); 36 | nodes.add(new Node(51, "Schweine")); 37 | nodes.add(new Node(7, "Rinder")); 38 | 39 | pie = new PieChart(this.g); 40 | pie.setNodes(nodes); 41 | pie.setPosition(width/2, height/2); 42 | pie.setScale(200); 43 | pie.setColorHue(125); 44 | 45 | bars = new BarChart(this.g); 46 | bars.setNodes(nodes); 47 | bars.setPosition(width/2, height/2); 48 | bars.setScale(400, 200); 49 | bars.setColorHue(125); 50 | } 51 | 52 | @Override 53 | public void draw() { 54 | background(0); 55 | pie.draw(); 56 | this.noLoop(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Java/DomeTools/src/charts/ChartImp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package charts; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | * 11 | * @author mphasize 12 | */ 13 | public abstract class ChartImp implements Chart { 14 | 15 | ArrayList nodes = new ArrayList(); 16 | float[] percentages; 17 | float max = 0; 18 | float total = 0; 19 | boolean dirty = true; 20 | int color = 0; 21 | float scaleV = 100; 22 | float scaleH = 100; 23 | float posX = 100; 24 | float posY = 100; 25 | 26 | public void addNode(Node node) { 27 | nodes.add(node); 28 | if (node.getNumber() > max) { 29 | max = node.getNumber(); 30 | } 31 | } 32 | 33 | public ArrayList getNodes() { 34 | return nodes; 35 | } 36 | 37 | public void setNodes(ArrayList nodes) { 38 | this.nodes = nodes; 39 | this.dirty = true; 40 | } 41 | 42 | public void setScale(float scale) { 43 | this.scaleH = scale; 44 | this.scaleV = scale; 45 | } 46 | 47 | public void setScale(float scaleV, float scaleH) { 48 | this.scaleV = scaleV; 49 | this.scaleH = scaleH; 50 | } 51 | 52 | protected void calculatePercentages() { 53 | percentages = new float[nodes.size()]; 54 | total = 0; 55 | for (Node n : nodes) { 56 | total += n.getNumber(); 57 | } 58 | for (int i = 0; i < nodes.size(); i++) { 59 | percentages[i] = nodes.get(i).getNumber() / total; 60 | System.out.println(percentages[i]); 61 | } 62 | dirty = false; 63 | } 64 | 65 | public int getColorHue() { 66 | return color; 67 | } 68 | 69 | public void setColorHue(int color) { 70 | this.color = color; 71 | } 72 | 73 | public void setPosition(float x, float y) { 74 | this.posX = x; 75 | this.posY = y; 76 | } 77 | 78 | public float[] getPosition() { 79 | float[] ret = new float[2]; 80 | ret[0] = posX; 81 | ret[1] = posY; 82 | return ret; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Java/DomeTools/src/charts/Node.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package charts; 6 | 7 | /** 8 | * 9 | * @author mphasize 10 | */ 11 | public class Node { 12 | 13 | float number; 14 | String title; 15 | String description; 16 | 17 | public Node(float _number, String _title) { 18 | this(_number, _title, null); 19 | } 20 | 21 | 22 | public Node(float _number, String _title, String _description) { 23 | this.number = _number; 24 | if (_title != null) { 25 | this.title = _title; 26 | } else { 27 | this.title = ""; 28 | } 29 | if (_description != null) { 30 | this.description = _description; 31 | } else { 32 | this.description = ""; 33 | } 34 | } 35 | 36 | public String getDescription() { 37 | return description; 38 | } 39 | 40 | public void setDescription(String description) { 41 | this.description = description; 42 | } 43 | 44 | public float getNumber() { 45 | return number; 46 | } 47 | 48 | public void setNumber(float number) { 49 | this.number = number; 50 | } 51 | 52 | public String getTitle() { 53 | return title; 54 | } 55 | 56 | public void setTitle(String title) { 57 | this.title = title; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Java/DomeTools/src/charts/PieChart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package charts; 6 | 7 | import processing.core.PApplet; 8 | import processing.core.PConstants; 9 | import processing.core.PGraphics; 10 | 11 | /** 12 | * 13 | * @author mphasize 14 | */ 15 | public class PieChart extends ChartImp implements PConstants { 16 | 17 | PGraphics p5; 18 | 19 | public PieChart(PGraphics g) { 20 | p5 = g; 21 | } 22 | 23 | public void draw() { 24 | p5.pushMatrix(); 25 | p5.colorMode(HSB); 26 | p5.stroke(100, 0, 100); 27 | if (dirty) { 28 | this.calculatePercentages(); 29 | } 30 | float r = 0; 31 | p5.translate(posX, posY); 32 | p5.rotate(-HALF_PI); 33 | for (float p : percentages) { 34 | float nodearc = p * TWO_PI; 35 | p5.fill(this.color, 255, PApplet.map(p, 0, 1, 50, 255)); 36 | p5.arc(0, 0, scaleV, scaleH, r, r + nodearc); 37 | r += nodearc; 38 | } 39 | p5.colorMode(RGB); 40 | p5.popMatrix(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Java/DomeTools/src/dome/Dome.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adaption of totally awesome domemod v.022 BETA by Dimitar Ruszev, 2010 (dimitar.ruszev @ gmail.com) 3 | * @author mphasize 4 | */ 5 | package dome; 6 | 7 | import domeapp.P5; 8 | import processing.core.PConstants; 9 | import processing.core.PImage; 10 | import processing.core.PVector; 11 | 12 | /** 13 | * Adaption of totally awesome domemod v.022 BETA by Dimitar Ruszev, 2010 (dimitar.ruszev @ gmail.com) 14 | * @author mphasize 15 | */ 16 | 17 | public class Dome implements PConstants { 18 | /* Projection Constants */ 19 | 20 | public static final int AUTOMATIC = 0; 21 | public static final int DOMEMASTER = 1; 22 | public static final int PANORAMA_360 = 2; 23 | public static final int PANORAMA_180 = 3; 24 | /* Image for projection */ 25 | private PImage texture = null; 26 | private int sourceProjection = AUTOMATIC; 27 | 28 | /* Draw Options */ 29 | private boolean drawGrid = false; 30 | private boolean drawMeshes = false; 31 | private boolean drawPlane = false; 32 | private boolean drawRays = false; 33 | int mCount = 41; 34 | int lCount = 21; 35 | /* Internal Mathematics */ 36 | private PVector vp1, vp2, vp3, vp4, p0; 37 | private PVector[][][] v; 38 | private float mu, la; 39 | private float k11, k12, k21, k22; 40 | protected float tr1, tr2; 41 | private float radius = 400f; 42 | private float distance = 520f; 43 | private float minc, linc, lstep, mstep; 44 | private float phi = PI / (float) mCount; 45 | // private float theta = PI / (float) mCount; 46 | private float a = radius * P5.sin(phi) * 2; 47 | 48 | public void draw() { 49 | if (texture != null) { 50 | P5.call.rectMode(CORNERS); 51 | 52 | la = 0; 53 | int l = 0; 54 | int m; 55 | int lp; 56 | int mp; 57 | k11 = P5.sq(P5.cos(tr1)); 58 | k12 = P5.sq(P5.sin(tr1)); 59 | k21 = P5.sq(P5.cos(tr2)); 60 | k22 = P5.sq(P5.sin(tr2)); 61 | 62 | while (la < HALF_PI) { 63 | m = 0; 64 | mu = -HALF_PI; 65 | while (mu + HALF_PI <= TWO_PI) { 66 | 67 | lp = (l + 1); 68 | mp = (m + 1); 69 | 70 | 71 | vp1.set(k21 * (k11 * v[0][m][l].x + k12 * v[1][m][l].x) + k22 * (k11 * v[2][m][l].x + k12 * v[3][m][l].x), 72 | k21 * (k11 * v[0][m][l].y + k12 * v[1][m][l].y) + k22 * (k11 * v[2][m][l].y + k12 * v[3][m][l].y), 73 | k21 * (k11 * v[0][m][l].z + k12 * v[1][m][l].z) + k22 * (k11 * v[2][m][l].z + k12 * v[3][m][l].z)); 74 | 75 | vp2.set(k21 * (k11 * v[0][m][lp].x + k12 * v[1][m][lp].x) + k22 * (k11 * v[2][m][lp].x + k12 * v[3][m][lp].x), 76 | k21 * (k11 * v[0][m][lp].y + k12 * v[1][m][lp].y) + k22 * (k11 * v[2][m][lp].y + k12 * v[3][m][lp].y), 77 | k21 * (k11 * v[0][m][lp].z + k12 * v[1][m][lp].z) + k22 * (k11 * v[2][m][lp].z + k12 * v[3][m][lp].z)); 78 | 79 | vp3.set(k21 * (k11 * v[0][mp][lp].x + k12 * v[1][mp][lp].x) + k22 * (k11 * v[2][mp][lp].x + k12 * v[3][mp][lp].x), 80 | k21 * (k11 * v[0][mp][lp].y + k12 * v[1][mp][lp].y) + k22 * (k11 * v[2][mp][lp].y + k12 * v[3][mp][lp].y), 81 | k21 * (k11 * v[0][mp][lp].z + k12 * v[1][mp][lp].z) + k22 * (k11 * v[2][mp][lp].z + k12 * v[3][mp][lp].z)); 82 | 83 | vp4.set(k21 * (k11 * v[0][mp][l].x + k12 * v[1][mp][l].x) + k22 * (k11 * v[2][mp][l].x + k12 * v[3][mp][l].x), 84 | k21 * (k11 * v[0][mp][l].y + k12 * v[1][mp][l].y) + k22 * (k11 * v[2][mp][l].y + k12 * v[3][mp][l].y), 85 | k21 * (k11 * v[0][mp][l].z + k12 * v[1][mp][l].z) + k22 * (k11 * v[2][mp][l].z + k12 * v[3][mp][l].z)); 86 | 87 | 88 | if (drawMeshes) { 89 | 90 | P5.call.beginShape(POINTS); 91 | P5.call.strokeWeight(3); 92 | P5.call.stroke(127, 127, 0); 93 | P5.call.vertex(v[0][m][l].x, v[0][m][l].y, v[0][m][l].z); 94 | P5.call.stroke(63, 127, 0); 95 | P5.call.vertex(v[1][m][l].x, v[1][m][l].y, v[1][m][l].z); 96 | P5.call.stroke(0, 127, 63); 97 | P5.call.vertex(v[2][m][l].x, v[2][m][l].y, v[2][m][l].z); 98 | P5.call.stroke(0, 127, 127); 99 | P5.call.vertex(v[3][m][l].x, v[3][m][l].y, v[3][m][l].z); 100 | P5.call.endShape(); 101 | P5.call.strokeWeight(2); 102 | } 103 | 104 | P5.call.stroke(255, 255, 96, 127); 105 | 106 | //////////////// draws the dome 107 | 108 | if (!drawGrid) { 109 | P5.call.noStroke(); 110 | } 111 | 112 | float s1 = P5.sin(linc * l) * (radius + distance) / (P5.cos(linc * l) + distance / radius); 113 | float s2 = P5.sin(linc * (l + 1)) * (radius + distance) / (P5.cos(linc * (l + 1)) + distance / radius); 114 | float t1 = P5.map(s1, 0, ((radius + distance) * radius / distance), 0, (texture.height / 2f)); 115 | float t2 = P5.map(s2, 0, ((radius + distance) * radius / distance), 0, (texture.height / 2f)); 116 | 117 | if (sourceProjection == DOMEMASTER) { 118 | P5.call.beginShape(QUADS); 119 | P5.call.texture(texture); 120 | P5.call.tint(255, 192); 121 | P5.call.vertex(vp1.x, vp1.y, vp1.z, texture.width / 2f + P5.cos(mu) * t1, texture.height / 2f + P5.sin(mu) * t1); 122 | P5.call.vertex(vp2.x, vp2.y, vp2.z, texture.width / 2f + P5.cos(mu) * t2, texture.height / 2f + P5.sin(mu) * t2); 123 | P5.call.vertex(vp3.x, vp3.y, vp3.z, texture.width / 2f + P5.cos(mu + minc) * t2, texture.height / 2f + P5.sin(mu + minc) * t2); 124 | P5.call.vertex(vp4.x, vp4.y, vp4.z, texture.width / 2f + P5.cos(mu + minc) * t1, texture.height / 2f + P5.sin(mu + minc) * t1); 125 | P5.call.endShape(CLOSE); 126 | } else { 127 | P5.call.beginShape(QUADS); 128 | P5.call.texture(texture); 129 | P5.call.tint(255, 192); 130 | P5.call.vertex(vp1.x, vp1.y, vp1.z, mstep * m, lstep * l); 131 | P5.call.vertex(vp2.x, vp2.y, vp2.z, mstep * m, lstep * (l + 1)); 132 | P5.call.vertex(vp3.x, vp3.y, vp3.z, mstep * (m + 1), lstep * (l + 1)); 133 | P5.call.vertex(vp4.x, vp4.y, vp4.z, mstep * (m + 1), lstep * l); 134 | P5.call.endShape(CLOSE); 135 | } 136 | float s = 0; 137 | //////////////// draws the domemaster in plane 138 | if (drawPlane) { 139 | if (sourceProjection == DOMEMASTER) { 140 | P5.call.beginShape(QUADS); 141 | P5.call.texture(texture); 142 | P5.call.tint(255, 192); 143 | P5.call.vertex(s + P5.cos(mu) * s1, radius, s + P5.sin(mu) * s1 + radius, texture.width / 2f + P5.cos(mu) * t1, texture.height / 2f + P5.sin(mu) * t1); 144 | P5.call.vertex(s + P5.cos(mu) * s2, radius, s + P5.sin(mu) * s2 + radius, texture.width / 2f + P5.cos(mu) * t2, texture.height / 2f + P5.sin(mu) * t2); 145 | P5.call.vertex(s + P5.cos(mu + minc) * s2, radius, s + P5.sin(mu + minc) * s2 + radius, texture.width / 2f + P5.cos(mu + minc) * t2, texture.height / 2f + P5.sin(mu + minc) * t2); 146 | P5.call.vertex(s + P5.cos(mu + minc) * s1, radius, s + P5.sin(mu + minc) * s1 + radius, texture.width / 2f + P5.cos(mu + minc) * t1, texture.height / 2f + P5.sin(mu + minc) * t1); 147 | P5.call.endShape(CLOSE); 148 | } else { 149 | P5.call.beginShape(QUADS); 150 | P5.call.texture(texture); 151 | P5.call.tint(255, 192); 152 | P5.call.vertex(s + P5.cos(mu) * s1, radius, s + P5.sin(mu) * s1 + radius, mstep * m, lstep * l); 153 | P5.call.vertex(s + P5.cos(mu) * s2, radius, s + P5.sin(mu) * s2 + radius, mstep * m, lstep * (l + 1)); 154 | P5.call.vertex(s + P5.cos(mu + minc) * s2, radius, s + P5.sin(mu + minc) * s2 + radius, mstep * (m + 1), lstep * (l + 1)); 155 | P5.call.vertex(s + P5.cos(mu + minc) * s1, radius, s + P5.sin(mu + minc) * s1 + radius, mstep * (m + 1), lstep * l); 156 | P5.call.endShape(CLOSE); 157 | } 158 | } 159 | 160 | 161 | //////////////// draws the projection rays 162 | //stroke(255,63); 163 | if (drawRays) { 164 | int c = texture.get((int) (texture.width / 2f + P5.cos(mu) * t2), (int) (texture.height / 2f + P5.sin(mu) * t2)); 165 | P5.call.stroke(c, 127); 166 | P5.call.beginShape(LINES); 167 | if (drawPlane) { 168 | P5.call.vertex(s + P5.cos(mu) * s2, radius, s + P5.sin(mu) * s2 + radius); 169 | } else { 170 | P5.call.vertex(vp2.x, vp2.y, vp2.z); 171 | } 172 | P5.call.vertex(p0.x, p0.y, p0.z); 173 | P5.call.endShape(); 174 | } 175 | 176 | 177 | mu += minc; 178 | m++; 179 | } 180 | la += linc; 181 | l++; 182 | } 183 | } 184 | } 185 | 186 | private void setVectors() { 187 | vp1 = new PVector(); 188 | vp2 = new PVector(); 189 | vp3 = new PVector(); 190 | vp4 = new PVector(); 191 | 192 | 193 | v = new PVector[4][mCount][lCount]; 194 | minc = 1f / (float) (mCount - 1f) * TWO_PI; 195 | linc = 1f / (float) (lCount - 1f) * PI; 196 | la = 0; 197 | int l = 0; 198 | int m; 199 | 200 | while (la < PI + linc) { 201 | m = 0; 202 | mu = -HALF_PI; 203 | while (mu + HALF_PI < TWO_PI + minc) { 204 | 205 | v[0][m][l] = new PVector(P5.sin(la) * P5.cos(mu) * radius, P5.cos(la) * radius, (P5.sin(la) * P5.sin(mu) + 1) * radius); 206 | v[1][m][l] = new PVector(P5.cos(mu) * radius, -l * a + lCount / 2f * a, (P5.sin(mu) + 1) * radius); 207 | v[2][m][l] = new PVector(mCount * a / 2f - m * a, P5.cos(la) * radius, 2 * radius); 208 | v[3][m][l] = new PVector(mCount * a / 2f - m * a, -l * a + lCount / 2f * a, 2 * radius); 209 | mu += minc; 210 | m++; 211 | } 212 | la += linc; 213 | l++; 214 | } 215 | } 216 | 217 | private void initTexture() { 218 | if (sourceProjection == AUTOMATIC) { 219 | if (P5.abs(texture.width - texture.height) > 10f) { 220 | if (texture.width / (float) texture.height < 3) { 221 | sourceProjection = Dome.PANORAMA_360; 222 | } else { 223 | sourceProjection = Dome.PANORAMA_180; 224 | } 225 | 226 | } else { 227 | sourceProjection = Dome.DOMEMASTER; 228 | } 229 | } 230 | setVectors(); 231 | minc = 1f / (float) (mCount - 1f) * TWO_PI; 232 | linc = 1f / (float) (lCount - 1f) * PI; 233 | if (sourceProjection != Dome.PANORAMA_360) { 234 | lstep = texture.height / (float) (lCount - 1f) * 2f; 235 | } else { 236 | lstep = texture.height / (float) (lCount - 1f); 237 | } 238 | mstep = texture.width / (float) (mCount - 1f); 239 | } 240 | 241 | public float getDistance() { 242 | return distance; 243 | } 244 | 245 | public void setDistance(float distance) { 246 | this.distance = distance > 0 ? distance : 0; 247 | p0.set(0, -this.distance, radius); 248 | } 249 | 250 | public int getSourceProjection() { 251 | return sourceProjection; 252 | } 253 | 254 | public void setSourceProjection(int sourceProjection) { 255 | this.sourceProjection = sourceProjection; 256 | } 257 | 258 | public PImage getTexture() { 259 | return texture; 260 | } 261 | 262 | public void setTexture(PImage texture) { 263 | this.sourceProjection = AUTOMATIC; 264 | this.texture = texture; 265 | } 266 | 267 | public void setTexture(PImage texture, int projection) { 268 | this.sourceProjection = projection; 269 | this.texture = texture; 270 | this.initTexture(); 271 | } 272 | 273 | public float getRadius() { 274 | return radius; 275 | } 276 | 277 | public void setRadius(float radius) { 278 | this.radius = radius; 279 | } 280 | 281 | public void toggleGrid() { 282 | this.drawGrid = !this.drawGrid; 283 | } 284 | } 285 | -------------------------------------------------------------------------------- /Java/DomeTools/src/dome/Integrator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package dome; 6 | 7 | /** 8 | * 9 | * @author mphasize 10 | */ 11 | public class Integrator { 12 | 13 | final float DAMPING = 0.5f; 14 | final float ATTRACTION = 0.2f; 15 | float value; 16 | float vel; 17 | float accel; 18 | float force; 19 | float mass = 1; 20 | float damping = DAMPING; 21 | float attraction = ATTRACTION; 22 | boolean targeting; 23 | float target; 24 | 25 | public Integrator() { 26 | } 27 | 28 | public Integrator(float value) { 29 | this.value = value; 30 | } 31 | 32 | public Integrator(float value, float damping, float attraction) { 33 | this.value = value; 34 | this.damping = damping; 35 | this.attraction = attraction; 36 | } 37 | 38 | public void set(float v) { 39 | value = v; 40 | } 41 | 42 | public void update() { 43 | if (targeting) { 44 | force += attraction * (target - value); 45 | } 46 | 47 | accel = force / mass; 48 | vel = (vel + accel) * damping; 49 | value += vel; 50 | 51 | force = 0; 52 | } 53 | 54 | public void target(float t) { 55 | targeting = true; 56 | target = t; 57 | } 58 | 59 | public void noTarget() { 60 | targeting = false; 61 | } 62 | 63 | public float getValue() { 64 | return value; 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Java/DomeTools/src/dome/InteractiveDome.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package dome; 6 | 7 | import domeapp.P5; 8 | import processing.core.PVector; 9 | 10 | /** 11 | * 12 | * @author mphasize 13 | */ 14 | public class InteractiveDome extends Dome { 15 | /* Manipulation constants */ 16 | 17 | public static final int ROTATION = 0; 18 | public static final int PROJECTION = 1; 19 | private PVector position; 20 | private float radius = 400f; 21 | private Integrator phixi, phiyi, tr1i, tr2i; 22 | private float phix = 0, phiy = 0, phiz = 0, lastphix, lastphiy; 23 | private float lasttr1, lasttr2; 24 | 25 | public InteractiveDome() { 26 | position = new PVector(P5.call.width / 2, P5.call.height / 2, -radius * 1.5f); 27 | phixi = new Integrator(0f, .5f, .1f); 28 | phiyi = new Integrator(0f, .5f, .1f); 29 | tr1i = new Integrator(0f, .5f, .1f); 30 | tr2i = new Integrator(0f, .5f, .1f); 31 | } 32 | 33 | @Override 34 | public void draw() { 35 | P5.call.pushMatrix(); 36 | P5.call.translate(position.x, position.y, position.z); 37 | P5.call.rotateX(phix); 38 | P5.call.rotateY(phiy); 39 | P5.call.rotateZ(phiz); 40 | P5.call.translate(0, 0, -radius); 41 | super.draw(); 42 | P5.call.popMatrix(); 43 | } 44 | 45 | public void resetPosition() { 46 | position.set(P5.call.width / 2, P5.call.height / 2, -radius * 1.5f); 47 | phiz = 0f; 48 | this.setDistance(520f); 49 | } 50 | 51 | public void handleMouseRotation(float mouseX, float mouseY) { 52 | lastphix = phix; 53 | lastphiy = phiy; 54 | phix = P5.map(P5.constrain(mouseY, 0, P5.call.height), 0, P5.call.height, TWO_PI, 0); 55 | phiy = P5.map(P5.constrain(mouseX, 0, P5.call.width), 0, P5.call.width, 0, TWO_PI); 56 | phixi.set(lastphix); 57 | phiyi.set(lastphiy); 58 | phixi.target(phix); 59 | phiyi.target(phiy); 60 | phixi.update(); 61 | phix = phixi.getValue(); 62 | phiyi.update(); 63 | phiy = phiyi.getValue(); 64 | tr1i.update(); 65 | tr2i.update(); 66 | tr1 = tr1i.getValue(); 67 | tr2 = tr2i.getValue(); 68 | } 69 | 70 | public void handleMouseProjection(float mouseX, float mouseY) { 71 | lasttr1 = tr1; 72 | lasttr2 = tr2; 73 | tr1 = P5.map(P5.constrain(mouseY, 0, P5.call.height), 0, P5.call.height, 0, HALF_PI); 74 | tr2 = P5.map(P5.constrain(mouseX, 0, P5.call.width), 0, P5.call.width, 0, HALF_PI); 75 | tr1i.set(lasttr1); 76 | tr2i.set(lasttr2); 77 | tr1i.target(tr1); 78 | tr2i.target(tr2); 79 | tr1i.update(); 80 | tr1 = tr1i.getValue(); 81 | tr2i.update(); 82 | tr2 = tr2i.getValue(); 83 | phixi.update(); 84 | phix = phixi.getValue(); 85 | phiyi.update(); 86 | phiy = phiyi.getValue(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Java/DomeTools/src/domeExamples/DomeSketch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package domeExamples; 6 | 7 | import processing.core.PConstants; 8 | import processing.core.PGraphics; 9 | 10 | /** 11 | * 12 | * @author mphasize 13 | */ 14 | public interface DomeSketch extends PConstants { 15 | 16 | public void init(PGraphics g); 17 | 18 | public void setup(); 19 | 20 | public void draw(); 21 | } 22 | -------------------------------------------------------------------------------- /Java/DomeTools/src/domeExamples/DomeSketchImp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package domeExamples; 6 | 7 | import processing.core.PGraphics; 8 | 9 | /** 10 | * 11 | * @author mphasize 12 | */ 13 | abstract public class DomeSketchImp implements DomeSketch { 14 | 15 | PGraphics p5; 16 | 17 | public DomeSketchImp(PGraphics g) { 18 | this.init(g); 19 | } 20 | 21 | public void init(PGraphics g) { 22 | p5 = g; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Java/DomeTools/src/domeExamples/Example1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package domeExamples; 6 | 7 | import charts.Node; 8 | import charts.PieChart; 9 | import processing.core.PGraphics; 10 | 11 | /** 12 | * 13 | * @author mphasize 14 | */ 15 | public class Example1 extends DomeSketchImp { 16 | 17 | private PieChart pie; 18 | 19 | public Example1(PGraphics g) { 20 | super(g); 21 | } 22 | 23 | public void setup() { 24 | pie = new PieChart(p5); 25 | pie.addNode(new Node(15, "Sketches")); 26 | pie.addNode(new Node(77, "Applications")); 27 | 28 | pie.setPosition(p5.width / 2, p5.height / 2); 29 | pie.setScale(200); 30 | pie.setColorHue(125); 31 | } 32 | 33 | public void draw() { 34 | p5.beginDraw(); 35 | p5.background(0); 36 | pie.draw(); 37 | p5.endDraw(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Java/DomeTools/src/domeExamples/Example2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package domeExamples; 6 | 7 | import processing.core.PGraphics; 8 | 9 | /** 10 | * 11 | * @author mphasize 12 | */ 13 | public class Example2 extends DomeSketchImp { 14 | 15 | private float runner = 0; 16 | private float x = 0; 17 | private float size = 20; 18 | 19 | public Example2(PGraphics g) { 20 | super(g); 21 | } 22 | 23 | public void setup() { 24 | } 25 | 26 | public void draw() { 27 | p5.beginDraw(); 28 | p5.background(0); 29 | runner += 0.1f; 30 | x = x > p5.width ? -size : x + 1; 31 | p5.noStroke(); 32 | p5.fill(255); 33 | p5.rect(x, p5.height - size * 2, size, size); 34 | p5.noFill(); 35 | p5.stroke(255); 36 | p5.ellipse(p5.width / 2, p5.height / 2, x, x); 37 | p5.endDraw(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Java/DomeTools/src/domeapp/DomeModOriginal.java: -------------------------------------------------------------------------------- 1 | package domeapp; 2 | 3 | /** 4 | * Adaption of totally awesome domemod v.022 BETA by Dimitar Ruszev, 2010 (dimitar.ruszev @ gmail.com) 5 | * @author mphasize 6 | */ 7 | import processing.core.*; 8 | import java.io.*; 9 | import dome.*; 10 | 11 | public class DomeModOriginal extends PApplet { 12 | PVector vp1, vp2, vp3, vp4, p0; 13 | PVector[][][] v; 14 | Integrator phixi, phiyi, tr1i, tr2i; 15 | float phiz = 0f; 16 | float phizInc = TWO_PI / 18f; 17 | String guiText = "domemod v.021 BETA - Dimitar Ruszev, 2010 (dimitar.ruszev @ gmail.com) \n\ncontrols:\n'i' = turn this help screen on/off\n\nmove mouse = rotate along x,y-axis [in roation mode];\nwarp around 4 different meshes \n- (hemisphere, cylinder and two planes) [in warp mode];\nleft click = change between these modes\n\n'w' = up; 's' = down; 'a' = left; 'd' = right;\n'g','z' = zooom in/out; 'h','j' = rotate along z-axis;\n'r' = reset transformations;\n\n'p','l' = move the projection point;\n'm','n','b','v' = turn meshes / grid / master plane / rays on/off;\n\n'q' turn status display on/off\n\n'e' show source image\n\n'x' quit program\n\nFor custom images, please put the material (*.jpg) in folder 'data'.\n(accepts both domemasters and panoramic images)\npress SPACE to cycle through"; 18 | String[] images; 19 | int currentImage = 0; 20 | PImage tex; 21 | PImage[] timg; 22 | float tinc_x, tinc_y; 23 | boolean showSource = false; 24 | int mCount = 41; 25 | int lCount = 21; 26 | int m, l; 27 | float minc, linc, lstep, mstep; 28 | float laf, laf_1; 29 | float mu, la; 30 | float rad = 400f; 31 | float dis = 520f; 32 | float r_d = rad / dis; 33 | float disstep = 20f; 34 | float k11, k12, k21, k22; 35 | //float surf_n, surf_c; 36 | float axesDia = 100f; 37 | private float tr1, tr2, lasttr1, lasttr2; 38 | private float phix, phiy, lastphix, lastphiy; 39 | private float xPos, yPos, zPos, xinc, yinc, zinc; 40 | private static final int ROTATE = 0; 41 | private static final int PROJECT_A = 1; 42 | private int inputType = ROTATE; 43 | private static final int INPUTCOUNT = 2; 44 | private float phi = PI / (float) mCount; 45 | private float theta = PI / (float) mCount; 46 | private float a = rad * sin(phi) * 2; 47 | private float h = rad * sin(theta) * 2; 48 | private float a_sq = sq(a); 49 | //color c1, c2, cc; 50 | boolean drawMeshes = false; 51 | boolean drawRays = true; 52 | boolean drawGrid = true; 53 | boolean drawPlane = true; 54 | boolean displayGUI = true; 55 | boolean displayInfos = true; 56 | boolean dmInput = true; 57 | boolean fullInput = false; 58 | public final float MARGIN = 40; 59 | float[] surfs = new float[lCount]; 60 | String texPath; 61 | PFont font, font2, font3; 62 | float leading = 14f; 63 | String s; 64 | File data_content; 65 | 66 | @Override 67 | public void setup() { 68 | P5.call = this; 69 | size(800, 600, OPENGL); 70 | phix = 0; 71 | phiy = 0; 72 | tr1 = 0; 73 | rectMode(CORNERS); 74 | phixi = new Integrator(0f, .5f, .1f); 75 | phiyi = new Integrator(0f, .5f, .1f); 76 | tr1i = new Integrator(0f, .5f, .1f); 77 | tr2i = new Integrator(0f, .5f, .1f); 78 | zinc = -50; 79 | zPos = -rad * 1.5f; 80 | xinc = 50; 81 | xPos = width / 2f; 82 | yinc = 50; 83 | yPos = height / 2f; 84 | 85 | 86 | p0 = new PVector(0, -dis, rad); 87 | 88 | //texPath = dataPath("") + "\\..\\input"; 89 | //texPath = dataPath("") + "\\..\\input\\"; 90 | texPath = dataPath(""); 91 | data_content = new File(texPath); 92 | String[] file_content = data_content.list(); 93 | for (int i = 0; i < file_content.length; i++) { 94 | String s = file_content[i]; 95 | if (s.substring((s.length() - 3), s.length()).equals("jpg") || s.substring((s.length() - 3), s.length()).equals("png")) { 96 | if (images == null) { 97 | images = new String[1]; 98 | images[0] = s; 99 | } else { 100 | images = append(images, s); 101 | } 102 | } 103 | } 104 | 105 | 106 | if (images != null) { // will be null if inaccessible 107 | println(images); 108 | timg = new PImage[images.length]; 109 | for (int i = 0; i < images.length; i++) { 110 | timg[i] = loadImage(texPath + images[i]); 111 | } 112 | } else { 113 | println("No textures found!"); 114 | exit(); 115 | } 116 | 117 | initTex(timg[0]); 118 | font = loadFont("Consolas-18.vlw"); 119 | font2 = loadFont("Consolas-14.vlw"); 120 | font3 = loadFont("Consolas-10.vlw"); 121 | textFont(font); 122 | ellipseMode(CENTER); 123 | } 124 | 125 | @Override 126 | public void draw() { 127 | background(13); 128 | // noFill(); 129 | // stroke(255); 130 | // rect(MARGIN,MARGIN,width-MARGIN,height-MARGIN); 131 | //stroke(255,0,0); 132 | noStroke(); 133 | fill(255, 63); 134 | rect(0, 0, width, MARGIN); 135 | rect(0, height - MARGIN, width, height); 136 | rect(0, MARGIN, MARGIN, height - MARGIN); 137 | rect(width - MARGIN, MARGIN, width, height - MARGIN); 138 | noFill(); 139 | 140 | handleMouseInput(); 141 | 142 | pushMatrix(); 143 | translate(xPos, yPos, zPos); 144 | rotateX(phix); 145 | rotateY(phiy); 146 | rotateZ(phiz); 147 | translate(0, 0, -rad); 148 | 149 | drawProjection1(); 150 | popMatrix(); 151 | pushMatrix(); 152 | displayAxes(); 153 | popMatrix(); 154 | if (displayGUI) { 155 | displayGUI(); 156 | } 157 | if (displayInfos) { 158 | displayInfos(); 159 | } 160 | if (showSource) { 161 | image(tex, width * 3 / 4f, MARGIN, width / 4f - MARGIN, tex.height * (width / 4f - MARGIN) / tex.width); 162 | } 163 | 164 | } 165 | 166 | public void drawProjection1() { 167 | 168 | la = 0; 169 | int l = 0; 170 | int m; 171 | int lp; 172 | int mp; 173 | k11 = sq(cos(tr1)); 174 | k12 = sq(sin(tr1)); 175 | k21 = sq(cos(tr2)); 176 | k22 = sq(sin(tr2)); 177 | 178 | while (la < HALF_PI) { 179 | m = 0; 180 | mu = -HALF_PI; 181 | while (mu + HALF_PI <= TWO_PI) { 182 | 183 | lp = (l + 1); 184 | mp = (m + 1); 185 | 186 | 187 | vp1.set(k21 * (k11 * v[0][m][l].x + k12 * v[1][m][l].x) + k22 * (k11 * v[2][m][l].x + k12 * v[3][m][l].x), 188 | k21 * (k11 * v[0][m][l].y + k12 * v[1][m][l].y) + k22 * (k11 * v[2][m][l].y + k12 * v[3][m][l].y), 189 | k21 * (k11 * v[0][m][l].z + k12 * v[1][m][l].z) + k22 * (k11 * v[2][m][l].z + k12 * v[3][m][l].z)); 190 | 191 | vp2.set(k21 * (k11 * v[0][m][lp].x + k12 * v[1][m][lp].x) + k22 * (k11 * v[2][m][lp].x + k12 * v[3][m][lp].x), 192 | k21 * (k11 * v[0][m][lp].y + k12 * v[1][m][lp].y) + k22 * (k11 * v[2][m][lp].y + k12 * v[3][m][lp].y), 193 | k21 * (k11 * v[0][m][lp].z + k12 * v[1][m][lp].z) + k22 * (k11 * v[2][m][lp].z + k12 * v[3][m][lp].z)); 194 | 195 | vp3.set(k21 * (k11 * v[0][mp][lp].x + k12 * v[1][mp][lp].x) + k22 * (k11 * v[2][mp][lp].x + k12 * v[3][mp][lp].x), 196 | k21 * (k11 * v[0][mp][lp].y + k12 * v[1][mp][lp].y) + k22 * (k11 * v[2][mp][lp].y + k12 * v[3][mp][lp].y), 197 | k21 * (k11 * v[0][mp][lp].z + k12 * v[1][mp][lp].z) + k22 * (k11 * v[2][mp][lp].z + k12 * v[3][mp][lp].z)); 198 | 199 | vp4.set(k21 * (k11 * v[0][mp][l].x + k12 * v[1][mp][l].x) + k22 * (k11 * v[2][mp][l].x + k12 * v[3][mp][l].x), 200 | k21 * (k11 * v[0][mp][l].y + k12 * v[1][mp][l].y) + k22 * (k11 * v[2][mp][l].y + k12 * v[3][mp][l].y), 201 | k21 * (k11 * v[0][mp][l].z + k12 * v[1][mp][l].z) + k22 * (k11 * v[2][mp][l].z + k12 * v[3][mp][l].z)); 202 | 203 | 204 | if (drawMeshes) { 205 | 206 | beginShape(POINTS); 207 | strokeWeight(3); 208 | stroke(127, 127, 0); 209 | vertex(v[0][m][l].x, v[0][m][l].y, v[0][m][l].z); 210 | stroke(63, 127, 0); 211 | vertex(v[1][m][l].x, v[1][m][l].y, v[1][m][l].z); 212 | stroke(0, 127, 63); 213 | vertex(v[2][m][l].x, v[2][m][l].y, v[2][m][l].z); 214 | stroke(0, 127, 127); 215 | vertex(v[3][m][l].x, v[3][m][l].y, v[3][m][l].z); 216 | endShape(); 217 | strokeWeight(2); 218 | } 219 | 220 | stroke(255, 255, 96, 127); 221 | 222 | //////////////// draws the dome 223 | 224 | if (!drawGrid) { 225 | noStroke(); 226 | } 227 | float s1 = sin(linc * l) * (rad + dis) / (cos(linc * l) + dis / rad); 228 | float s2 = sin(linc * (l + 1)) * (rad + dis) / (cos(linc * (l + 1)) + dis / rad); 229 | float t1 = map(s1, 0, ((rad + dis) * rad / dis), 0, (tex.height / 2f)); 230 | float t2 = map(s2, 0, ((rad + dis) * rad / dis), 0, (tex.height / 2f)); 231 | 232 | if (dmInput) { 233 | beginShape(QUADS); 234 | texture(tex); 235 | tint(255, 192); 236 | vertex(vp1.x, vp1.y, vp1.z, tex.width / 2f + cos(mu) * t1, tex.height / 2f + sin(mu) * t1); 237 | vertex(vp2.x, vp2.y, vp2.z, tex.width / 2f + cos(mu) * t2, tex.height / 2f + sin(mu) * t2); 238 | vertex(vp3.x, vp3.y, vp3.z, tex.width / 2f + cos(mu + minc) * t2, tex.height / 2f + sin(mu + minc) * t2); 239 | vertex(vp4.x, vp4.y, vp4.z, tex.width / 2f + cos(mu + minc) * t1, tex.height / 2f + sin(mu + minc) * t1); 240 | endShape(CLOSE); 241 | } else { 242 | 243 | beginShape(QUADS); 244 | texture(tex); 245 | tint(255, 192); 246 | vertex(vp1.x, vp1.y, vp1.z, mstep * m, lstep * l); 247 | vertex(vp2.x, vp2.y, vp2.z, mstep * m, lstep * (l + 1)); 248 | vertex(vp3.x, vp3.y, vp3.z, mstep * (m + 1), lstep * (l + 1)); 249 | vertex(vp4.x, vp4.y, vp4.z, mstep * (m + 1), lstep * l); 250 | endShape(CLOSE); 251 | 252 | 253 | 254 | } 255 | float s = 0; 256 | //////////////// draws the domemaster in plane 257 | if (drawPlane) { 258 | if (dmInput) { 259 | beginShape(QUADS); 260 | texture(tex); 261 | tint(255, 192); 262 | vertex(s + cos(mu) * s1, rad, s + sin(mu) * s1 + rad, tex.width / 2f + cos(mu) * t1, tex.height / 2f + sin(mu) * t1); 263 | vertex(s + cos(mu) * s2, rad, s + sin(mu) * s2 + rad, tex.width / 2f + cos(mu) * t2, tex.height / 2f + sin(mu) * t2); 264 | vertex(s + cos(mu + minc) * s2, rad, s + sin(mu + minc) * s2 + rad, tex.width / 2f + cos(mu + minc) * t2, tex.height / 2f + sin(mu + minc) * t2); 265 | vertex(s + cos(mu + minc) * s1, rad, s + sin(mu + minc) * s1 + rad, tex.width / 2f + cos(mu + minc) * t1, tex.height / 2f + sin(mu + minc) * t1); 266 | endShape(CLOSE); 267 | } else { 268 | beginShape(QUADS); 269 | texture(tex); 270 | tint(255, 192); 271 | vertex(s + cos(mu) * s1, rad, s + sin(mu) * s1 + rad, mstep * m, lstep * l); 272 | vertex(s + cos(mu) * s2, rad, s + sin(mu) * s2 + rad, mstep * m, lstep * (l + 1)); 273 | vertex(s + cos(mu + minc) * s2, rad, s + sin(mu + minc) * s2 + rad, mstep * (m + 1), lstep * (l + 1)); 274 | vertex(s + cos(mu + minc) * s1, rad, s + sin(mu + minc) * s1 + rad, mstep * (m + 1), lstep * l); 275 | endShape(CLOSE); 276 | } 277 | } 278 | 279 | 280 | //////////////// draws the projection rays 281 | //stroke(255,63); 282 | if (drawRays) { 283 | int c = tex.get((int) (tex.width / 2f + cos(mu) * t2), (int) (tex.height / 2f + sin(mu) * t2)); 284 | stroke(c, 127); 285 | beginShape(LINES); 286 | if (drawPlane) { 287 | vertex(s + cos(mu) * s2, rad, s + sin(mu) * s2 + rad); 288 | } else { 289 | vertex(vp2.x, vp2.y, vp2.z); 290 | } 291 | vertex(p0.x, p0.y, p0.z); 292 | endShape(); 293 | } 294 | 295 | 296 | mu += minc; 297 | m++; 298 | } 299 | la += linc; 300 | l++; 301 | } 302 | 303 | } 304 | 305 | public void displayAxes() { 306 | 307 | translate(width - axesDia, height - axesDia, 0); 308 | textMode(MODEL); 309 | 310 | fill(255); 311 | 312 | rotateX(phix); 313 | text("y+", 3, axesDia / 2f - 3, 0); 314 | text("y-", 3, -axesDia / 2f + 8, 0); 315 | 316 | rotateY(phiy); 317 | 318 | text("z+", 3, 0, axesDia / 2f); 319 | text("z-", 3, 0, -axesDia / 2f); 320 | 321 | rotateZ(phiz); 322 | text("x+", axesDia / 2f - 18, -5, 0); 323 | text("x-", -axesDia / 2f - 3, -5, 0); 324 | 325 | stroke(255); 326 | beginShape(LINES); 327 | vertex(axesDia / 2f, 0, 0); 328 | vertex(-axesDia / 2f, 0, 0); 329 | endShape(); 330 | beginShape(LINES); 331 | vertex(0, axesDia / 2f, 0); 332 | vertex(0, -axesDia / 2f, 0); 333 | endShape(); 334 | beginShape(LINES); 335 | vertex(0, 0, axesDia / 2f); 336 | vertex(0, 0, -axesDia / 2f); 337 | endShape(); 338 | } 339 | 340 | public void displayGUI() { 341 | fill(191); 342 | textFont(font2); 343 | text(guiText, MARGIN + 2, MARGIN - 5f); 344 | } 345 | 346 | public void displayInfos() { 347 | fill(255); 348 | textFont(font3); 349 | int lines = 7; 350 | s = "pos.x: " + xPos + ". pos.y: " + yPos + ". pos.z: " + zPos + '.'; 351 | text(s, MARGIN + 2, height - MARGIN + 7 - lines * leading); 352 | lines--; 353 | s = "rot.x: " + nf(degrees(phix), 3, 2) + "\u00b0 rot.y: " + nf(degrees(phiy), 3, 2) + "\u00b0 rot.z: " + nf(degrees(phiz), 3, 2) + '\u00b0'; 354 | text(s, MARGIN + 2, height - MARGIN + 7 - lines * leading); 355 | lines--; 356 | s = "radius: " + rad + ". distance to projection point: " + dis + '.'; 357 | text(s, MARGIN + 2, height - MARGIN + 7 - lines * leading); 358 | lines--; 359 | s = "grid is: " + onoff(drawGrid) + ". plane is: " + onoff(drawPlane) + ". rays are: " + onoff(drawRays) + ". meshes are: " + onoff(drawMeshes) + '.'; 360 | text(s, MARGIN + 2, height - MARGIN + 7 - lines * leading); 361 | lines--; 362 | s = "interaction mode is: "; 363 | if (inputType == 0) { 364 | s += "ROTATION."; 365 | } else { 366 | s += "WARPING."; 367 | } 368 | text(s, MARGIN + 2, height - MARGIN + 7 - lines * leading); 369 | lines--; 370 | s = "mesh interpolation: " + nf(k21 * k11, 1, 4) + " | " + nf(k21 * k12, 1, 4) + " | " + nf(k22 * k11, 1, 4) + " | " + nf(k22 * k12, 1, 4) + '.'; 371 | text(s, MARGIN + 2, height - MARGIN + 7 - lines * leading); 372 | lines--; 373 | s = "input is: "; 374 | if (dmInput) { 375 | s += "DOMEMASTER. "; 376 | } else { 377 | if (fullInput) { 378 | s += "360\u00b0 (cropped) "; 379 | } else { 380 | s += "180\u00b0 "; 381 | } 382 | s += "PANORAMA. "; 383 | } 384 | text(s, MARGIN + 2, height - MARGIN + 7 - lines * leading); 385 | } 386 | 387 | public String onoff(boolean input) { 388 | if (input) { 389 | return ("ON"); 390 | } else { 391 | return ("OFF"); 392 | } 393 | 394 | } 395 | 396 | @Override 397 | public void keyPressed() { 398 | if (key == 'x') { 399 | exit(); 400 | } 401 | if (key == 'e') { 402 | showSource = !showSource; 403 | } 404 | if (key == 'z') { 405 | zPos -= zinc; 406 | } 407 | if (key == 'g') { 408 | zPos += zinc; 409 | } 410 | if (key == 'w') { 411 | yPos -= yinc; 412 | } 413 | if (key == 's') { 414 | yPos += yinc; 415 | } 416 | if (key == 'a') { 417 | xPos -= xinc; 418 | } 419 | if (key == 'd') { 420 | xPos += xinc; 421 | } 422 | if (key == 'm') { 423 | drawMeshes = !drawMeshes; 424 | } 425 | if (key == 'n') { 426 | drawGrid = !drawGrid; 427 | } 428 | if (key == 'b') { 429 | drawPlane = !drawPlane; 430 | } 431 | if (key == 'v') { 432 | drawRays = !drawRays; 433 | } 434 | if (key == 'i') { 435 | displayGUI = !displayGUI; 436 | } 437 | if (key == 'q') { 438 | displayInfos = !displayInfos; 439 | } 440 | if (key == 'j') { 441 | phiz += phizInc; 442 | } 443 | if (key == 'h') { 444 | phiz -= phizInc; 445 | } 446 | if (key == 'p') { 447 | 448 | dis += disstep; 449 | r_d = rad / dis; 450 | p0.set(0, -dis, rad); 451 | println(dis); 452 | 453 | } 454 | if (key == 'l') { 455 | dis -= disstep; 456 | if (dis < 0) { 457 | dis = 0; 458 | } 459 | p0.set(0, -dis, rad); 460 | r_d = rad / dis; 461 | println(dis); 462 | } 463 | if (key == 'r') { 464 | xPos = width / 2f; 465 | yPos = height / 2f; 466 | zPos = -rad * 1.5f; 467 | phiz = 0f; 468 | dis = 520f; 469 | } 470 | 471 | if (key == ' ') { 472 | currentImage++; 473 | currentImage = currentImage % images.length; 474 | initTex(timg[currentImage]); 475 | } 476 | } 477 | 478 | public void initTex(String theImgName) { 479 | tex = null; 480 | fullInput = false; 481 | dmInput = true; 482 | tex = loadImage(theImgName); 483 | if (abs(tex.width - tex.height) > 10f) { 484 | dmInput = false; 485 | if (tex.width / (float) tex.height < 3) { 486 | fullInput = true; 487 | } 488 | 489 | } 490 | tinc_x = tex.width / (float) mCount; 491 | tinc_y = tex.height / (float) lCount * 2f; 492 | 493 | setVectors(); 494 | minc = 1f / (float) (mCount - 1f) * TWO_PI; 495 | linc = 1f / (float) (lCount - 1f) * PI; 496 | if (!fullInput) { 497 | lstep = tex.height / (float) (lCount - 1f) * 2f; 498 | } else { 499 | lstep = tex.height / (float) (lCount - 1f); 500 | } 501 | mstep = tex.width / (float) (mCount - 1f); 502 | } 503 | 504 | public void initTex(PImage theImg) { 505 | tex = null; 506 | fullInput = false; 507 | dmInput = true; 508 | tex = theImg; 509 | if (abs(tex.width - tex.height) > 10f) { 510 | dmInput = false; 511 | if (tex.width / (float) tex.height < 3) { 512 | fullInput = true; 513 | } 514 | 515 | } 516 | tinc_x = tex.width / (float) mCount; 517 | tinc_y = tex.height / (float) lCount * 2f; 518 | 519 | setVectors(); 520 | minc = 1f / (float) (mCount - 1f) * TWO_PI; 521 | linc = 1f / (float) (lCount - 1f) * PI; 522 | if (!fullInput) { 523 | lstep = tex.height / (float) (lCount - 1f) * 2f; 524 | } else { 525 | lstep = tex.height / (float) (lCount - 1f); 526 | } 527 | mstep = tex.width / (float) (mCount - 1f); 528 | } 529 | 530 | public void setVectors() { 531 | vp1 = new PVector(); 532 | vp2 = new PVector(); 533 | vp3 = new PVector(); 534 | vp4 = new PVector(); 535 | 536 | 537 | v = new PVector[4][mCount][lCount]; 538 | minc = 1f / (float) (mCount - 1f) * TWO_PI; 539 | linc = 1f / (float) (lCount - 1f) * PI; 540 | la = 0; 541 | int l = 0; 542 | int m; 543 | 544 | while (la < PI + linc) { 545 | m = 0; 546 | mu = -HALF_PI; 547 | while (mu + HALF_PI < TWO_PI + minc) { 548 | 549 | v[0][m][l] = new PVector(sin(la) * cos(mu) * rad, cos(la) * rad, (sin(la) * sin(mu) + 1) * rad); 550 | v[1][m][l] = new PVector(cos(mu) * rad, -l * a + lCount / 2f * a, (sin(mu) + 1) * rad); 551 | v[2][m][l] = new PVector(mCount * a / 2f - m * a, cos(la) * rad, 2 * rad); 552 | v[3][m][l] = new PVector(mCount * a / 2f - m * a, -l * a + lCount / 2f * a, 2 * rad); 553 | mu += minc; 554 | m++; 555 | } 556 | la += linc; 557 | l++; 558 | } 559 | //println(m); 560 | //println(l); 561 | } 562 | 563 | public void drawAllMeshes(int l, int m) { 564 | for (int i = 0; i < v.length; i++) { 565 | beginShape(QUADS); 566 | vertex(v[i][m][l].x, v[i][m][l].y, v[i][m][l].z); 567 | vertex(v[i][m][l + 1].x, v[i][m][l + 1].y, v[i][m][l + 1].z); 568 | vertex(v[i][m + 1][l + 1].x, v[i][m + 1][l + 1].y, v[i][m + 1][l + 1].z); 569 | vertex(v[i][m + 1][l].x, v[i][m + 1][l].y, v[i][m + 1][l].z); 570 | endShape(CLOSE); 571 | } 572 | } 573 | 574 | private void handleMouseInput() { 575 | switch (inputType) { 576 | case ROTATE: 577 | lastphix = phix; 578 | lastphiy = phiy; 579 | phix = map(constrain(mouseY, 0 + MARGIN, height - MARGIN), 0 + MARGIN, height - MARGIN, TWO_PI, 0); 580 | phiy = map(constrain(mouseX, 0 + MARGIN, width - MARGIN), 0 + MARGIN, width - MARGIN, 0, TWO_PI); 581 | 582 | phixi.set(lastphix); 583 | phiyi.set(lastphiy); 584 | phixi.target(phix); 585 | phiyi.target(phiy); 586 | phixi.update(); 587 | phix = phixi.getValue(); 588 | phiyi.update(); 589 | phiy = phiyi.getValue(); 590 | 591 | tr1i.update(); 592 | tr2i.update(); 593 | tr1 = tr1i.getValue(); 594 | tr2 = tr2i.getValue(); 595 | break; 596 | case PROJECT_A: 597 | lasttr1 = tr1; 598 | lasttr2 = tr2; 599 | tr1 = map(constrain(mouseY, 0 + MARGIN, height - MARGIN), 0 + MARGIN, height - MARGIN, 0, HALF_PI); 600 | tr2 = map(constrain(mouseX, 0 + MARGIN, width - MARGIN), 0 + MARGIN, width - MARGIN, 0, HALF_PI); 601 | 602 | tr1i.set(lasttr1); 603 | tr2i.set(lasttr2); 604 | tr1i.target(tr1); 605 | tr2i.target(tr2); 606 | tr1i.update(); 607 | tr1 = tr1i.getValue(); 608 | tr2i.update(); 609 | tr2 = tr2i.getValue(); 610 | phixi.update(); 611 | phix = phixi.getValue(); 612 | phiyi.update(); 613 | phiy = phiyi.getValue(); 614 | break; 615 | } 616 | } 617 | 618 | @Override 619 | public void mousePressed() { 620 | inputType = (inputType + 1) % INPUTCOUNT; 621 | drawRays = false; 622 | drawPlane = false; 623 | } 624 | 625 | static public void main(String args[]) { 626 | PApplet.main(new String[]{"--bgcolor=#F0F0F0", "domeapp.DomeModOriginal"}); 627 | } 628 | } 629 | -------------------------------------------------------------------------------- /Java/DomeTools/src/domeapp/DomeTester.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adaption of totally awesome domemod v.022 BETA by Dimitar Ruszev, 2010 (dimitar.ruszev @ gmail.com) 3 | * @author mphasize 4 | */ 5 | package domeapp; 6 | 7 | import dome.Dome; 8 | import dome.InteractiveDome; 9 | import domeExamples.DomeSketch; 10 | import domeExamples.Example1; 11 | import domeExamples.Example2; 12 | import java.util.ArrayList; 13 | import processing.core.PApplet; 14 | import processing.core.PConstants; 15 | import processing.core.PFont; 16 | import processing.core.PGraphics; 17 | 18 | /** 19 | * Adaption of totally awesome domemod v.022 BETA by Dimitar Ruszev, 2010 (dimitar.ruszev @ gmail.com) 20 | * @author mphasize 21 | */ 22 | public class DomeTester extends PApplet implements PConstants { 23 | 24 | private InteractiveDome dome; 25 | private PGraphics canvas; 26 | private boolean previewMode = false; 27 | private ArrayList examples = new ArrayList(); 28 | private DomeSketch example = null; 29 | private int exampleIndex = 0; 30 | private int[] projections = {Dome.DOMEMASTER, Dome.PANORAMA_180, Dome.PANORAMA_360}; 31 | private int projection = 0; 32 | private PFont font; 33 | 34 | /** 35 | * @param args the command line arguments 36 | */ 37 | public static void main(String[] args) { 38 | PApplet.main(new String[]{"domeapp.DomeTester"}); 39 | } 40 | 41 | @Override 42 | public void setup() { 43 | P5.call = this; 44 | size(1024, 768, OPENGL); 45 | hint(PApplet.ENABLE_OPENGL_4X_SMOOTH); 46 | 47 | font = this.createFont("Verdana", 12, true); 48 | this.textFont(font, 12); 49 | 50 | /* Init sketching surface */ 51 | canvas = createGraphics(800, 300, JAVA2D); 52 | canvas.beginDraw(); 53 | canvas.endDraw(); 54 | 55 | /* Load Examples */ 56 | examples.add(new Example2(canvas)); 57 | examples.add(new Example1(canvas)); 58 | /* Prepare first example */ 59 | example = examples.get(exampleIndex); 60 | example.setup(); 61 | 62 | /* Prepare Dome projection */ 63 | dome = new InteractiveDome(); 64 | dome.setRadius(400); 65 | dome.setTexture(canvas, projections[projection]); 66 | } 67 | 68 | @Override 69 | public void draw() { 70 | background(50); 71 | example.draw(); 72 | 73 | if (previewMode) { 74 | dome.handleMouseRotation(mouseX, mouseY); 75 | dome.draw(); 76 | } else { 77 | imageMode(CENTER); 78 | image(canvas, width / 2, height / 2); 79 | } 80 | drawInfos(); 81 | } 82 | 83 | public void drawInfos() { 84 | fill(255); 85 | String project = ""; 86 | switch(projection) { 87 | case 0: project = "DomeMaster"; break; 88 | case 1: project = "Panorama 180°"; break; 89 | case 2: project = "Panorama 360°"; break; 90 | } 91 | String display = previewMode ? "Dome Preview" : "Sketch Preview"; 92 | 93 | text("Example #" + exampleIndex, 20, 32); 94 | text("Display: " + display, 20, height - 36); 95 | if(previewMode) text("Projection: " + project, 20, height-20); 96 | 97 | } 98 | 99 | @Override 100 | public void keyPressed() { 101 | /* reset parameters */ 102 | if (key == 'r') { 103 | dome.resetPosition(); 104 | } 105 | if (key == ' ') { 106 | previewMode = !previewMode; 107 | } 108 | if (key == 'g') { 109 | dome.toggleGrid(); 110 | } 111 | if (key == 'p') { 112 | projection = projection < projections.length - 1 ? projection + 1 : 0; 113 | dome.setTexture(canvas, projections[projection]); 114 | } 115 | if (key == 'e') { 116 | exampleIndex = exampleIndex < examples.size() - 1 ? exampleIndex + 1 : 0; 117 | example = examples.get(exampleIndex); 118 | System.out.println("Switched to example " + exampleIndex); 119 | example.setup(); 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Java/DomeTools/src/domeapp/P5.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package domeapp; 6 | 7 | import processing.core.PApplet; 8 | 9 | /** 10 | * 11 | * @author mphasize 12 | */ 13 | public class P5 extends PApplet { 14 | 15 | static public PApplet call; 16 | } 17 | -------------------------------------------------------------------------------- /Java/DomeTools/src/kinedome/KineDome.java: -------------------------------------------------------------------------------- 1 | /** 2 | * this project uses an fbo to write into cubemap txtures dynamically 3 | * use wasd or arrow cursors to navigate, use mouse to move the cursor 4 | * you can press the mouse to zoom in as well 5 | * 6 | * draw everything into the 'drawScene' function, instead of draw. 7 | * 8 | * Author: Christopher Warnow, 2010, ch.warnow@gmx.de 9 | */ 10 | package kinedome; 11 | 12 | import codeanticode.glgraphics.GLSLShader; 13 | import com.sun.opengl.util.GLUT; 14 | import java.util.Hashtable; 15 | import javax.media.opengl.GL; 16 | import javax.media.opengl.glu.GLU; 17 | import oscP5.OscMessage; 18 | import oscP5.OscP5; 19 | import processing.core.PApplet; 20 | import processing.core.PConstants; 21 | import processing.core.PVector; 22 | import processing.opengl.PGraphicsOpenGL; 23 | 24 | /** 25 | * 26 | * @author mphasize 27 | */ 28 | public class KineDome extends PApplet implements PConstants { 29 | 30 | GLSLShader shader; 31 | PGraphicsOpenGL pgl; 32 | GL gl; 33 | GLU glu; 34 | GLUT glut; 35 | PVector mouseP; 36 | float globalZoom = 0; 37 | PVector mousePos; 38 | float mouseSpeed = .2f; 39 | float globalX = 0; 40 | float globalZ = 0; 41 | float destGlobalX = 0; 42 | float destGlobalZ = 0; 43 | int[] fbo = { 44 | 0}; 45 | int[] rbo = { 46 | 0}; 47 | int[] envMapTextureID = { 48 | 0}; 49 | float[] cameraPos = { 50 | 0.0f, 0.0f, -.00001f, 1.0f}; 51 | int envMapSize = 1024; 52 | Hashtable skels = new Hashtable(); 53 | OscP5 oscP5; 54 | int ballSize = 5; 55 | boolean domemaster = true; 56 | 57 | /** 58 | * @param args the command line arguments 59 | */ 60 | public static void main(String[] args) { 61 | PApplet.main(new String[]{"kinedome.KineDome"}); 62 | } 63 | 64 | @Override 65 | public void setup() { 66 | size(800, 600, OPENGL); 67 | mousePos = new PVector(width * .5f, height * .5f, 0); 68 | glut = new GLUT(); 69 | glu = new GLU(); 70 | pgl = (PGraphicsOpenGL) g; 71 | gl = pgl.gl; 72 | initCubeMap(); 73 | noCursor(); 74 | oscP5 = new OscP5(this, "127.0.0.1", 7110); 75 | } 76 | 77 | /* 78 | * draw everything here 79 | * this scene is called 6 times for the cubemap 80 | */ 81 | public void drawScene() { 82 | 83 | pushMatrix(); 84 | translate(globalX, 0, globalZ); 85 | 86 | // cursorBox 87 | fill(255, 200, 50); 88 | pushMatrix(); 89 | translate(mouseP.x, mouseP.y, mouseP.z); 90 | box(5); 91 | popMatrix(); 92 | 93 | // some test lines 94 | stroke(255); 95 | int linesAmount = 20; 96 | for (int i = 0; i < linesAmount; i++) { 97 | float ratio = (float) i / (linesAmount - 1); 98 | line(0, 0, cos(ratio * TWO_PI) * 30, sin(ratio * TWO_PI) * 30); 99 | } 100 | noStroke(); 101 | 102 | 103 | pushMatrix(); 104 | rotateX(PI/2f); 105 | 106 | for (Skeleton s : skels.values()) { 107 | //s.drawStickfigure(); 108 | for (float[] j : s.allCoords) { 109 | pushMatrix(); 110 | translate(j[0] * 300, j[1] * 300, -j[2] * 100); 111 | sphere(ballSize); 112 | popMatrix(); 113 | } 114 | 115 | } 116 | popMatrix(); 117 | 118 | 119 | popMatrix(); 120 | 121 | 122 | } 123 | 124 | @Override 125 | public void draw() { 126 | // main position 127 | globalX += (destGlobalX - globalX) * .25; 128 | globalZ += (destGlobalZ - globalZ) * .25; 129 | 130 | background(0, 0, 0); 131 | if (mousePressed) { 132 | destGlobalZ += 3; 133 | } 134 | 135 | mousePos.x += (mouseX - mousePos.x) * mouseSpeed; 136 | mousePos.y += (mouseY - mousePos.y) * mouseSpeed; 137 | mouseP = new PVector(-mousePos.x + width * .5f, mousePos.y - height * .5f, 0); 138 | 139 | // draw a sphere that reflects its environment (cubemap) 140 | drawCubeMap(); 141 | } 142 | 143 | @Override 144 | public void keyPressed() { 145 | if (key == 'w' || keyCode == UP) { 146 | destGlobalZ += 3; 147 | } 148 | if (key == 's' || keyCode == DOWN) { 149 | destGlobalZ -= 3; 150 | } 151 | 152 | if (key == 'a' || keyCode == LEFT) { 153 | destGlobalX -= 3; 154 | } 155 | if (key == 'd' || keyCode == RIGHT) { 156 | destGlobalX += 3; 157 | } 158 | if (key == ' ') { 159 | this.domemaster = !this.domemaster; 160 | } 161 | } 162 | 163 | /* incoming osc message are forwarded to the oscEvent method. */ 164 | // Here you can easily see the format of the OSC messages sent. For each user, the joints are named with 165 | // the joint named followed by user ID (head0, neck0 .... r_foot0; head1, neck1.....) 166 | void oscEvent(OscMessage msg) { 167 | //msg.print(); 168 | 169 | if (msg.checkAddrPattern("/joint") && msg.checkTypetag("sifff")) { 170 | // We have received joint coordinates, let's find out which skeleton/joint and save the values ;) 171 | Integer id = msg.get(1).intValue(); 172 | Skeleton s = skels.get(id); 173 | if (s == null) { 174 | s = new Skeleton(id, this); 175 | skels.put(id, s); 176 | } 177 | if (msg.get(0).stringValue().equals("head")) { 178 | s.head[0] = msg.get(2).floatValue(); 179 | s.head[1] = msg.get(3).floatValue(); 180 | s.head[2] = msg.get(4).floatValue(); 181 | } else if (msg.get(0).stringValue().equals("neck")) { 182 | s.neck[0] = msg.get(2).floatValue(); 183 | s.neck[1] = msg.get(3).floatValue(); 184 | s.neck[2] = msg.get(4).floatValue(); 185 | } else if (msg.get(0).stringValue().equals("r_collar")) { 186 | s.rCollar[0] = msg.get(2).floatValue(); 187 | s.rCollar[1] = msg.get(3).floatValue(); 188 | s.rCollar[2] = msg.get(4).floatValue(); 189 | } else if (msg.get(0).stringValue().equals("r_shoulder")) { 190 | s.rShoulder[0] = msg.get(2).floatValue(); 191 | s.rShoulder[1] = msg.get(3).floatValue(); 192 | s.rShoulder[2] = msg.get(4).floatValue(); 193 | } else if (msg.get(0).stringValue().equals("r_elbow")) { 194 | s.rElbow[0] = msg.get(2).floatValue(); 195 | s.rElbow[1] = msg.get(3).floatValue(); 196 | s.rElbow[2] = msg.get(4).floatValue(); 197 | } else if (msg.get(0).stringValue().equals("r_wrist")) { 198 | s.rWrist[0] = msg.get(2).floatValue(); 199 | s.rWrist[1] = msg.get(3).floatValue(); 200 | s.rWrist[2] = msg.get(4).floatValue(); 201 | } else if (msg.get(0).stringValue().equals("r_hand")) { 202 | s.rHand[0] = msg.get(2).floatValue(); 203 | s.rHand[1] = msg.get(3).floatValue(); 204 | s.rHand[2] = msg.get(4).floatValue(); 205 | } else if (msg.get(0).stringValue().equals("r_finger")) { 206 | s.rFinger[0] = msg.get(2).floatValue(); 207 | s.rFinger[1] = msg.get(3).floatValue(); 208 | s.rFinger[2] = msg.get(4).floatValue(); 209 | } else if (msg.get(0).stringValue().equals("r_collar")) { 210 | s.lCollar[0] = msg.get(2).floatValue(); 211 | s.lCollar[1] = msg.get(3).floatValue(); 212 | s.lCollar[2] = msg.get(4).floatValue(); 213 | } else if (msg.get(0).stringValue().equals("l_shoulder")) { 214 | s.lShoulder[0] = msg.get(2).floatValue(); 215 | s.lShoulder[1] = msg.get(3).floatValue(); 216 | s.lShoulder[2] = msg.get(4).floatValue(); 217 | } else if (msg.get(0).stringValue().equals("l_elbow")) { 218 | s.lElbow[0] = msg.get(2).floatValue(); 219 | s.lElbow[1] = msg.get(3).floatValue(); 220 | s.lElbow[2] = msg.get(4).floatValue(); 221 | } else if (msg.get(0).stringValue().equals("l_wrist")) { 222 | s.lWrist[0] = msg.get(2).floatValue(); 223 | s.lWrist[1] = msg.get(3).floatValue(); 224 | s.lWrist[2] = msg.get(4).floatValue(); 225 | } else if (msg.get(0).stringValue().equals("l_hand")) { 226 | s.lHand[0] = msg.get(2).floatValue(); 227 | s.lHand[1] = msg.get(3).floatValue(); 228 | s.lHand[2] = msg.get(4).floatValue(); 229 | } else if (msg.get(0).stringValue().equals("l_finger")) { 230 | s.lFinger[0] = msg.get(2).floatValue(); 231 | s.lFinger[1] = msg.get(3).floatValue(); 232 | s.lFinger[2] = msg.get(4).floatValue(); 233 | } else if (msg.get(0).stringValue().equals("torso")) { 234 | s.torso[0] = msg.get(2).floatValue(); 235 | s.torso[1] = msg.get(3).floatValue(); 236 | s.torso[2] = msg.get(4).floatValue(); 237 | } else if (msg.get(0).stringValue().equals("r_hip")) { 238 | s.rHip[0] = msg.get(2).floatValue(); 239 | s.rHip[1] = msg.get(3).floatValue(); 240 | s.rHip[2] = msg.get(4).floatValue(); 241 | } /* else if (msg.get(0).stringValue().equals("r_knee")) { 242 | s.rKnee[0] = msg.get(2).floatValue(); 243 | s.rKnee[1] = msg.get(3).floatValue(); 244 | s.rKnee[2] = msg.get(4).floatValue(); 245 | } else if (msg.get(0).stringValue().equals("r_ankle")) { 246 | s.rAnkle[0] = msg.get(2).floatValue(); 247 | s.rAnkle[1] = msg.get(3).floatValue(); 248 | s.rAnkle[2] = msg.get(4).floatValue(); 249 | } else if (msg.get(0).stringValue().equals("r_foot")) { 250 | s.rFoot[0] = msg.get(2).floatValue(); 251 | s.rFoot[1] = msg.get(3).floatValue(); 252 | s.rFoot[2] = msg.get(4).floatValue(); 253 | } */ else if (msg.get(0).stringValue().equals("l_hip")) { 254 | s.lHip[0] = msg.get(2).floatValue(); 255 | s.lHip[1] = msg.get(3).floatValue(); 256 | s.lHip[2] = msg.get(4).floatValue(); 257 | } /* else if (msg.get(0).stringValue().equals("l_knee")) { 258 | s.lKnee[0] = msg.get(2).floatValue(); 259 | s.lKnee[1] = msg.get(3).floatValue(); 260 | s.lKnee[2] = msg.get(4).floatValue(); 261 | } else if (msg.get(0).stringValue().equals("l_ankle")) { 262 | s.lAnkle[0] = msg.get(2).floatValue(); 263 | s.lAnkle[1] = msg.get(3).floatValue(); 264 | s.lAnkle[2] = msg.get(4).floatValue(); 265 | } else if (msg.get(0).stringValue().equals("l_foot")) { 266 | s.lFoot[0] = msg.get(2).floatValue(); 267 | s.lFoot[1] = msg.get(3).floatValue(); 268 | s.lFoot[2] = msg.get(4).floatValue(); 269 | } */ 270 | } else if (msg.checkAddrPattern("/new_user") && msg.checkTypetag("i")) { 271 | // A new user is in front of the kinect... Tell him to do the calibration pose! 272 | println("New user with ID = " + msg.get(0).intValue()); 273 | } else if (msg.checkAddrPattern("/new_skel") && msg.checkTypetag("i")) { 274 | //New skeleton calibrated! Lets create it! 275 | Integer id = msg.get(0).intValue(); 276 | Skeleton s = new Skeleton(id, this); 277 | skels.put(id, s); 278 | } else if (msg.checkAddrPattern("/lost_user") && msg.checkTypetag("i")) { 279 | //Lost user/skeleton 280 | Integer id = msg.get(0).intValue(); 281 | println("Lost user " + id); 282 | skels.remove(id); 283 | } 284 | } 285 | 286 | void initCubeMap() { 287 | // init cubemap textures 288 | gl.glGenTextures(1, envMapTextureID, 0); 289 | gl.glBindTexture(GL.GL_TEXTURE_CUBE_MAP, envMapTextureID[0]); 290 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE); 291 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE); 292 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_WRAP_R, GL.GL_CLAMP_TO_EDGE); 293 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); 294 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); 295 | 296 | for (int i = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X; i < GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X + 6; i++) { 297 | gl.glTexImage2D(i, 0, GL.GL_RGBA8, envMapSize, envMapSize, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null); 298 | } 299 | 300 | // smoothing 301 | gl.glEnable(GL.GL_POLYGON_SMOOTH); 302 | gl.glEnable(GL.GL_LINE_SMOOTH); 303 | gl.glEnable(GL.GL_BLEND); 304 | gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_DONT_CARE); 305 | gl.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_DONT_CARE); 306 | 307 | // Loading reflection shader. 308 | shader = new GLSLShader(this, "data/cubemapvert.glsl", "data/cubemapfrag.glsl"); 309 | } 310 | 311 | void drawCubeMap() { 312 | regenerateEnvMap(); 313 | drawDomeMaster(); 314 | } 315 | 316 | void drawDomeMaster() { 317 | // draw the ellipse 318 | ortho(-width * .025f, width * .025f, -height * .025f, height * .025f, 319 | -1500, 1500); 320 | 321 | camera(0, 0, 150, // <- NOTE: this is dynamic and changes the 322 | // perspective, must test and try more 323 | 0, 0, 0, 0, 1, 0); 324 | 325 | shader.start(); 326 | 327 | // draw sphere 328 | gl.glColor3f(1.0f, 1.0f, 1.0f); 329 | glut.glutSolidSphere(height * 0.03, 50, 50); 330 | 331 | shader.stop(); 332 | } 333 | 334 | // Called to regenerate the envmap 335 | void regenerateEnvMap() { 336 | // init fbo 337 | gl.glGenFramebuffersEXT(1, fbo, 0); 338 | gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fbo[0]); 339 | // Attach one of the faces of the Cubemap texture to this FBO 340 | gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, 341 | GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, 342 | envMapTextureID[0], 0); 343 | 344 | gl.glGenRenderbuffersEXT(1, rbo, 0); 345 | gl.glBindRenderbufferEXT(GL.GL_RENDERBUFFER_EXT, rbo[0]); 346 | gl.glRenderbufferStorageEXT(GL.GL_RENDERBUFFER_EXT, 347 | GL.GL_DEPTH_COMPONENT24, envMapSize, envMapSize); 348 | 349 | // Attach depth buffer to FBO 350 | gl.glFramebufferRenderbufferEXT(GL.GL_FRAMEBUFFER_EXT, 351 | GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_RENDERBUFFER_EXT, rbo[0]); 352 | 353 | // generate 6 views from origin(0, 0, 0) 354 | gl.glMatrixMode(GL.GL_PROJECTION); 355 | gl.glLoadIdentity(); 356 | glu.gluPerspective(90.0f, 1.0f, 1.0f, 1025.0f); 357 | gl.glViewport(0, 0, envMapSize, envMapSize); 358 | // gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fbo[0]); 359 | 360 | for (int i = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X; i < GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X + 6; i++) { 361 | 362 | gl.glMatrixMode(GL.GL_MODELVIEW); 363 | gl.glLoadIdentity(); 364 | switch (i) { 365 | case GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X: 366 | // +X 367 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 368 | 0.0f); 369 | break; 370 | case GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X: 371 | // -X 372 | glu.gluLookAt(0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 373 | 0.0f); 374 | break; 375 | case GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y: 376 | // +Y 377 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 378 | 1.0f); 379 | break; 380 | case GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: 381 | // -Y 382 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 383 | -1.0f); 384 | break; 385 | case GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z: 386 | // +Z 387 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 388 | 0.0f); 389 | break; 390 | case GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: 391 | // -Z 392 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, -1.0f, 393 | 0.0f); 394 | break; 395 | default: 396 | assert (false); 397 | break; 398 | } 399 | gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, 400 | GL.GL_COLOR_ATTACHMENT0_EXT, i, envMapTextureID[0], 0); 401 | // Clear the window with current clearing color 402 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); 403 | // Draw objects in the scene 404 | drawScene(); 405 | } 406 | 407 | // Delete resources 408 | gl.glDeleteRenderbuffersEXT(1, rbo, 0); 409 | // Bind 0, which means render to back buffer, as a result, fb is unbound 410 | gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); 411 | gl.glDeleteFramebuffersEXT(1, fbo, 0); 412 | 413 | // restore view 414 | gl.glMatrixMode(GL.GL_MODELVIEW); 415 | gl.glLoadIdentity(); 416 | glu.gluLookAt(cameraPos[0], cameraPos[1], cameraPos[2], 0.0f, 0.0f, 417 | 0.0f, 0.0f, 1.0f, 0.0f); 418 | gl.glViewport(0, 0, width, height); 419 | } 420 | } 421 | -------------------------------------------------------------------------------- /Java/DomeTools/src/kinedome/Skeleton.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this template, choose Tools | Templates 3 | * and open the template in the editor. 4 | */ 5 | package kinedome; 6 | 7 | import processing.core.PApplet; 8 | 9 | /** 10 | * 11 | * OSCeleton Example 12 | */ 13 | public class Skeleton { 14 | int id; //here we store the skeleton's ID as assigned by OpenNI and sent through OSC. 15 | PApplet p5; 16 | int scale = 50; 17 | 18 | // We just use this class as a structure to store the joint coordinates sent by OSC. 19 | // The format is {x, y, z}, where x and y are in the [0.0, 1.0] interval, 20 | // and z is in the [0.0, 7.0] interval. 21 | float head[] = new float[3]; 22 | float neck[] = new float[3]; 23 | float rCollar[] = new float[3]; 24 | float rShoulder[] = new float[3]; 25 | float rElbow[] = new float[3]; 26 | float rWrist[] = new float[3]; 27 | float rHand[] = new float[3]; 28 | float rFinger[] = new float[3]; 29 | float lCollar[] = new float[3]; 30 | float lShoulder[] = new float[3]; 31 | float lElbow[] = new float[3]; 32 | float lWrist[] = new float[3]; 33 | float lHand[] = new float[3]; 34 | float lFinger[] = new float[3]; 35 | float torso[] = new float[3]; 36 | float rHip[] = new float[3]; 37 | float rKnee[] = new float[3]; 38 | float rAnkle[] = new float[3]; 39 | float rFoot[] = new float[3]; 40 | float lHip[] = new float[3]; 41 | float lKnee[] = new float[3]; 42 | float lAnkle[] = new float[3]; 43 | float lFoot[] = new float[3]; 44 | float[] allCoords[] = {head, neck, rCollar, rShoulder, rElbow, rWrist, 45 | rHand, rFinger, lCollar, lShoulder, lElbow, lWrist, 46 | lHand, lFinger, torso, rHip, lHip}; 47 | 48 | 49 | Skeleton(int id, PApplet p5) { 50 | this.id = id; 51 | this.p5 = p5; 52 | } 53 | 54 | public void drawStickfigure() { 55 | p5.stroke(255); 56 | p5.noFill(); 57 | line(head, neck); 58 | line(neck, rCollar); 59 | line(neck, lCollar); 60 | line(lCollar, lShoulder); 61 | line(lShoulder, lElbow); 62 | line(lElbow, lWrist); 63 | line(lWrist, lHand); 64 | line(rCollar, rShoulder); 65 | line(rShoulder, rElbow); 66 | line(rElbow, rWrist); 67 | line(rWrist, rHand); 68 | line(lShoulder, torso); 69 | line(rShoulder, torso); 70 | } 71 | 72 | private void line(float[] from, float[] to) { 73 | p5.line(from[0] * scale, from[1] * scale, -from[2] * scale, to[0] * scale, to[1] * scale, -to[2] * scale); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Processing/FullDomeTemplate/CubeMapUtils.pde: -------------------------------------------------------------------------------- 1 | /** 2 | * this project uses an fbo to write into cubemap txtures dynamically 3 | * use wasd or arrow cursors to navigate, use mouse to move the cursor 4 | * you can press the mouse to zoom in as well 5 | * 6 | * draw everything into the 'drawScene' function, instead of draw. 7 | * 8 | * Author: Christopher Warnow, 2010, ch.warnow@gmx.de 9 | */ 10 | int[] fbo = { 11 | 0 }; 12 | int[] rbo = { 13 | 0 }; 14 | int[] envMapTextureID = { 15 | 0 }; 16 | 17 | float[] cameraPos = { 18 | 0.0f, 0.0f, -.00001f, 1.0f }; 19 | 20 | int envMapSize = 1024; 21 | 22 | void initCubeMap() { 23 | // init cubemap textures 24 | gl.glGenTextures(1, envMapTextureID, 0); 25 | gl.glBindTexture(GL.GL_TEXTURE_CUBE_MAP, envMapTextureID[0]); 26 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE); 27 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE); 28 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_WRAP_R, GL.GL_CLAMP_TO_EDGE); 29 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); 30 | gl.glTexParameteri(GL.GL_TEXTURE_CUBE_MAP, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); 31 | 32 | for (int i = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X; i < GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X+6; i++) 33 | { 34 | gl.glTexImage2D(i, 0, GL.GL_RGBA8, envMapSize, envMapSize, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null); 35 | } 36 | 37 | // smoothing 38 | gl.glEnable (GL.GL_POLYGON_SMOOTH); 39 | gl.glEnable (GL.GL_LINE_SMOOTH); 40 | gl.glEnable (GL.GL_BLEND); 41 | gl.glHint (GL.GL_LINE_SMOOTH_HINT, GL.GL_DONT_CARE); 42 | gl.glHint (GL.GL_POLYGON_SMOOTH_HINT, GL.GL_DONT_CARE); 43 | 44 | // Loading reflection shader. 45 | shader = new GLSLShader(this, "cubemapvert.glsl", "cubemapfrag.glsl"); 46 | } 47 | 48 | void drawCubeMap() { 49 | regenerateEnvMap(); 50 | drawDomeMaster(); 51 | } 52 | 53 | void drawDomeMaster() { 54 | // draw the ellipse 55 | ortho(-width * .025f, width * .025f, -height * .025f, height * .025f, 56 | -1500, 1500); 57 | 58 | camera(0, 0, 150, // <- NOTE: this is dynamic and changes the 59 | // perspective, must test and try more 60 | 0, 0, 0, 0, 1, 0); 61 | 62 | shader.start(); 63 | 64 | // draw sphere 65 | gl.glColor3f(1.0f, 1.0f, 1.0f); 66 | glut.glutSolidSphere(height*0.03, 50, 50); 67 | 68 | shader.stop(); 69 | } 70 | 71 | // Called to regenerate the envmap 72 | void regenerateEnvMap() 73 | { 74 | // init fbo 75 | gl.glGenFramebuffersEXT(1, fbo, 0); 76 | gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fbo[0]); 77 | // Attach one of the faces of the Cubemap texture to this FBO 78 | gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, 79 | GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, 80 | envMapTextureID[0], 0); 81 | 82 | gl.glGenRenderbuffersEXT(1, rbo, 0); 83 | gl.glBindRenderbufferEXT(GL.GL_RENDERBUFFER_EXT, rbo[0]); 84 | gl.glRenderbufferStorageEXT(GL.GL_RENDERBUFFER_EXT, 85 | GL.GL_DEPTH_COMPONENT24, envMapSize, envMapSize); 86 | 87 | // Attach depth buffer to FBO 88 | gl.glFramebufferRenderbufferEXT(GL.GL_FRAMEBUFFER_EXT, 89 | GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_RENDERBUFFER_EXT, rbo[0]); 90 | 91 | // generate 6 views from origin(0, 0, 0) 92 | gl.glMatrixMode(GL.GL_PROJECTION); 93 | gl.glLoadIdentity(); 94 | glu.gluPerspective(90.0f, 1.0f, 1.0f, 1025.0f); 95 | gl.glViewport(0, 0, envMapSize, envMapSize); 96 | // gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fbo[0]); 97 | 98 | for (int i = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X; i < GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X + 6; i++) { 99 | 100 | gl.glMatrixMode(GL.GL_MODELVIEW); 101 | gl.glLoadIdentity(); 102 | switch (i) { 103 | case GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X: 104 | // +X 105 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 106 | 0.0f); 107 | break; 108 | case GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X: 109 | // -X 110 | glu.gluLookAt(0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 111 | 0.0f); 112 | break; 113 | case GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y: 114 | // +Y 115 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 116 | 1.0f); 117 | break; 118 | case GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: 119 | // -Y 120 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 121 | -1.0f); 122 | break; 123 | case GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z: 124 | // +Z 125 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 126 | 0.0f); 127 | break; 128 | case GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: 129 | // -Z 130 | glu.gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, -1.0f, 131 | 0.0f); 132 | break; 133 | default: 134 | assert (false); 135 | break; 136 | } 137 | gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, 138 | GL.GL_COLOR_ATTACHMENT0_EXT, i, envMapTextureID[0], 0); 139 | // Clear the window with current clearing color 140 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); 141 | // Draw objects in the scene 142 | drawScene(); 143 | } 144 | 145 | // Delete resources 146 | gl.glDeleteRenderbuffersEXT(1, rbo, 0); 147 | // Bind 0, which means render to back buffer, as a result, fb is unbound 148 | gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); 149 | gl.glDeleteFramebuffersEXT(1, fbo, 0); 150 | 151 | // restore view 152 | gl.glMatrixMode(GL.GL_MODELVIEW); 153 | gl.glLoadIdentity(); 154 | glu.gluLookAt(cameraPos[0], cameraPos[1], cameraPos[2], 0.0f, 0.0f, 155 | 0.0f, 0.0f, 1.0f, 0.0f); 156 | 157 | gl.glViewport(0, 0, width, height); 158 | } 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /Processing/FullDomeTemplate/FullDomeTemplate.pde: -------------------------------------------------------------------------------- 1 | /** 2 | * this project uses an fbo to write into cubemap txtures dynamically 3 | * use wasd or arrow cursors to navigate, use mouse to move the cursor 4 | * you can press the mouse to zoom in as well 5 | * 6 | * draw everything into the 'drawScene' function, instead of draw. 7 | * 8 | * Author: Christopher Warnow, 2010, ch.warnow@gmx.de 9 | */ 10 | import codeanticode.glgraphics.*; 11 | import processing.opengl.*; 12 | import javax.media.opengl.*; 13 | import javax.media.opengl.glu.GLU; 14 | import com.sun.opengl.util.*; 15 | 16 | GLSLShader shader; 17 | PGraphicsOpenGL pgl; 18 | GL gl; 19 | GLU glu; 20 | GLUT glut; 21 | PVector mouseP; 22 | float globalZoom = 0; 23 | 24 | PVector mousePos; 25 | float mouseSpeed = .2; 26 | float globalX = 0; 27 | float globalZ = 0; 28 | float destGlobalX = 0; 29 | float destGlobalZ = 0; 30 | 31 | void setup() { 32 | size(800, 600, OPENGL); 33 | mousePos = new PVector(width*.5, height*.5, 0); 34 | glut = new GLUT(); 35 | glu = new GLU(); 36 | pgl = (PGraphicsOpenGL) g; 37 | gl = pgl.gl; 38 | 39 | initCubeMap(); 40 | 41 | noCursor(); 42 | } 43 | 44 | /* 45 | * draw everything here 46 | * this scene is called 6 times for the cubemap 47 | */ 48 | void drawScene() { 49 | 50 | pushMatrix(); 51 | translate(globalX, 0, globalZ); 52 | 53 | // cursorBox 54 | fill(255, 200, 50); 55 | pushMatrix(); 56 | translate(mouseP.x, mouseP.y, mouseP.z); 57 | box(5); 58 | popMatrix(); 59 | 60 | // some test lines 61 | stroke(255); 62 | int linesAmount = 20; 63 | for(int i=0;i p5.width ? -size : x + 1; 16 | p5.noStroke(); 17 | p5.fill(255); 18 | p5.rect(x, p5.height - size * 2, size, size); 19 | p5.noFill(); 20 | p5.stroke(255); 21 | p5.ellipse(p5.width / 2, p5.height / 2, x, x); 22 | p5.endDraw(); // This has to be used LAST! 23 | } 24 | 25 | /* Only change the name of the class to your class name here! */ 26 | public Beispiel1(PGraphics g) { 27 | super(g); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Processing/SimulationTemplate/Beispiel2.pde: -------------------------------------------------------------------------------- 1 | public class Beispiel2 extends DomeSketch { 2 | 3 | int number_of_rects = 12; 4 | float runner; 5 | 6 | public void setup() { 7 | } 8 | 9 | public void draw() { 10 | /* Use p5. prefix for everything that you would normally do inside processing */ 11 | runner += 0.01f; // Rotation speed 12 | p5.beginDraw(); // This has to be used FIRST! 13 | p5.rectMode(CENTER); 14 | p5.background(0); 15 | p5.fill(100); 16 | p5.stroke(255); 17 | p5.translate(p5.width/2, p5.height/2); 18 | for(int i = 0; i < number_of_rects; i++) { 19 | p5.pushMatrix(); 20 | p5.rotate(sin(runner) + i * TWO_PI/number_of_rects); 21 | p5.translate(150,0); 22 | p5.rect(0,0, 50, 20); 23 | p5.popMatrix(); 24 | } 25 | p5.endDraw(); // This has to be used LAST! 26 | } 27 | 28 | /* Only change the name of the class to your class name here! */ 29 | public Beispiel2(PGraphics g) { 30 | super(g); 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Processing/SimulationTemplate/Dome.pde: -------------------------------------------------------------------------------- 1 | /* 2 | * Adaption of totally awesome domemod v.022 BETA by Dimitar Ruszev, 2010 (dimitar.ruszev @ gmail.com) 3 | * @author mphasize 4 | */ 5 | public class Dome implements PConstants { 6 | /* Projection Constants */ 7 | 8 | public static final int AUTOMATIC = 0; 9 | public static final int DOMEMASTER = 1; 10 | public static final int PANORAMA_360 = 2; 11 | public static final int PANORAMA_180 = 3; 12 | /* Image for projection */ 13 | private PImage texture = null; 14 | private int sourceProjection = AUTOMATIC; 15 | 16 | /* Draw Options */ 17 | private boolean drawGrid = false; 18 | private boolean drawMeshes = false; 19 | private boolean drawPlane = false; 20 | private boolean drawRays = false; 21 | 22 | int mCount = 41; 23 | int lCount = 21; 24 | /* Internal Mathematics */ 25 | private PVector vp1, vp2, vp3, vp4, p0; 26 | private PVector[][][] v; 27 | private float mu, la; 28 | private float k11, k12, k21, k22; 29 | protected float tr1, tr2; 30 | private float radius = 400f; 31 | private float distance = 520f; 32 | private float minc, linc, lstep, mstep; 33 | private float phi = PI / (float) mCount; 34 | // private float theta = PI / (float) mCount; 35 | private float a = radius * sin(phi) * 2; 36 | 37 | public void draw() { 38 | if (texture != null) { 39 | rectMode(CORNERS); 40 | 41 | la = 0; 42 | int l = 0; 43 | int m; 44 | int lp; 45 | int mp; 46 | k11 = sq(cos(tr1)); 47 | k12 = sq(sin(tr1)); 48 | k21 = sq(cos(tr2)); 49 | k22 = sq(sin(tr2)); 50 | 51 | while (la < HALF_PI) { 52 | m = 0; 53 | mu = -HALF_PI; 54 | while (mu + HALF_PI <= TWO_PI) { 55 | 56 | lp = (l + 1); 57 | mp = (m + 1); 58 | 59 | 60 | vp1.set(k21 * (k11 * v[0][m][l].x + k12 * v[1][m][l].x) + k22 * (k11 * v[2][m][l].x + k12 * v[3][m][l].x), 61 | k21 * (k11 * v[0][m][l].y + k12 * v[1][m][l].y) + k22 * (k11 * v[2][m][l].y + k12 * v[3][m][l].y), 62 | k21 * (k11 * v[0][m][l].z + k12 * v[1][m][l].z) + k22 * (k11 * v[2][m][l].z + k12 * v[3][m][l].z)); 63 | 64 | vp2.set(k21 * (k11 * v[0][m][lp].x + k12 * v[1][m][lp].x) + k22 * (k11 * v[2][m][lp].x + k12 * v[3][m][lp].x), 65 | k21 * (k11 * v[0][m][lp].y + k12 * v[1][m][lp].y) + k22 * (k11 * v[2][m][lp].y + k12 * v[3][m][lp].y), 66 | k21 * (k11 * v[0][m][lp].z + k12 * v[1][m][lp].z) + k22 * (k11 * v[2][m][lp].z + k12 * v[3][m][lp].z)); 67 | 68 | vp3.set(k21 * (k11 * v[0][mp][lp].x + k12 * v[1][mp][lp].x) + k22 * (k11 * v[2][mp][lp].x + k12 * v[3][mp][lp].x), 69 | k21 * (k11 * v[0][mp][lp].y + k12 * v[1][mp][lp].y) + k22 * (k11 * v[2][mp][lp].y + k12 * v[3][mp][lp].y), 70 | k21 * (k11 * v[0][mp][lp].z + k12 * v[1][mp][lp].z) + k22 * (k11 * v[2][mp][lp].z + k12 * v[3][mp][lp].z)); 71 | 72 | vp4.set(k21 * (k11 * v[0][mp][l].x + k12 * v[1][mp][l].x) + k22 * (k11 * v[2][mp][l].x + k12 * v[3][mp][l].x), 73 | k21 * (k11 * v[0][mp][l].y + k12 * v[1][mp][l].y) + k22 * (k11 * v[2][mp][l].y + k12 * v[3][mp][l].y), 74 | k21 * (k11 * v[0][mp][l].z + k12 * v[1][mp][l].z) + k22 * (k11 * v[2][mp][l].z + k12 * v[3][mp][l].z)); 75 | 76 | 77 | if (drawMeshes) { 78 | 79 | beginShape(POINTS); 80 | strokeWeight(3); 81 | stroke(127, 127, 0); 82 | vertex(v[0][m][l].x, v[0][m][l].y, v[0][m][l].z); 83 | stroke(63, 127, 0); 84 | vertex(v[1][m][l].x, v[1][m][l].y, v[1][m][l].z); 85 | stroke(0, 127, 63); 86 | vertex(v[2][m][l].x, v[2][m][l].y, v[2][m][l].z); 87 | stroke(0, 127, 127); 88 | vertex(v[3][m][l].x, v[3][m][l].y, v[3][m][l].z); 89 | endShape(); 90 | strokeWeight(2); 91 | } 92 | 93 | stroke(255, 255, 96, 127); 94 | 95 | //////////////// draws the dome 96 | 97 | if (!drawGrid) { 98 | noStroke(); 99 | } 100 | 101 | float s1 = sin(linc * l) * (radius + distance) / (cos(linc * l) + distance / radius); 102 | float s2 = sin(linc * (l + 1)) * (radius + distance) / (cos(linc * (l + 1)) + distance / radius); 103 | float t1 = map(s1, 0, ((radius + distance) * radius / distance), 0, (texture.height / 2f)); 104 | float t2 = map(s2, 0, ((radius + distance) * radius / distance), 0, (texture.height / 2f)); 105 | 106 | if (sourceProjection == DOMEMASTER) { 107 | beginShape(QUADS); 108 | texture(texture); 109 | tint(255, 192); 110 | vertex(vp1.x, vp1.y, vp1.z, texture.width / 2f + cos(mu) * t1, texture.height / 2f + sin(mu) * t1); 111 | vertex(vp2.x, vp2.y, vp2.z, texture.width / 2f + cos(mu) * t2, texture.height / 2f + sin(mu) * t2); 112 | vertex(vp3.x, vp3.y, vp3.z, texture.width / 2f + cos(mu + minc) * t2, texture.height / 2f + sin(mu + minc) * t2); 113 | vertex(vp4.x, vp4.y, vp4.z, texture.width / 2f + cos(mu + minc) * t1, texture.height / 2f + sin(mu + minc) * t1); 114 | endShape(CLOSE); 115 | } 116 | else { 117 | beginShape(QUADS); 118 | texture(texture); 119 | tint(255, 192); 120 | vertex(vp1.x, vp1.y, vp1.z, mstep * m, lstep * l); 121 | vertex(vp2.x, vp2.y, vp2.z, mstep * m, lstep * (l + 1)); 122 | vertex(vp3.x, vp3.y, vp3.z, mstep * (m + 1), lstep * (l + 1)); 123 | vertex(vp4.x, vp4.y, vp4.z, mstep * (m + 1), lstep * l); 124 | endShape(CLOSE); 125 | } 126 | float s = 0; 127 | //////////////// draws the domemaster in plane 128 | if (drawPlane) { 129 | if (sourceProjection == DOMEMASTER) { 130 | beginShape(QUADS); 131 | texture(texture); 132 | tint(255, 192); 133 | vertex(s + cos(mu) * s1, radius, s + sin(mu) * s1 + radius, texture.width / 2f + cos(mu) * t1, texture.height / 2f + sin(mu) * t1); 134 | vertex(s + cos(mu) * s2, radius, s + sin(mu) * s2 + radius, texture.width / 2f + cos(mu) * t2, texture.height / 2f + sin(mu) * t2); 135 | vertex(s + cos(mu + minc) * s2, radius, s + sin(mu + minc) * s2 + radius, texture.width / 2f + cos(mu + minc) * t2, texture.height / 2f + sin(mu + minc) * t2); 136 | vertex(s + cos(mu + minc) * s1, radius, s + sin(mu + minc) * s1 + radius, texture.width / 2f + cos(mu + minc) * t1, texture.height / 2f + sin(mu + minc) * t1); 137 | endShape(CLOSE); 138 | } 139 | else { 140 | beginShape(QUADS); 141 | texture(texture); 142 | tint(255, 192); 143 | vertex(s + cos(mu) * s1, radius, s + sin(mu) * s1 + radius, mstep * m, lstep * l); 144 | vertex(s + cos(mu) * s2, radius, s + sin(mu) * s2 + radius, mstep * m, lstep * (l + 1)); 145 | vertex(s + cos(mu + minc) * s2, radius, s + sin(mu + minc) * s2 + radius, mstep * (m + 1), lstep * (l + 1)); 146 | vertex(s + cos(mu + minc) * s1, radius, s + sin(mu + minc) * s1 + radius, mstep * (m + 1), lstep * l); 147 | endShape(CLOSE); 148 | } 149 | } 150 | 151 | 152 | //////////////// draws the projection rays 153 | //stroke(255,63); 154 | if (drawRays) { 155 | int c = texture.get((int) (texture.width / 2f + cos(mu) * t2), (int) (texture.height / 2f + sin(mu) * t2)); 156 | stroke(c, 127); 157 | beginShape(LINES); 158 | if (drawPlane) { 159 | vertex(s + cos(mu) * s2, radius, s + sin(mu) * s2 + radius); 160 | } 161 | else { 162 | vertex(vp2.x, vp2.y, vp2.z); 163 | } 164 | vertex(p0.x, p0.y, p0.z); 165 | endShape(); 166 | } 167 | 168 | 169 | mu += minc; 170 | m++; 171 | } 172 | la += linc; 173 | l++; 174 | } 175 | } 176 | } 177 | 178 | private void setVectors() { 179 | vp1 = new PVector(); 180 | vp2 = new PVector(); 181 | vp3 = new PVector(); 182 | vp4 = new PVector(); 183 | 184 | 185 | v = new PVector[4][mCount][lCount]; 186 | minc = 1f / (float) (mCount - 1f) * TWO_PI; 187 | linc = 1f / (float) (lCount - 1f) * PI; 188 | la = 0; 189 | int l = 0; 190 | int m; 191 | 192 | while (la < PI + linc) { 193 | m = 0; 194 | mu = -HALF_PI; 195 | while (mu + HALF_PI < TWO_PI + minc) { 196 | 197 | v[0][m][l] = new PVector(sin(la) * cos(mu) * radius, cos(la) * radius, (sin(la) * sin(mu) + 1) * radius); 198 | v[1][m][l] = new PVector(cos(mu) * radius, -l * a + lCount / 2f * a, (sin(mu) + 1) * radius); 199 | v[2][m][l] = new PVector(mCount * a / 2f - m * a, cos(la) * radius, 2 * radius); 200 | v[3][m][l] = new PVector(mCount * a / 2f - m * a, -l * a + lCount / 2f * a, 2 * radius); 201 | mu += minc; 202 | m++; 203 | } 204 | la += linc; 205 | l++; 206 | } 207 | } 208 | 209 | private void initTexture() { 210 | if (sourceProjection == AUTOMATIC) { 211 | if (abs(texture.width - texture.height) > 10f) { 212 | if (texture.width / (float) texture.height < 3) { 213 | sourceProjection = Dome.PANORAMA_360; 214 | } 215 | else { 216 | sourceProjection = Dome.PANORAMA_180; 217 | } 218 | } 219 | else { 220 | sourceProjection = Dome.DOMEMASTER; 221 | } 222 | } 223 | setVectors(); 224 | minc = 1f / (float) (mCount - 1f) * TWO_PI; 225 | linc = 1f / (float) (lCount - 1f) * PI; 226 | if (sourceProjection != Dome.PANORAMA_360) { 227 | lstep = texture.height / (float) (lCount - 1f) * 2f; 228 | } 229 | else { 230 | lstep = texture.height / (float) (lCount - 1f); 231 | } 232 | mstep = texture.width / (float) (mCount - 1f); 233 | } 234 | 235 | public float getDistance() { 236 | return distance; 237 | } 238 | 239 | public void setDistance(float distance) { 240 | this.distance = distance > 0 ? distance : 0; 241 | p0.set(0, -this.distance, radius); 242 | } 243 | 244 | public int getSourceProjection() { 245 | return sourceProjection; 246 | } 247 | 248 | public void setSourceProjection(int sourceProjection) { 249 | this.sourceProjection = sourceProjection; 250 | } 251 | 252 | public PImage getTexture() { 253 | return texture; 254 | } 255 | 256 | public void setTexture(PImage texture) { 257 | this.sourceProjection = AUTOMATIC; 258 | this.texture = texture; 259 | } 260 | 261 | public void setTexture(PImage texture, int projection) { 262 | this.sourceProjection = projection; 263 | this.texture = texture; 264 | this.initTexture(); 265 | } 266 | 267 | public float getRadius() { 268 | return radius; 269 | } 270 | 271 | public void setRadius(float radius) { 272 | this.radius = radius; 273 | } 274 | 275 | public void toggleGrid() { 276 | this.drawGrid = !this.drawGrid; 277 | } 278 | 279 | public boolean hasGrid() { 280 | return this.drawGrid; 281 | } 282 | } 283 | 284 | -------------------------------------------------------------------------------- /Processing/SimulationTemplate/DomeSketch.pde: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @author mphasize 4 | */ 5 | public class DomeSketch { 6 | 7 | PGraphics p5; 8 | 9 | public void setup() { 10 | } 11 | 12 | public void draw() { 13 | } 14 | 15 | public void init(PGraphics g) { 16 | p5 = g; 17 | } 18 | 19 | public DomeSketch(PGraphics g) { 20 | this.init(g); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Processing/SimulationTemplate/Integrator.pde: -------------------------------------------------------------------------------- 1 | public class Integrator { 2 | 3 | final float DAMPING = 0.5f; 4 | final float ATTRACTION = 0.2f; 5 | float value; 6 | float vel; 7 | float accel; 8 | float force; 9 | float mass = 1; 10 | float damping = DAMPING; 11 | float attraction = ATTRACTION; 12 | boolean targeting; 13 | float target; 14 | 15 | public Integrator() { 16 | } 17 | 18 | public Integrator(float value) { 19 | this.value = value; 20 | } 21 | 22 | public Integrator(float value, float damping, float attraction) { 23 | this.value = value; 24 | this.damping = damping; 25 | this.attraction = attraction; 26 | } 27 | 28 | public void set(float v) { 29 | value = v; 30 | } 31 | 32 | public void update() { 33 | if (targeting) { 34 | force += attraction * (target - value); 35 | } 36 | 37 | accel = force / mass; 38 | vel = (vel + accel) * damping; 39 | value += vel; 40 | 41 | force = 0; 42 | } 43 | 44 | public void target(float t) { 45 | targeting = true; 46 | target = t; 47 | } 48 | 49 | public void noTarget() { 50 | targeting = false; 51 | } 52 | 53 | public float getValue() { 54 | return value; 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /Processing/SimulationTemplate/InteractiveDome.pde: -------------------------------------------------------------------------------- 1 | public class InteractiveDome extends Dome { 2 | /* Manipulation constants */ 3 | static final int ROTATION = 0; 4 | static final int PROJECTION = 1; 5 | PVector position; 6 | float radius = 400f; 7 | Integrator phixi, phiyi, tr1i, tr2i; 8 | float phix = 0, phiy = 0, phiz = 0, lastphix, lastphiy; 9 | float lasttr1, lasttr2; 10 | 11 | public InteractiveDome() { 12 | position = new PVector(width / 2, height / 2, -radius * 1.5f); 13 | phixi = new Integrator(0f, .5f, .1f); 14 | phiyi = new Integrator(0f, .5f, .1f); 15 | tr1i = new Integrator(0f, .5f, .1f); 16 | tr2i = new Integrator(0f, .5f, .1f); 17 | } 18 | 19 | 20 | public void draw() { 21 | pushMatrix(); 22 | translate(position.x, position.y, position.z); 23 | rotateX(phix); 24 | rotateY(phiy); 25 | rotateZ(phiz); 26 | translate(0, 0, -radius); 27 | super.draw(); 28 | popMatrix(); 29 | } 30 | 31 | public void resetPosition() { 32 | position.set(width / 2, height / 2, -radius * 1.5f); 33 | phiz = 0f; 34 | this.setDistance(520f); 35 | } 36 | 37 | public void handleMouseRotation(float mouseX, float mouseY) { 38 | lastphix = phix; 39 | lastphiy = phiy; 40 | phix = map(constrain(mouseY, 0, height), 0, height, TWO_PI, 0); 41 | phiy = map(constrain(mouseX, 0, width), 0, width, 0, TWO_PI); 42 | phixi.set(lastphix); 43 | phiyi.set(lastphiy); 44 | phixi.target(phix); 45 | phiyi.target(phiy); 46 | phixi.update(); 47 | phix = phixi.getValue(); 48 | phiyi.update(); 49 | phiy = phiyi.getValue(); 50 | tr1i.update(); 51 | tr2i.update(); 52 | tr1 = tr1i.getValue(); 53 | tr2 = tr2i.getValue(); 54 | } 55 | 56 | public void handleMouseProjection(float mouseX, float mouseY) { 57 | lasttr1 = tr1; 58 | lasttr2 = tr2; 59 | tr1 = map(constrain(mouseY, 0, height), 0, height, 0, HALF_PI); 60 | tr2 = map(constrain(mouseX, 0, width), 0, width, 0, HALF_PI); 61 | tr1i.set(lasttr1); 62 | tr2i.set(lasttr2); 63 | tr1i.target(tr1); 64 | tr2i.target(tr2); 65 | tr1i.update(); 66 | tr1 = tr1i.getValue(); 67 | tr2i.update(); 68 | tr2 = tr2i.getValue(); 69 | phixi.update(); 70 | phix = phixi.getValue(); 71 | phiyi.update(); 72 | phiy = phiyi.getValue(); 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Processing/SimulationTemplate/README.md: -------------------------------------------------------------------------------- 1 | SimulationTemplate 2 | ================== 3 | 4 | Dieses Template erzeugt eine frei bewegliche Simulation der Kuppel, 5 | die mit euren Processing-Inhalten bespielt werden kann. 6 | 7 | HINWEIS: Vorneweg... man kann leider (noch?) nicht einfach ein bestehendes 8 | Processing-Skript laden, sondern muss bestehende Sketches anpassen oder 9 | einfach neue Beispiele schreiben. Wie das geht, weiter unten... 10 | 11 | 12 | Anleitung: 13 | ---------- 14 | 15 | Beim Öffnen zeigt das App zunächst einen Bildschirm und das flache 16 | Rendering aus dem ersten Beispiel. 17 | 18 | Mit Hilfe von *SPACE* könnt ihr zwischen dem flachen Rendering und 19 | der Kuppelsimulation umschalten. 20 | 21 | Weitere Optionen: 22 | *e* schaltet zwischen den (aktiven) Examples durch... 23 | *g* schaltet das Grid (in der Kuppelsimulation) ein oder aus 24 | *p* ändert die Art und Weise wie das Beispiel in die Kuppel projeziert wird 25 | 26 | 27 | Neues Beispiel erstellen: 28 | --------- 29 | 30 | Am besten einfach ein neues Tab erstellen und den Inhalt von Beispiel1 oder Beispiel2 31 | kopieren und anpassen. 32 | 33 | public class BeispielX extends DomeSketch { 34 | 35 | // Hier Variablen deklarieren 36 | boolean MeinSketh = true 37 | 38 | // Setup-Methode funktioniert wie in Processing 39 | public void setup() { 40 | } 41 | 42 | // Draw-Methode 43 | public void draw() { 44 | /* Für alle Processing-Funktionen und Eigenschaften unbedingt p5. voran stellen! */ 45 | p5.beginDraw(); // Dieser Aufruf muss als erstes kommen! 46 | p5.background(0); 47 | runner += 0.1f; // Speed 48 | x = x > p5.width ? -size : x + 1; 49 | p5.noStroke(); 50 | p5.fill(255); 51 | p5.rect(x, p5.height - size * 2, size, size); 52 | p5.noFill(); 53 | p5.stroke(255); 54 | p5.ellipse(p5.width / 2, p5.height / 2, x, x); 55 | p5.endDraw(); // Dieser Aufruf als letztes! 56 | } 57 | 58 | /* Hier unbedingt den Klassennamen ändern! */ 59 | public BeispielX (PGraphics g) { 60 | super(g); 61 | } 62 | } 63 | 64 | Zur Theorie: Innerhalb der Simulation wird ein PGraphics-Objekt erzeugt, 65 | welches ihr als Leinwand bespielt (mit p5.funktion()). Diese Leinwand (canvas) 66 | wird dann später auf den Dome projeziert. 67 | 68 | 69 | -------------------------------------------------------------------------------- /Processing/SimulationTemplate/SimulationTemplate.pde: -------------------------------------------------------------------------------- 1 | /* 2 | * Adaption of totally awesome domemod v.022 BETA by Dimitar Ruszev, 2010 (dimitar.ruszev @ gmail.com) 3 | * @author mphasize 4 | * 5 | * The interesting part is in the Beispiel1 oder Beispiel2... go there and check it out. 6 | */ 7 | 8 | import processing.opengl.*; 9 | 10 | InteractiveDome dome; 11 | PGraphics canvas; 12 | boolean previewMode = false; 13 | ArrayList examples = new ArrayList(); 14 | DomeSketch example = null; 15 | int exampleIndex = 0; 16 | int[] projections = { 17 | Dome.DOMEMASTER, Dome.PANORAMA_180, Dome.PANORAMA_360 18 | }; 19 | int projection = 0; 20 | PFont font; 21 | 22 | 23 | void setup() { 24 | size(800, 600, OPENGL); 25 | //hint(PApplet.ENABLE_OPENGL_4X_SMOOTH); 26 | 27 | font = this.createFont("Verdana", 12, true); 28 | this.textFont(font, 12); 29 | 30 | /* Init sketching surface */ 31 | canvas = createGraphics(400, 400, JAVA2D); 32 | canvas.beginDraw(); 33 | canvas.endDraw(); 34 | 35 | /* Load Examples 36 | Make a copy of BeispielX, modify it, and add it to this list! 37 | */ 38 | examples.add(new Beispiel1(canvas)); 39 | examples.add(new Beispiel2(canvas)); 40 | 41 | /* Prepare first example */ 42 | example = examples.get(exampleIndex); 43 | example.setup(); 44 | 45 | /* Prepare Dome projection */ 46 | dome = new InteractiveDome(); 47 | dome.setRadius(400); 48 | dome.setTexture(canvas, projections[projection]); 49 | } 50 | 51 | 52 | void draw() { 53 | background(50); 54 | example.draw(); 55 | 56 | if (previewMode) { 57 | dome.handleMouseRotation(mouseX, mouseY); 58 | dome.draw(); 59 | } 60 | else { 61 | imageMode(CENTER); 62 | image(canvas, width / 2, height / 2); 63 | } 64 | drawInfos(); 65 | } 66 | 67 | void drawInfos() { 68 | fill(255); 69 | String project = ""; 70 | switch(projection) { 71 | case 0: 72 | project = "DomeMaster"; 73 | break; 74 | case 1: 75 | project = "Panorama 180°"; 76 | break; 77 | case 2: 78 | project = "Panorama 360°"; 79 | break; 80 | } 81 | String display = previewMode ? "Dome Preview" : "Sketch Preview"; 82 | 83 | text("Example #" + exampleIndex +" (e)", 20, 32); 84 | text("Grid is " + (dome.hasGrid() ? "ON" : "OFF") + " (g)", 20, 48); 85 | text("Display: " + display + " (SPACE)", 20, height - 36); 86 | if(previewMode) text("Projection: " + project + " (p)", 20, height-20); 87 | } 88 | 89 | 90 | void keyPressed() { 91 | /* reset parameters */ 92 | if (key == 'r') { 93 | dome.resetPosition(); 94 | } 95 | if (key == ' ') { 96 | previewMode = !previewMode; 97 | } 98 | if (key == 'g') { 99 | dome.toggleGrid(); 100 | } 101 | if (key == 'p') { 102 | projection = projection < projections.length - 1 ? projection + 1 : 0; 103 | dome.setTexture(canvas, projections[projection]); 104 | } 105 | if (key == 'e') { 106 | exampleIndex = exampleIndex < examples.size() - 1 ? exampleIndex + 1 : 0; 107 | example = examples.get(exampleIndex); 108 | System.out.println("Switched to example " + exampleIndex); 109 | example.setup(); 110 | } 111 | } 112 | 113 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FullDome: Tools and Examples 2 | ============================ 3 | 4 | 5 | This is a collection of tools and code I came across or I modified for displaying interactive content in a fulldome environment. 6 | I do this as part of a class I'm taking called "Immersive Data Visualisation" at the FH Potsdam. 7 | [Workspace](http://incom.org/workspace/2755) 8 | 9 | 10 | Tools: 11 | ====== 12 | 13 | Processing / FullDomeTemplate 14 | --- 15 | Amazing Tool by Christopher Warnow! Warps your Processing Sketch into a dome master with some really nice OpenGL magic. 16 | For [more details and instructions](https://github.com/mphasize/FullDome/tree/master/Processing/FullDomeTemplate) on usage (german only so far...) click the link and scroll down to README... 17 | 18 | 19 | 20 | Processing / SimulationTemplate 21 | --- 22 | 23 | The SimulationTemplate creates a movable Dome and projects your interactive Sketches into it. 24 | For [more details and instructions](https://github.com/mphasize/FullDome/tree/master/Processing/SimulationTemplate) on usage (german only so far...) click the link and scroll down to README... 25 | 26 | --------------------------------------------------------------------------------