├── README.md ├── build └── stereo │ ├── ActiveStereoView.class │ ├── ActiveStereoViewGLGraphics.class │ ├── PassiveStereoView.class │ ├── Stereo$1.class │ ├── Stereo$StereoType.class │ ├── Stereo.class │ └── StereoType.class ├── examples ├── AnaglyphTest │ ├── AnaglyphTest.pde │ └── Quad.pde ├── PassiveDemo │ ├── PassiveDemo.pde │ ├── data │ │ ├── frag.glsl │ │ └── vert.glsl │ └── sketch.properties ├── PassiveDemoRotatingSpheres │ ├── PassiveDemoRotatingSpheres.pde │ └── data │ │ ├── frag.glsl │ │ └── vert.glsl ├── PassiveTest │ ├── PassiveTest.pde │ └── Quad.pde └── SpherePhong │ ├── SpherePhong.pde │ ├── data │ ├── frag.glsl │ └── vert.glsl │ └── sketch.properties ├── jars ├── core.jar ├── export.txt ├── gluegen-rt.jar └── jogl-all.jar ├── library.properties ├── library └── Stereo.jar ├── makeLibrary.sh └── src └── stereo └── Stereo.java /README.md: -------------------------------------------------------------------------------- 1 | stereo 2 | ====== 3 | 4 | Stereographic library for Processing 2.2.1 (see the branches that work with previous versions of Processing), based on code by Paul Bourke. This port to Processing was originally created by Charlie Roberts and Angus Forbes, and continues to be maintained by Angus Forbes and others. Javier Villegas fixed a number of bugs and helped port examples to Processing 2.0. Massimo De Marchi and Giorgio Conte created examples that work with Processing 2.2.1. Many thanks to Andres Colubri for resolving some of the issues introduced in Processing 2.0 (and now resolved in 2.2.1). 5 | 6 | This 2.2.1 version of the library gives you more flexibility in setting the convergence and eye separation. The 2.2.1 gives you access to the JOGL "capabilities", so we can set up an active stereo context (as we can in 1.5.1, but couldn't in 2.0). However, the drivers for Nvidia's consumer level active stereo systems have issues with OpenGL. (A work around might be found at https://github.com/tliron/opengl-3d-vision-bridge, but we haven't had a chance to incorporate it.) So, if you are planning on using this library for active stereo, the only one that has been explicitly tested by us is the 1.5.1 branch. In the meantime, anaglyph and passive work great, and we've created some simple examples to demonstrate them. 7 | 8 | Feel free to send me an email at angus.forbes (at) gmail if you have questions, or especially if you have some demo code that uses this library. 9 | 10 | Projects that use (or have used) this library: 11 | 12 | ICA Temporal Brain-Activity Viewer, University of Arizona Speech and Hearing Lab 13 | 14 | SCRAPE (SCReen Adjusted Panoramic Effect) : https://github.com/c-flynn/SCRAPE 15 | 16 | Allosphere Research Facility : http://www.allosphere.ucsb.edu/ 17 | 18 | Annular Genealogy art project : http://vimeo.com/43759229 19 | 20 | Philip Galanter's 3D Interactive Wall : http://philipgalanter.com/ 21 | 22 | Emanuel Haas's Dance of Molecules : http://www.behance.net/gallery/Dance-of-Molecules/11614101 23 | 24 | Andy Modla's PhotoCube library for Cardboard : http://andymodlaphotography.blogspot.com/2015/07/stereo-photo-cube-app-for-cardboard.html, https://github.com/ajavamind/processing-android/tree/master/AndroidStereoMultiTextureCube, http://andymodlaphotography.blogspot.com/2015/07/write-google-cardboard-vr-apps-with.html, and https://github.com/ajavamind/Processing-Cardboard 25 | 26 | 27 | -------------------------------------------------------------------------------- /build/stereo/ActiveStereoView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeCodingLab/stereo/1bb1e2e2ec81082185cd966927c9a3091fe0bc24/build/stereo/ActiveStereoView.class -------------------------------------------------------------------------------- /build/stereo/ActiveStereoViewGLGraphics.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeCodingLab/stereo/1bb1e2e2ec81082185cd966927c9a3091fe0bc24/build/stereo/ActiveStereoViewGLGraphics.class -------------------------------------------------------------------------------- /build/stereo/PassiveStereoView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeCodingLab/stereo/1bb1e2e2ec81082185cd966927c9a3091fe0bc24/build/stereo/PassiveStereoView.class -------------------------------------------------------------------------------- /build/stereo/Stereo$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeCodingLab/stereo/1bb1e2e2ec81082185cd966927c9a3091fe0bc24/build/stereo/Stereo$1.class -------------------------------------------------------------------------------- /build/stereo/Stereo$StereoType.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeCodingLab/stereo/1bb1e2e2ec81082185cd966927c9a3091fe0bc24/build/stereo/Stereo$StereoType.class -------------------------------------------------------------------------------- /build/stereo/Stereo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeCodingLab/stereo/1bb1e2e2ec81082185cd966927c9a3091fe0bc24/build/stereo/Stereo.class -------------------------------------------------------------------------------- /build/stereo/StereoType.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CreativeCodingLab/stereo/1bb1e2e2ec81082185cd966927c9a3091fe0bc24/build/stereo/StereoType.class -------------------------------------------------------------------------------- /examples/AnaglyphTest/AnaglyphTest.pde: -------------------------------------------------------------------------------- 1 | 2 | import processing.opengl.*; 3 | import javax.media.opengl.*; 4 | import javax.media.opengl.GL2; 5 | import stereo.*; 6 | //import java.nio.*; 7 | 8 | Stereo stereo = null; 9 | Quad[] quads; 10 | float[] Theparams = new float[3]; 11 | 12 | void setup() { 13 | 14 | size(640, 480, OPENGL); 15 | frame.setResizable(true); 16 | quads = new Quad[200]; 17 | 18 | for(int i = 0; i<200; i++) { 19 | quads[i] = new Quad(0.004, i); 20 | } 21 | 22 | Theparams[0] = 0.85; // simetry 23 | Theparams[1] = 0.4; // radia distortion 24 | Theparams[2] = 1.0; // Y scale factor 25 | 26 | background(0); 27 | float convPlane =10.0f; 28 | float eyeSep = (float) (convPlane / 30f); 29 | 30 | frameRate(60); 31 | 32 | // set last parameter according to type of stereo 33 | // ACTIVE, PASSIVE, ANAGLYPH_REDLEFT_CYANRIGHT, ANAGLYPH_CYANLEFT_REDRIGHT etc. 34 | 35 | /* first constructor, custom eye separation, default convergence */ 36 | // stereo = new Stereo(this, eyeSep, 45f, .1f, 1000f, Stereo.StereoType.ANAGLYPH_REDLEFT_CYANRIGHT); 37 | 38 | /* second constructor, custom eye separation, custom convergence */ 39 | stereo = new Stereo(this, eyeSep, 45f, .1f, 1000f, Stereo.StereoType.ANAGLYPH_REDLEFT_CYANRIGHT, convPlane); 40 | 41 | /* third constructor, default eye separation, custom convergence */ 42 | //stereo = new Stereo(this, 45f, .1f, 1000f, Stereo.StereoType.ANAGLYPH_REDLEFT_CYANRIGHT,convPlane); 43 | 44 | /* fourth constructor, default eye separation, default convergence */ 45 | // stereo = new Stereo(this, 45f, .1f, 1000f, Stereo.StereoType.ANAGLYPH_REDLEFT_CYANRIGHT); 46 | } 47 | 48 | //these are test variables.... 49 | float cx = 0f; float cy = 0f; float cz = 10f; 50 | 51 | void draw() { 52 | 53 | background(0,0,0,255); 54 | 55 | //PGraphicsOpenGL pgl = (PGraphicsOpenGL) g; 56 | //pgl.beginPGL(); 57 | //GL2 gl = PJOGL.gl.getGL2(); {//pgl.beginPGL().gl.getGL2(); { 58 | PGL pgl = beginPGL(); 59 | GL2 gl = ((PJOGL)pgl).gl.getGL2(); { 60 | // only needs to be called repeatedly if you are 61 | // changing camera position 62 | stereo.start(gl, 63 | cx, cy, cz, 64 | 0f, 0f, -1f, 65 | 0f, 1f, 0f); 66 | //println(cz); 67 | stereo.right(gl); // right eye rendering 68 | render(gl); 69 | 70 | stereo.left(gl); // left eye rendering 71 | render(gl); 72 | 73 | // only needed for anaglyph 74 | stereo.end(gl); 75 | } 76 | endPGL();//pgl.endPGL(); 77 | } 78 | 79 | void render(GL2 gl) { 80 | 81 | gl.glColor4f(1f,0f,1f,1f); 82 | 83 | for(int i = 0; i<200; i++) { 84 | quads[i].display(gl,Theparams); 85 | } 86 | } 87 | 88 | public void keyPressed() { 89 | 90 | if (key == 'a') { 91 | cz += .1f; 92 | } 93 | 94 | if (key == 'z') { 95 | cz -= .1f; 96 | } 97 | 98 | if (key == 's') { 99 | Theparams[0] += .01f; 100 | } 101 | 102 | if (key == 'x') { 103 | Theparams[0] -= .01f; 104 | } 105 | 106 | if (key == 'd') { 107 | Theparams[1] += .01f; 108 | } 109 | 110 | if (key == 'c') { 111 | Theparams[1] -= .01f; 112 | } 113 | 114 | if (key == 'f') { 115 | Theparams[2] += .01f; 116 | } 117 | 118 | if (key == 'v') { 119 | Theparams[2] -= .01f; 120 | } 121 | 122 | if(keyCode == LEFT) { 123 | stereo.eyeSeperation -= .01; 124 | } 125 | 126 | if(keyCode == RIGHT) { 127 | stereo.eyeSeperation += .01; 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /examples/AnaglyphTest/Quad.pde: -------------------------------------------------------------------------------- 1 | import processing.opengl.*; 2 | import javax.media.opengl.*; 3 | 4 | class Quad { 5 | float Qrad; 6 | float Qangle; 7 | float y; 8 | float[] rgba; 9 | float speed; 10 | int id; 11 | Quad(float _speed, int _id) { 12 | id = _id; 13 | float Rmax = 5.0; 14 | float Ymax = 3; 15 | this.rgba = new float[4]; 16 | this.speed = _speed; 17 | 18 | this.Qangle = random(0,2*PI); 19 | this.Qrad = random(0.01,Rmax); 20 | this.y = random(-Ymax*(1.0-this.Qrad/Rmax),Ymax*(1.0-this.Qrad/Rmax)); 21 | this.rgba[0] = random(0,1); 22 | this.rgba[1] = random(0,1); 23 | this.rgba[2] = random(0,1); 24 | 25 | } 26 | 27 | void display(GL2 gl, float[] TheParams) { 28 | float Rmax = 5.0; 29 | float r =this.Qrad; 30 | this.Qangle += this.speed; 31 | float a = Qangle; 32 | float x = r*sin(a); 33 | float z = r*(TheParams[0])*cos(a); 34 | float b = r*(TheParams[1]); 35 | float s = sin(b); 36 | float c = cos(b); 37 | 38 | 39 | gl.glPushMatrix(); 40 | gl.glTranslatef(s*x+c*z,TheParams[2]*this.y,c*x-s*z); 41 | gl.glColor4f(this.rgba[0],this.rgba[1],this.rgba[2],1f); 42 | gl.glRectf(-.1f,-.1f,.1f,.1f); 43 | gl.glPopMatrix(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /examples/PassiveDemo/PassiveDemo.pde: -------------------------------------------------------------------------------- 1 | import java.nio.*; 2 | import stereo.*; 3 | import processing.opengl.*; 4 | import javax.media.opengl.*; 5 | import javax.media.opengl.GL2; 6 | 7 | 8 | PGL pgl; 9 | PShader sh; 10 | float angle; 11 | 12 | PShape sphere; 13 | Stereo stereo = null; 14 | 15 | PShape[] spheres; 16 | final int N = 8; 17 | 18 | void setup() { 19 | 20 | size(800, 600, P3D); 21 | 22 | 23 | float convPlane =20.0f; 24 | float eyeSep = (float) (convPlane / 30f); 25 | 26 | frameRate(60); 27 | 28 | spheres = new PShape[N]; 29 | /* second constructor, custom eye separation, custom convergence */ 30 | stereo = new Stereo( 31 | this, eyeSep, 45f, 32 | .1f, 1000f, Stereo.StereoType.PASSIVE, 33 | convPlane); 34 | 35 | sh = loadShader("frag.glsl", "vert.glsl"); 36 | sphere = createShape(SPHERE, 2); 37 | sphere.setStroke(0); 38 | angle = 0; 39 | 40 | for(int i=0;i