augmented reality - Local Area Description: Learning -
i've started learning google tango , having troubles in understanding how implement local area description learning. have followed 1 of how-to-guides documentation, 1 placing virtual objects in ar , wanted app remember places kittens placed. attach scene unity , script i've tried enable savecurrent method areadescription. the scene unity , following code 1 how-to-guide have tried create thread saving current areadescription
public class kittyuicontroller : monobehaviour { thread thread; public gameobject m_kitten; private tangopointcloud m_pointcloud; void start() { m_pointcloud = findobjectoftype<tangopointcloud>(); thread = new thread(thread123); } void update() { if (input.touchcount == 1) { // trigger place kitten function when single touch ended. touch t = input.gettouch(0); if (t.phase == touchphase.ended) { placekitten(t.position); thread.start(); } } } void placekitten(vector2 touchposition) { // find plane. camera cam = camera.main; vector3 planecenter; plane plane; if (!m_pointcloud.findplane(cam, touchposition, out planecenter, out plane)) { debug.log("cannot find plane."); return; } // place kitten on surface, , make face camera. if (vector3.angle(plane.normal, vector3.up) < 30.0f) { vector3 = plane.normal; vector3 right = vector3.cross(plane.normal, cam.transform.forward).normalized; vector3 forward = vector3.cross(right, plane.normal).normalized; instantiate(m_kitten, planecenter, quaternion.lookrotation(forward, up)); } else { debug.log("surface steep kitten stand on."); } } void thread123() { areadescription.savecurrent(); } public void onapplicationquit() { thread.abort(); }
}
i don't have enough reputation points comment post answer here. should provide more details working, , not.
first, start this page, because need set arealearning in app. then, examine this code , corresponding arealearning scene example, need want want do.
something not in turorial nor in code, , important make work need check "use area description" in "tango ar pose controller" of "tango ar camera" prefab (or tango camera, if using latest sdk's prefab), otherwise objects won't placed regarding adf base frame.
if had sum up, workflow is:
- load existing adf (in learning mode or not) or start learning new one.
- if existing adf loaded, relocalize (if load adf in learning mode, can take longer time)
- once relocalized, load xml storing objects (in cas kittens). xml have same name adf's uuid , stored in application.persistentdatapath (android/data/com.yourapp/files). loaded objects placed regarding adf base frame.
- for each new kitten place, record timestamp when place it. time stamp allow recover transformation between frame when placed kitten , adf base frame.
- when save xml, transformation, able save cordinates of kitten regarding adf base frame (in example, transformation computed in _updatemarkersforloopclosures).
in example, reload scene after save, go areadescriptionpicker screen decide how want this.
i don't know more say. hope helps.
wiki
Comments
Post a Comment