Instant Tracker

The Instant Tracker instantly scans the planar surface in the camera frame and recognizes the space with sensors. You can find the rendered 3D object on the space.

Starting / Stopping the Tracker
Using the Tracking Information
Creating the Instant Target Data

Starting / Stopping the Tracker

To start / stop Tracker, refer to the following code.

InstantTrackerViewController.mm

- (void)resumeAR
{
    ...
    TrackerManager::getInstance()->startTracker(TRACKER_TYPE_INSTANT);
}

- (void)pauseAR
{
    TrackerManager::getInstance()->stopTracker();
    ...
}

Using the Tracking Information

To augment an object using Tracking results, refer to the following code.

InstantTrackerViewController.mm

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
    ...
    gl_helper::Mat4 projectionMatrix = BackgroundRenderer::getInstance()->getProjectionMatrix();
    maxstAR::ITrackingResult *result = &TrackerManager::getInstance()->getTrackingResult();
    
    for (int i = 0; i < (int)result->getCount(); i++)
    {
        maxstAR::ITrackable *trackable = result->getTrackable(i);
        
        gl_helper::Mat4 pose = trackable->getPose();
        pose = projectionMatrix * pose;
        
        texturedCube->setTransform(pose);
        texturedCube->setPosition(panTranslateX, panTranslateY, -0.05f);
        texturedCube->setRotation(rotateValue, 0.0f, 0.0f, 1.0f);
        texturedCube->setScale(0.3f + pinchScale, 0.3f + pinchScale, 0.01f);
        texturedCube->draw();
    }
    ...
}

Creating the Instant Target Data

You can create new data only when it is not in Tracking state. Refer to the following code.

InstantTrackerViewController.mm

- (IBAction)doTrackingState:(id)sender {
    UIButton *button = (UIButton*)sender;
    
    if([[[button titleLabel] text]  isEqual: @"Start Tracking"])
    {
        beforeTranslateX = 0.0f;
        beforeTranslateY = 0.0f;
        panTranslateX = 0.0f;
        panTranslateY = 0.0f;
        pinchScale = 0.0f;
        rotateValue = 0.0f;
        TrackerManager::getInstance()->findSurface();
        [button setTitle:@"Stop Tracking" forState:UIControlStateNormal];
    }
    else if([[[button titleLabel] text]  isEqual: @"Stop Tracking"])
    {
        TrackerManager::getInstance()->quitFindingSurface();
        [button setTitle:@"Start Tracking" forState:UIControlStateNormal];
    }
}