Skip to content

Commit 7d9fb56

Browse files
committed
added drawAim example
1 parent d636cc6 commit 7d9fb56

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
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
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import processing.vr.*;
2+
3+
float[] r1, r2;
4+
5+
void setup() {
6+
fullScreen(PVR.STEREO);
7+
//size(1920, 1080, P3D);
8+
r1 = new float[100];
9+
r2 = new float[100];
10+
for (int i = 0; i < 100; i++) {
11+
r1[i] = random(0, 1);
12+
r2[i] = random(0, 1);
13+
}
14+
}
15+
16+
void draw() {
17+
background(150);
18+
PGraphicsVR pvr = (PGraphicsVR)g;
19+
20+
// Some lights
21+
pointLight(255, 255, 255, pvr.cameraX, pvr.cameraY, pvr.cameraZ);
22+
23+
// Floor
24+
beginShape(QUADS);
25+
fill(255, 0, 0);
26+
normal(0, 0, +1);
27+
vertex(-width/2, -500, -width/2);
28+
fill(0, 0, 255);
29+
vertex(-width/2, -500, +width/2);
30+
vertex(+width/2, -500, +width/2);
31+
fill(255, 0, 0);
32+
vertex(+width/2, -500, -width/2);
33+
endShape();
34+
35+
pushMatrix();
36+
rotateY(millis()/1000.0);
37+
fill(220);
38+
box(200);
39+
popMatrix();
40+
41+
// Red box, X axis
42+
pushMatrix();
43+
translate(200, 0, 0);
44+
fill(255, 0, 0);
45+
box(100);
46+
popMatrix();
47+
48+
// Green box, Y axis
49+
pushMatrix();
50+
translate(0, 200, 0);
51+
fill(0, 255, 0);
52+
box(100);
53+
popMatrix();
54+
55+
// Blue box, Z axis
56+
pushMatrix();
57+
translate(0, 0, 200);
58+
fill(0, 0, 255);
59+
box(100);
60+
popMatrix();
61+
62+
// Place the aim at 300 units from the camera eye
63+
float d = 300;
64+
float x = pvr.cameraX + d * pvr.forwardVector[0];
65+
float y = pvr.cameraY + d * pvr.forwardVector[1];
66+
float z = pvr.cameraZ + d * pvr.forwardVector[2];
67+
stroke(200, 50, 150);
68+
strokeWeight(50);
69+
point(x, y, z);
70+
noStroke();
71+
popMatrix();
72+
}

0 commit comments

Comments
 (0)