Marker Based Tracking Sample

 This is a sample project for using Marker based Tracking.
SDK:                      Metaio
Render Software:  Unity3D
AI (Unity Plugin):   R.A.I.N AI Engine
Script Language:    C#

Project FilesIf you are unfamiliar with Augmented Reality, this article could introduce AR to you

To Test the sample:
·
Make
sure you have a camera connected to your system, it is preferred if it is not
fixed. easier to control.
·
Make
sure to Print the makers from the location:”AssetStreamingAssetsTrackingSamples” t1.png & t2.png
·
Open
Unity3D with OpenGL Render mode, use the command “Unity.exe
-force-opengl”
·
Scene
is in “StreamingAssetsTrackingSamples” Folder Double click on it to
open the project
·
After
Opening the Scene:
·
Expand
MetaioSDK object
·
You
will find two objects with the name “MetaioTracker”
·
If
you click on any of them, you will see in the inspector tab  “Coordinate System ID” This
is the Id number which specify which Marker image is associated with this
marker.This information is predefined in the XML File
“TrackingData_MarkerlessFast”Located at the same folder as the markers
“AssetStreamingAssetsTrackingSamples”

·
If
you expand the “MetaioTracker” objects you will find:

o   in one of them

an object called “Max”

o   and in the other one

an object called “Tyrant Zombie”Those are the 3D models which they will appear when their parent tracker will
detect the associated Marker (pointing the camera to one of the printed
markers)

You can alternatively remove those models and add your own.

·
The
model “Max” can be controlled with the keyboard: Movement (W,S,A,D)
·
The
model “Tyrant Zombie” is associated with an AI system
o   if model “Max” get to his
sight rangehe will start following him
o   if model “Max” get to his
attack rangehe will start attacking him(at this sample no health system is not applied)
·
This sample has an issue:If the “Tyran Zombie” tries to switch his direction it model will be
flipped in a weird direction.I am suspecting this is due to the Up Vector and the way it is implemented in
the AI engine (R.A.I.N)because AI usually use “transform.LookAt” or
“Quaternion.LookRotation” and pass the default UpVector (0,1,0).

Assuming that UpVector is to parallel to the Y-Axis

But with this sample; Metaio SDK will keep changing the position of the markers
based on the camera movement so the look stable while we are moving it.

Thus UpVector is not (0,1,0) always!

I wrote small Script you can find it at this location
“Asset/TrackingSamples/AI.CS”

and attached to the “Tyrant Zombie” by default it is disabled
(because I am using the R.A.I.N engine)

The script  will make the “Tyrant Zombie” always toward at
“Max”.

In this script, I did not use the Default value for the UpVector but I kept
recalculating it for every frame from the Tracker position.

Therefore, I got more stable movement, and the “Tyrant Zombie” will
not flip.

·
To
test this script:
o   Expand “Tyrant Zombie”
Object and
o   Select AI object then disable it (the
check box Top-Left at the inspector).
o   Click on the “Tyrant Zombie”
object and
o   Click on the check box beside AI
script
·
Note:
I used UnityVS add in to make edit and view the code in Visual StudioYou may have to go to:
o   “Edit/Preferences”
o   “External Tools”

o   “External Script Editor”

to choose your preferred Editor.

Leave a Reply

Your email address will not be published. Required fields are marked *