Skip to content

Commit 407c2f8

Browse files
committed
added Stereoscopy example to VR library
1 parent 4b65796 commit 407c2f8

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Stereoscopy in VR:
2+
// https://github.com/processing/processing-android/issues/593
3+
// By Javier Marco Rubio (https://github.com/jmarco2000)
4+
5+
import processing.vr.*;
6+
7+
int eyedist = 50;
8+
9+
VRCamera cam;
10+
11+
float angulo=0;
12+
13+
float cx, cz;
14+
float px, pz;
15+
float ang;
16+
float orbita = 400;
17+
float vorbita = 0.01;
18+
19+
// eye matrix
20+
PMatrix3D eyeMat = new PMatrix3D();
21+
22+
boolean ciclo = false; //test witch eye is beign draw
23+
float orientacion;
24+
25+
void setup() {
26+
fullScreen(VR);
27+
cameraUp();
28+
rectMode(CENTER);
29+
cam = new VRCamera(this);
30+
cam.setNear(10);
31+
cam.setFar(2500);
32+
33+
//posicion planeta
34+
//centro
35+
cx=width/2;
36+
cz=-200;
37+
ang=0;
38+
}
39+
40+
void draw() {
41+
ciclo = !ciclo;
42+
43+
background(0);
44+
lights();
45+
if (!ciclo) {
46+
getEyeMatrix(eyeMat);
47+
orientacion = acos(eyeMat.m00);
48+
if (eyeMat.m02 < 0) orientacion =- orientacion;
49+
println(degrees(orientacion));
50+
}
51+
if (ciclo) {
52+
cam.setPosition(+(eyedist/2) * cos(orientacion), 100, 500 + (eyedist/2) * sin(orientacion));
53+
} else {
54+
cam.setPosition(-(eyedist/2) * cos(orientacion), 100, 500 - (eyedist/2) * sin(orientacion));
55+
}
56+
57+
pushMatrix();
58+
px = cx + cos(ang) * orbita;
59+
pz = cz + sin(ang) * orbita;
60+
translate(px, 100, pz);
61+
ang = ang + vorbita;
62+
rotateY(1.25);
63+
rotateX(-0.4);
64+
rotateZ(angulo); //angulo=angulo+0.01;
65+
noStroke();
66+
fill(251, 100, 10);
67+
box(100);
68+
popMatrix();
69+
70+
pushMatrix();
71+
translate(width/2, 100, cz);
72+
rotateY(1.25);
73+
rotateX(-0.4);
74+
rotateZ(angulo); //angulo=angulo+0.01;
75+
noStroke();
76+
fill(0, 200, 10);
77+
sphere(70);
78+
popMatrix();
79+
}
80+
81+
void mousePressed() {
82+
vorbita = 0;
83+
}
84+
85+
void mouseReleased() {
86+
vorbita = 0.01;
87+
}
88+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mode=Android
2+
component=vr
3+
mode.id=processing.mode.android.AndroidMode

0 commit comments

Comments
 (0)