This is a more advanced movement controller based on the poses returned from the Tango service. This updates the position with deltas, so movement can be done using a CharacterController, or physics, or anything else that wants deltas.
Inheritance: MonoBehaviour, ITangoPose
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();
        m_tangoApplication.Register(this);
        m_tangoDeltaPoseController = FindObjectOfType <TangoDeltaPoseController>();
        m_unityWorldTStartService.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_colorCameraTUnityCamera.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(1, new Vector4(0.0f, -1.0f, 0.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(2, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Assign triangles, note: this is just for visualizing point in the mesh data.
        m_points = new Vector3[MAX_POINT_COUNT];

        m_mesh = GetComponent <MeshFilter>().mesh;
        m_mesh.Clear();

        m_renderer = GetComponent <Renderer>();
        m_rand     = new System.Random();
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Awake is called when the script instance is being loaded.
    /// </summary>
    public void Awake()
    {
        if (Player == null)
        {
            Player = this;
        }

        // Constant matrix converting start of service frame to Unity world frame.
        m_uwTss = new Matrix4x4();
        m_uwTss.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_uwTss.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_dTuc = new Matrix4x4();
        m_dTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(2, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
        m_dTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_poseDeltaTime     = -1.0f;
        m_poseTimestamp     = -1.0f;
        m_poseCount         = -1;
        m_poseStatus        = TangoEnums.TangoPoseStatusType.NA;
        m_prevTangoRotation = m_tangoRotation = Quaternion.identity;
        m_prevTangoPosition = m_tangoPosition = Vector3.zero;

        m_uwTuc       = Matrix4x4.identity;
        m_uwOffsetTuw = Matrix4x4.identity;
    }
Ejemplo n.º 3
0
    /// @cond
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();
        m_tangoApplication.Register(this);
        m_tangoDeltaPoseController = FindObjectOfType <TangoDeltaPoseController>();
        m_unityWorldTStartService.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_colorCameraTUnityCamera.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(1, new Vector4(0.0f, -1.0f, 0.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(2, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Assign triangles, note: this is just for visualizing point in the mesh data.
        m_points = new Vector3[MAX_POINT_COUNT];

        m_mesh = GetComponent <MeshFilter>().mesh;
        m_mesh.Clear();

        // Points used for finding floor plane.
        m_numPointsAtY    = new Dictionary <float, int>();
        m_nonNoiseBuckets = new List <float>();

        m_renderer = GetComponent <Renderer>();
    }
    /// <summary>
    /// Inspector GUI event for immediate-mode Editor GUI.
    /// </summary>
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        TangoDeltaPoseController inspectedObject = (TangoDeltaPoseController)target;

        if (TangoPrefabInspectorHelper.CheckForTangoApplication(inspectedObject, ref m_tangoApplication))
        {
            TangoPrefabInspectorHelper.CheckMotionTrackingPermissions(m_tangoApplication);

            TangoPrefabInspectorHelper.CheckAreaDescriptionPermissions(m_tangoApplication,
                                                                       inspectedObject.m_useAreaDescriptionPose);
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Start is used to initialize.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();
        m_dynamicMesh      = FindObjectOfType <TangoDynamicMesh>();
        m_exporter         = new Exporter();
        m_tangoCamera      = FindObjectOfType <TangoMultiCamera>();
        m_poseController   = FindObjectOfType <TangoDeltaPoseController>();
        LineRenderer lineRenderer = gameObject.AddComponent <LineRenderer>();
        Material     lineMat      = Resources.Load("Line", typeof(Material)) as Material;

        lineRenderer.material = lineMat;
        lineRenderer.SetWidth(0.01F, 0.01F);
        lineRenderer.SetVertexCount(2);
        lineRenderer.SetPosition(0, measurePointStart.transform.position);
        lineRenderer.SetPosition(1, measurePointEnd.transform.position);
    }
Ejemplo n.º 6
0
    /// @cond
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();
        m_tangoApplication.Register(this);

        m_tangoDeltaPoseController = FindObjectOfType <TangoDeltaPoseController>();

        // Assign triangles, note: this is just for visualizing point in the mesh data.
        m_points = new Vector3[MAX_POINT_COUNT];

        m_mesh = GetComponent <MeshFilter>().mesh;
        m_mesh.Clear();

        // Points used for finding floor plane.
        m_numPointsAtY    = new Dictionary <float, int>();
        m_nonNoiseBuckets = new List <float>();

        m_renderer = GetComponent <Renderer>();
    }
    /// <summary>
    /// Unity Start function.
    ///
    /// We find and assign pose controller and tango applicaiton, and register this class to callback events.
    /// </summary>
    public void Start()
    {
        // Constant matrix converting start of service frame to Unity world frame.
        m_uwTss = new Matrix4x4();
        m_uwTss.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_uwTss.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_dTuc = new Matrix4x4();
        m_dTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(2, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
        m_dTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_deltaPoseController = FindObjectOfType <TangoDeltaPoseController>();
        m_tangoApplication    = FindObjectOfType <TangoApplication>();

        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType<TangoApplication>();
        m_tangoApplication.Register(this);
        m_tangoDeltaPoseController = FindObjectOfType<TangoDeltaPoseController>();
        m_unityWorldTStartService.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Assign triangles, note: this is just for visualizing point in the mesh data.
        m_points = new Vector3[MAX_POINT_COUNT];

        m_mesh = GetComponent<MeshFilter>().mesh;
        m_mesh.Clear();

        m_renderer = GetComponent<Renderer>();
        m_rand = new System.Random();
    }
Ejemplo n.º 9
0
    /// @cond
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start() 
    {
        m_tangoApplication = FindObjectOfType<TangoApplication>();
        m_tangoApplication.Register(this);
        m_tangoDeltaPoseController = FindObjectOfType<TangoDeltaPoseController>();
        m_unityWorldTStartService.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_unityWorldTStartService.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_colorCameraTUnityCamera.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(1, new Vector4(0.0f, -1.0f, 0.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(2, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_colorCameraTUnityCamera.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
        
        // Assign triangles, note: this is just for visualizing point in the mesh data.
        m_points = new Vector3[MAX_POINT_COUNT];

        m_mesh = GetComponent<MeshFilter>().mesh;
        m_mesh.Clear();

        // Points used for finding floor plane.
        m_numPointsAtY = new Dictionary<float, int>();
        m_nonNoiseBuckets = new List<float>();

        m_renderer = GetComponent<Renderer>();
    }
    /// <summary>
    /// Unity Start function.
    /// 
    /// We find and assign pose controller and tango applicaiton, and register this class to callback events.
    /// </summary>
    public void Start()
    {
        // Constant matrix converting start of service frame to Unity world frame.
        m_uwTss = new Matrix4x4();
        m_uwTss.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_uwTss.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_dTuc = new Matrix4x4();
        m_dTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(2, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
        m_dTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_deltaPoseController = FindObjectOfType<TangoDeltaPoseController>();
        m_tangoApplication = FindObjectOfType<TangoApplication>();
        
        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Awake is called when the script instance is being loaded.
    /// </summary>
    public void Awake()
    {
        if (Player == null)
            Player = this;

        // Constant matrix converting start of service frame to Unity world frame.
        m_uwTss = new Matrix4x4();
        m_uwTss.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(1, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        m_uwTss.SetColumn(2, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_uwTss.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        // Constant matrix converting Unity world frame frame to device frame.
        m_dTuc = new Matrix4x4();
        m_dTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(1, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
        m_dTuc.SetColumn(2, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
        m_dTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_poseDeltaTime = -1.0f;
        m_poseTimestamp = -1.0f;
        m_poseCount = -1;
        m_poseStatus = TangoEnums.TangoPoseStatusType.NA;
        m_prevTangoRotation = m_tangoRotation = Quaternion.identity;
        m_prevTangoPosition = m_tangoPosition = Vector3.zero;

        m_uwTuc = Matrix4x4.identity;
        m_uwOffsetTuw = Matrix4x4.identity;
    }
Ejemplo n.º 12
0
 void Awake()
 {
     source                   = GetComponent <AudioSource>();
     tengoPointCloud          = gameObject.GetComponent <TangoPointCloud>();
     tangoDeltaPoseController = GameObject.Find("Tango Delta Camera").GetComponent <TangoDeltaPoseController>();
 }