ArbiTrack Basics iOS

From Kudan AR Engine
Jump to: navigation, search

This tutorial will go through the basics of using Kudan’s ArbiTrack feature. This will lead on from our previous tutorial previous tutorial which described how to add content to a marker. If you have not already set up a project where you place content onto a marker, we suggest you check it out before going any further.

For this sample we have used:

  • Model : ben.armodel / ben.jet
  • Model Texture : bigBenTexture.png
  • Target Node : target.png

Which can all be downloaded here.

Initialise ArbiTrack and the Gyro Placement Manager

ArbiTrack and the Gyro Placement Manager will need to be initialised before they can be used. As they are singletons they can be called using getInstance from anywhere in the program. The Gyro Placement Manager uses your device’s gyro to position a node and ArbiTrack locks your model in place instantly, by keeping track of arbitrary feature points.

Note: ArbiTrack relies on having a large number of feature points in the environment to track correctly. If you are in a low feature environment, this can cause tracking to become less consistent.

// Initialise ArbiTrack
ARArbiTrackerManager *arbiTrack = [ARArbiTrackerManager getInstance];
[arbiTrack initialise];
 
// Initialise gyro placement. Gyro placement positions content on a virtual floor plane where the device is aiming.
ARGyroPlaceManager *gyroPlaceManager = [ARGyroPlaceManager getInstance];
[gyroPlaceManager initialise];


Create Target Node

To position your model you will need to use a target node. As the target node’s position is altered by the Gyro Placement Manager, it is useful to have a graphical representation of where the target node is. Anything can be used as a target, even the model itself, since the target is itself an ARNode. We will be using a red rectangle image for our target.

// Add a visual reticule to the target node for the user.
ARImageNode *targetImageNode = [[ARImageNode alloc] initWithImage:[UIImage imageNamed:@"target.png"]];
[gyroPlaceManager.world addChild:targetImageNode];
 
// Scale and rotate the image to the correct transformation.
[targetImageNode scaleByUniform:0.3];
[targetImageNode rotateByDegrees:90 axisX:1 y:0 z:0];
 
// Set the ArbiTracker target node to the node moved by the user.
arbiTrack.targetNode = targetImageNode;


Start ArbiTrack

Starting ArbiTrack will lock your model in place. You may also wish to hide your target node as it will not reposition your model until ArbiTrack has been stopped.

//Start ArbiTrack
[arbiTrack start];
 
//Hide target node
arbiTrack.targetNode.visible = NO;
 
//Change enum and label to reflect ArbiTrack state
__arbiButtonState = ARBI_TRACKING;


Stopping ArbiTrack

You may wish to reposition your model. In order to do this, you will need to stop ArbiTrack and re-enable your target node. You can start ArbiTrack again after this and your model will be locked to the new position of the target node.

// Display target node
arbiTrack.targetNode.visible = YES;
 
// Stop ArbiTrack
[arbiTrack stop];
 
//Change enum and label to reflect ArbiTrack state
__arbiButtonState = ARBI_PLACEMENT;