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
Mostrar archivo Open project: stetro/project-tango-poc Class Usage Examples

Public Properties

Property Type Description
m_canvas Canvas
m_markPrefabs GameObject[]
m_pointCloud TangoPointCloud,
m_prefabTouchEffect UnityEngine.RectTransform
m_savingText UnityEngine.UI.Text

Public Methods

Method 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

Method 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 method

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

OnGUI() public method

Unity OnGUI function. Mainly for removing markers.
public OnGUI ( ) : void
return void

OnTangoDepthAvailable() public method

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.
return void

OnTangoEventAvailableEventHandler() public method

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

OnTangoPoseAvailable() public method

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.
return void

Save() public method

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
return void

SetCurrentMarkType() public method

Set the marker type.
public SetCurrentMarkType ( int type ) : void
type int Marker type.
return void

Start() public method

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

Update() public method

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

Property Details

m_canvas public_oe property

The canvas to place 2D game objects under.
public Canvas m_canvas
return Canvas

m_markPrefabs public_oe property

Prefabs of different colored markers.
public GameObject[] m_markPrefabs
return GameObject[]

m_pointCloud public_oe property

The point cloud object in the scene.
public TangoPointCloud, m_pointCloud
return TangoPointCloud,

m_prefabTouchEffect public_oe property

The touch effect to place on taps.
public RectTransform,UnityEngine m_prefabTouchEffect
return UnityEngine.RectTransform

m_savingText public_oe property

Saving progress UI text.
public Text,UnityEngine.UI m_savingText
return UnityEngine.UI.Text