Augmented Reality | Help!

Hi All,

I’m working with ar within Processing for Android’s framework and I seem to have gotten stuck. I’ve utilized Andres Colubri’s [fantastic] tutorials at android.processing.org as well as the included ar tutorials included with Processing’s ar library to create an incredibly simple implementation of ar:

import processing.ar.*;

ARTracker tracker;
ARAnchor anchor;

float angle;

void setup(){
fullScreen(AR);

tracker = new ARTracker(this);
tracker.start();

fill(37, 148, 179);

}

void draw(){
lights();

if (mousePressed){
//create new anchor at the current touch point
if (anchor != null) anchor.dispose();
ARTrackable hit = tracker.get(mouseX, mouseY);
if (hit != null) anchor = new ARAnchor (hit);
else anchor = null;
}

if (anchor != null){
anchor.attach();
rotateY(radians(angle));
box(.1);
anchor.detach();
}

angle = angle + 1;

}

With the above code, I’m able to place a rotating cube on an x, y, z coordinate within a particular physical space - I haven’t bothered with drawing trackable planes because I don’t believe it to be necessary for what I’m trying to achieve.

My Question: How can I add multiple objects (in this case, cubes) to the scene? I’d love to be able to anchor 3-4 objects to x, y, z coordinates that can then be further manipulated or animated.

I feel it has something to do with detaching the anchor, however when I removed the anchor.detach() function the app crashed on me.

Any help or nudge in the right direction will be greatly appreciated :slightly_smiling_face:

Thank You!!!

-Brittney

For anyone who’s interested, Andres Colubri created another example sketch demonstrating how to create multiple anchors and touch events. Feel free to check out the example here: