Skip to content

Commit a974b50

Browse files
committed
updated ar examples
1 parent 0c3ca97 commit a974b50

File tree

6 files changed

+102
-28
lines changed

6 files changed

+102
-28
lines changed

debug/apps/arscene/src/main/java/arscene/Sketch.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public void draw() {
6565
if (mousePressed) {
6666
oldSelAnchor = selAnchor;
6767
selAnchor = createAnchor(mouseX, mouseY);
68-
System.out.println("-------------> CREATED TOUCH ANCHOR " + selAnchor);
6968
}
7069

7170
for (int i = 0; i < anchorCount(); i++) {
@@ -77,7 +76,6 @@ public void draw() {
7776

7877
int status = anchorStatus(i);
7978
if (status == PAR.PAUSED || status == PAR.STOPPED) {
80-
if (status == PAR.PAUSED) System.out.println("-------------> PAUSED ANCHOR " + i);
8179
if (status == PAR.STOPPED) deleteAnchor(i);
8280
continue;
8381
}
@@ -93,11 +91,6 @@ public void draw() {
9391

9492
rotateY(angle);
9593
box(0.15f);
96-
// noStroke();
97-
// sphere(0.10f);
98-
// rotateZ(angle);
99-
// translate(0, 0.3f, 0);
100-
// sphere(0.05f);
10194
popMatrix();
10295
}
10396

mode/libraries/ar/examples/Cube/Cube.pde

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import processing.ar.*;
2+
3+
float[] points;
4+
PMatrix3D mat;
5+
float angle;
6+
int oldSelAnchor;
7+
int selAnchor;
8+
9+
void setup() {
10+
fullScreen(AR);
11+
mat = new PMatrix3D();
12+
}
13+
14+
void draw() {
15+
// The AR Core session, frame and camera can be accessed through Processing's surface object
16+
// to obtain the full information about the AR scene:
17+
// PSurfaceAR surface = (PSurfaceAR) getSurface();
18+
// surface.camera.getPose();
19+
// surface.frame.getLightEstimate();
20+
21+
// No background call is needed, the screen is refreshed each frame with the image from the camera
22+
23+
lights();
24+
25+
26+
for (int i = 0; i < trackableCount(); i++) {
27+
int status = trackableStatus(i);
28+
if (status == PAR.PAUSED || status == PAR.STOPPED) continue;
29+
30+
if (status == PAR.CREATED && trackableCount() < 10) {
31+
if (trackableType(i) == PAR.PLANE_WALL) {
32+
createAnchor(i, 0.3, 0, 0);
33+
} else {
34+
createAnchor(i, 0, 0.3, 0);
35+
}
36+
}
37+
38+
points = getTrackablePolygon(i, points);
39+
40+
getTrackableMatrix(i, mat);
41+
pushMatrix();
42+
applyMatrix(mat);
43+
if (trackableSelected(i, mouseX, mouseY)) {
44+
fill(255, 0, 0, 100);
45+
} else {
46+
fill(255, 100);
47+
}
48+
49+
beginShape();
50+
for (int n = 0; n < points.length/2; n++) {
51+
float x = points[2 * n];
52+
float z = points[2 * n + 1];
53+
vertex(x, 0, z);
54+
}
55+
endShape();
56+
popMatrix();
57+
}
58+
59+
if (mousePressed) {
60+
oldSelAnchor = selAnchor;
61+
selAnchor = createAnchor(mouseX, mouseY);
62+
}
63+
64+
for (int i = 0; i < anchorCount(); i++) {
65+
int id = anchorId(i);
66+
if (oldSelAnchor == id) {
67+
deleteAnchor(i);
68+
continue;
69+
}
70+
71+
int status = anchorStatus(i);
72+
if (status == PAR.PAUSED || status == PAR.STOPPED) {
73+
if (status == PAR.STOPPED) deleteAnchor(i);
74+
continue;
75+
}
76+
77+
pushMatrix();
78+
anchor(i);
79+
80+
if (selAnchor == id) {
81+
fill(255, 0, 0);
82+
} else {
83+
fill(255);
84+
}
85+
86+
rotateY(angle);
87+
box(0.15);
88+
popMatrix();
89+
}
90+
91+
angle += 0.1;
92+
}

mode/libraries/ar/examples/ImportObj/ImportObj.pde

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ PShape arObj;
44

55
void setup() {
66
fullScreen(AR);
7-
8-
// Setting Color of the detected plane - BLUE in this case
9-
PAR.planeColor(#BCD4FF);
10-
117
arObj = loadShape("model.obj");
128
}
139

1410
void draw() {
1511
lights();
16-
background(0);
12+
1713
if (mousePressed) {
18-
// Placing the AR object on encountering touch events
14+
// Delete the old touch anchor, if any.
15+
if (0 < anchorCount()) deleteAnchor(0);
16+
17+
// Create a new anchor at the current touch position.
18+
createAnchor(mouseX, mouseY);
19+
}
20+
21+
if (0 < anchorCount()) {
22+
anchor(0);
1923
shape(arObj);
2024
}
2125
}

0 commit comments

Comments
 (0)