bertt / tango

2 stars 0 forks source link

tango

Hardware

Lenovo Phab 2 Pro

Asus Zenfone AR

C samples

todo

Java samples

Unity3D

1] Installation Hello World

sample: 1_only_a_box

2] Demo motion tracking

sample: 2_motion_tracking

3] Demo list adfs

Sample: 3_list_adfs

using UnityEngine;
using Tango;

public class startup : MonoBehaviour, ITangoLifecycle
{
    private TangoApplication m_tangoApplication;
    // Use this for initialization
    void Start () {
        Debug.Log("ajax list adf startup" );

        m_tangoApplication = FindObjectOfType<TangoApplication>();
        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
            m_tangoApplication.RequestPermissions();
        }
    }

    // Update is called once per frame
    void Update () {

    }

    public void OnTangoPermissions(bool permissionsGranted)
    {
        if (permissionsGranted)
        {
            AreaDescription[] list = AreaDescription.GetList();

            if (list.Length > 0)
            {
                foreach (var adf in list)
                {
                    Debug.Log("ajax adf found:" + adf.m_uuid);
                }
            }
            else
            {
                // No Area Descriptions available.
                Debug.Log("ajax No area descriptions available.");
            }
        }
    }

    public void OnTangoServiceConnected()
    {
    }

    public void OnTangoServiceDisconnected()
    {
    }
}

4] Demo Area learning

Prerequisites: There should be an ADF available of same room you're now in. Otherwise no localisation is possble and the image will not disappear. Code loads the last available ADF file.

https://web.archive.org/web/20170326085044/https://developers.google.com/tango/apis/unity/unity-howto-area-learning

using System.Collections;
using UnityEngine;
using Tango;

public class AreaLearningStartup : MonoBehaviour, ITangoLifecycle
{
    private TangoApplication m_tangoApplication;

    public void Start()
    {
        m_tangoApplication = FindObjectOfType<TangoApplication>();
        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
            m_tangoApplication.RequestPermissions();
        }
    }

    public void OnTangoPermissions(bool permissionsGranted)
    {
        if (permissionsGranted)
        {
            AreaDescription[] list = AreaDescription.GetList();
            AreaDescription mostRecent = null;
            AreaDescription.Metadata mostRecentMetadata = null;
            if (list.Length > 0)
            {
                // Find and load the most recent Area Description
                mostRecent = list[0];
                mostRecentMetadata = mostRecent.GetMetadata();
                foreach (AreaDescription areaDescription in list)
                {
                    AreaDescription.Metadata metadata = areaDescription.GetMetadata();
                    if (metadata.m_dateTime > mostRecentMetadata.m_dateTime)
                    {
                        mostRecent = areaDescription;
                        mostRecentMetadata = metadata;
                    }
                }

                m_tangoApplication.Startup(mostRecent);
            }
            else
            {
                // No Area Descriptions available.
                Debug.Log("No area descriptions available.");
            }
        }
    }

    public void OnTangoServiceConnected()
    {
    }

    public void OnTangoServiceDisconnected()
    {
    }
}

UI -> canvas

Set image to: Assets -> Tango SDK -> examples -> common -> textures -> relocalize_screen

Click 'set native size'