Skip to content

Commit 9742570

Browse files
committed
updated raycasting examples
1 parent 86d562f commit 9742570

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

mode/libraries/vr/examples/IntersectsBox/IntersectsBox.pde

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ float rotAngle = 0;
77
void setup() {
88
fullScreen(VR);
99
cameraUp();
10-
VRCamera cam;
10+
cam = new VRCamera(this);
1111
}
1212

1313
void draw() {

mode/libraries/vr/examples/IntersectsPlane/IntersectsPlane.pde

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ float x, y;
66
void setup() {
77
fullScreen(VR);
88
cameraUp();
9-
VRCamera cam;
9+
cam = new VRCamera(this);
1010
}
1111

1212
void draw() {
1313
background(200, 0, 150);
1414

1515
cam.setPosition(0, 0, 400);
16-
fill(255,170,238);
17-
// plane(400, 400);
16+
fill(255, 170, 238);
17+
plane(400, 400);
1818
fill(255, 0, 0);
1919
translate(x, y, 0);
2020
PVector offset;
21-
if (intersectsBox(60)) {
21+
if (intersectsBox(60, 0, 0)) {
2222
translate(-x, -y, 0);
2323
fill(0, 0, 255);
2424
offset = intersectsPlane(0, 0);
@@ -27,4 +27,13 @@ void draw() {
2727
}
2828
translate(x, y, 0);
2929
box(60);
30+
}
31+
32+
void plane(float w, float d) {
33+
beginShape(QUADS);
34+
vertex(-w/2, -d/2);
35+
vertex(+w/2, -d/2);
36+
vertex(+w/2, +d/2);
37+
vertex(-w/2, +d/2);
38+
endShape();
3039
}

mode/libraries/vr/examples/IntersectsSphere/IntersectsSphere.pde

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ void setup() {
1818
void draw() {
1919
background(200, 0, 150);
2020

21+
lights();
22+
noStroke();
2123
cam.setPosition(0, 0, 400);
2224
for (int i = 0; i < 5; ++i) {
2325
push();
@@ -27,11 +29,14 @@ void draw() {
2729
fill(0, 0, 255);
2830
}
2931
sphere(70);
30-
// noLoop();
3132
pop();
3233
}
34+
3335
cam.sticky();
34-
circle(windowWidth/2, windowHeight/2, 25);
35-
// image(pg, -windowWidth/2, -windowHeight/2, windowWidth, windowHeight);
36+
strokeWeight(5 * displayDensity);
37+
stroke(0, 0, 255);
38+
noFill();
39+
translate(0, 0, 200);
40+
circle(0, 0, 50);
3641
cam.noSticky();
3742
}

0 commit comments

Comments
 (0)