[Go to site: main page, start]

Processing for Android

EN ES

ARTrackable

This class provides methods to query the status of a trackable surface. Anchors are attached to a trackable.

  • String id()

    A unique string ID for the trackable.

  • PMatrix3D matrix()

    It returns the pose matrix associated to this trackable.

  • transform()

    Applies the pose matrix to the scene.

  • float[] getPolygon()

    Returns the list of points [x0, z0, x1, z1...] defining the current boundary of the trackable (it can change from frame to frame).

  • float lengthX()

    Returns the total extent of the trackable along X.

  • float lengthY()

    Returns the total extent of the trackable along Y

  • float lengthZ()

    Returns the total extent of the trackable along Z

  • boolean isSelected()

    Returns true if the trackable is selected.

  • boolean isNew()

    Returns true if this is a trackable detected in the last frame.

  • boolean isTracking()

    Returns true if the trackable is being tracked.

  • boolean isPaused()

    Returns true if the tracking of this trackable is currently paused.

  • boolean isStopped()

    Returns true if the tracking of this trackable is stopped, if so, the trackable will be automatically removed in the next frame.

  • boolean isPlane()

    Returns true if the trackable is a plane.

  • boolean isPointCloud()

    Returns true if the trackable is a point cloud.

  • boolean isFloorPlane()

    Returns true if the trackable is a floor plane.

  • boolean isFloorPlane()

    Returns true if the trackable is a ceiling plane.

  • boolean isWallPlane()

    Returns true if the trackable is a wall plane.


import processing.ar.*;

ARTracker tracker;

void setup() {
  fullScreen(AR);
  tracker = new ARTracker(this);
  tracker.start();
}

void draw() {
  lights();

  // Draw trackable planes
  for (int i = 0; i < tracker.count(); i++) {
    ARTrackable trackable = tracker.get(i);
    if (!trackable.isTracking()) continue;

    pushMatrix();
    trackable.transform();
    if (mousePressed && trackable.isSelected(mouseX, mouseY)) {
      fill(255, 0, 0, 100);
    } else {
      fill(255, 100);
    }

    beginShape(QUADS);
    float lx = trackable.lengthX();
    float lz = trackable.lengthZ();
    vertex(-lx/2, 0, -lz/2);
    vertex(-lx/2, 0, +lz/2);
    vertex(+lx/2, 0, +lz/2);
    vertex(+lx/2, 0, -lz/2);
    endShape();
    popMatrix();
  }
}