C# Класс AreaLearningInGameController, project-tango-poc

AreaLearningGUIController is responsible for the main game interaction. This class also takes care of loading / save persistent data(marker), and loop closure handling.
Наследование: MonoBehaviour, ITangoPose, ITangoEvent
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
m_canvas Canvas
m_markPrefabs GameObject[]
m_pointCloud TangoPointCloud,
m_prefabTouchEffect UnityEngine.RectTransform
m_savingText UnityEngine.UI.Text

Открытые методы

Метод Описание
OnApplicationPause ( bool pauseStatus ) : void

Applicaiton onPause / onResume callback.

OnGUI ( ) : void

Unity OnGUI function. Mainly for removing markers.

OnTangoDepthAvailable ( TangoUnityDepth tangoDepth ) : void

This is called each time new depth data is available. On the Tango tablet, the depth callback occurs at 5 Hz.

OnTangoEventAvailableEventHandler ( Tango tangoEvent ) : void

This is called each time a Tango event happens.

OnTangoPoseAvailable ( Tango poseData ) : void

OnTangoPoseAvailable event from Tango. In this function, we only listen to the Start-Of-Service with respect to Area-Description frame pair. This pair indicates a relocalization or loop closure event happened, base on that, we either start the initialize the interaction or do a bundle adjustment for all marker position.

Save ( ) : void

Save the game. Save will trigger 3 things: 1. Save the Area Description if the learning mode is on. 2. Bundle adjustment for all markers's position, please see _UpdateMarkersForLoopClosures() function header for more details. 3. Save all markers to xml, save the Area Description if the learning mode is on. 4. Reload the scene.

SetCurrentMarkType ( int type ) : void

Set the marker type.

Start ( ) : void

Unity Start function. We find and assign pose controller and tango applicaiton, and register this class to callback events.

Update ( ) : void

Unity Update function. Mainly handle the touch event and place mark in place.

Приватные методы

Метод Описание
_DoSaveCurrentAreaDescription ( ) : IEnumerator

Actually do the Area Description save.

_LoadMarkerFromDisk ( ) : void

Load marker list xml from application storage.

_SaveMarkerToDisk ( ) : void

Write marker list to an xml file stored in application storage.

_UpdateMarkersForLoopClosures ( ) : void

Correct all saved marks when loop closure happens. When Tango Service is in learning mode, the drift will accumulate overtime, but when the system sees a pre-exsiting area, it will do a operation to correct all previously saved poses (the pose you can query with GetPoseAtTime). This operation is called loop closure. When loop closure happens, we will need to re-query all previously saved marker position in order to achieve the best result. This function is doing the querying job based on timestamp.

_WaitForDepthAndFindPlane ( Vector2 touchPosition ) : IEnumerator

Wait for the next depth update, then find the plane at the touch position.

_WorldBoundsToScreen ( Camera cam, Bounds bounds ) : Rect

Convert a 3D bounding box into a 2D Rect.

Описание методов

OnApplicationPause() публичный Метод

Applicaiton onPause / onResume callback.
public OnApplicationPause ( bool pauseStatus ) : void
pauseStatus bool true if the application about to pause, otherwise false.
Результат void

OnGUI() публичный Метод

Unity OnGUI function. Mainly for removing markers.
public OnGUI ( ) : void
Результат void

OnTangoDepthAvailable() публичный Метод

This is called each time new depth data is available. On the Tango tablet, the depth callback occurs at 5 Hz.
public OnTangoDepthAvailable ( TangoUnityDepth tangoDepth ) : void
tangoDepth Tango.TangoUnityDepth Tango depth.
Результат void

OnTangoEventAvailableEventHandler() публичный Метод

This is called each time a Tango event happens.
public OnTangoEventAvailableEventHandler ( Tango tangoEvent ) : void
tangoEvent Tango Tango event.
Результат void

OnTangoPoseAvailable() публичный Метод

OnTangoPoseAvailable event from Tango. In this function, we only listen to the Start-Of-Service with respect to Area-Description frame pair. This pair indicates a relocalization or loop closure event happened, base on that, we either start the initialize the interaction or do a bundle adjustment for all marker position.
public OnTangoPoseAvailable ( Tango poseData ) : void
poseData Tango Returned pose data from TangoService.
Результат void

Save() публичный Метод

Save the game. Save will trigger 3 things: 1. Save the Area Description if the learning mode is on. 2. Bundle adjustment for all markers's position, please see _UpdateMarkersForLoopClosures() function header for more details. 3. Save all markers to xml, save the Area Description if the learning mode is on. 4. Reload the scene.
public Save ( ) : void
Результат void

SetCurrentMarkType() публичный Метод

Set the marker type.
public SetCurrentMarkType ( int type ) : void
type int Marker type.
Результат void

Start() публичный Метод

Unity Start function. We find and assign pose controller and tango applicaiton, and register this class to callback events.
public Start ( ) : void
Результат void

Update() публичный Метод

Unity Update function. Mainly handle the touch event and place mark in place.
public Update ( ) : void
Результат void

Описание свойств

m_canvas публичное свойство

The canvas to place 2D game objects under.
public Canvas m_canvas
Результат Canvas

m_markPrefabs публичное свойство

Prefabs of different colored markers.
public GameObject[] m_markPrefabs
Результат GameObject[]

m_pointCloud публичное свойство

The point cloud object in the scene.
public TangoPointCloud, m_pointCloud
Результат TangoPointCloud,

m_prefabTouchEffect публичное свойство

The touch effect to place on taps.
public RectTransform,UnityEngine m_prefabTouchEffect
Результат UnityEngine.RectTransform

m_savingText публичное свойство

Saving progress UI text.
public Text,UnityEngine.UI m_savingText
Результат UnityEngine.UI.Text