Object Tracker

The Object Tracker loads the map file and renders 3D object on it.

Starting / Stopping the Tracker
Using the Tracking Information
Setting a Map
Adding / Replacing a Map

Starting / Stopping the Tracker

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

ObjectTrackerViewController.mm

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

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

Using the Tracking Information

To use the Tracking information, refer to the following code.

ObjectTrackerViewController.mm

- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
    ...
    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(0.0f, 0.0f, -0.0005f);
        texturedCube->setScale(0.4f, 0.4f, 0.001f);
        texturedCube->draw();
    }
    ...
}

Setting a Map

By calling addTrackerData () to register the map file and calling loadTrackerData (), Space can be tracked. To set a map, refer to the following code.

ObjectTrackerViewController.mm

- (void)startEngine
{
    ...
    TrackerManager::getInstance()->addTrackerData(std::string([objectTrackerMapPath UTF8String]));
    TrackerManager::getInstance()->loadTrackerData();
}

Adding / Replacing a Map

  1. Create a map file refer to Documentation > Map Manager.

  2. Copy the received map file to the desired path.

  3. Set a map.

  4. If you have an existing map file, call addTrackerData () and loadTrackerData () after calling TrackerManager::getInstance()->removeTrackerData().