C# Class 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.
Inheritance: MonoBehaviour, ITangoPose, ITangoEvent
Afficher le fichier Open project: stetro/project-tango-poc Class Usage Examples

Méthodes publiques

Свойство Type Description
m_canvas Canvas
m_markPrefabs GameObject[]
m_pointCloud TangoPointCloud,
m_prefabTouchEffect UnityEngine.RectTransform
m_savingText UnityEngine.UI.Text

Méthodes publiques

Méthode Description
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.

Private Methods

Méthode Description
_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.

Method Details

OnApplicationPause() public méthode

Applicaiton onPause / onResume callback.
public OnApplicationPause ( bool pauseStatus ) : void
pauseStatus bool true if the application about to pause, otherwise false.
Résultat void

OnGUI() public méthode

Unity OnGUI function. Mainly for removing markers.
public OnGUI ( ) : void
Résultat void

OnTangoDepthAvailable() public méthode

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.
Résultat void

OnTangoEventAvailableEventHandler() public méthode

This is called each time a Tango event happens.
public OnTangoEventAvailableEventHandler ( Tango tangoEvent ) : void
tangoEvent Tango Tango event.
Résultat void

OnTangoPoseAvailable() public méthode

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.
Résultat void

Save() public méthode

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
Résultat void

SetCurrentMarkType() public méthode

Set the marker type.
public SetCurrentMarkType ( int type ) : void
type int Marker type.
Résultat void

Start() public méthode

Unity Start function. We find and assign pose controller and tango applicaiton, and register this class to callback events.
public Start ( ) : void
Résultat void

Update() public méthode

Unity Update function. Mainly handle the touch event and place mark in place.
public Update ( ) : void
Résultat void

Property Details

m_canvas public_oe property

The canvas to place 2D game objects under.
public Canvas m_canvas
Résultat Canvas

m_markPrefabs public_oe property

Prefabs of different colored markers.
public GameObject[] m_markPrefabs
Résultat GameObject[]

m_pointCloud public_oe property

The point cloud object in the scene.
public TangoPointCloud, m_pointCloud
Résultat TangoPointCloud,

m_prefabTouchEffect public_oe property

The touch effect to place on taps.
public RectTransform,UnityEngine m_prefabTouchEffect
Résultat UnityEngine.RectTransform

m_savingText public_oe property

Saving progress UI text.
public Text,UnityEngine.UI m_savingText
Résultat UnityEngine.UI.Text