public void showMarkerInfoPopup(MarkerData markerData)
    {
        //MarkersListController.Instance.closeMarkersMenu();
        MarkerAddPopupController.Instance.closeMarkerAddPopup();

        md = markerData;
        popUp.GetComponentInChildren <Text>().text = md.name;
        popUp.transform.FindChild("markerLatLon").GetComponent <Text>().text
            = "Lat: " + md.worldCoords.z + ", Lon: " + md.worldCoords.x + ", Alt: " + md.worldCoords.y;
        popUp.transform.FindChild("markerDate").GetComponent <Text>().text = markerData.dateAdded;
        popupMarkerInfoText.GetComponent <Text>().text = md.description;
        popUp.transform.FindChild("closeButton").GetComponent <Button>().onClick.AddListener(MarkerInfoPopUpController.Instance.closeMarkerInfoPopup);

        popUp.transform.FindChild("hideButton").GetComponent <Button>().onClick.AddListener(MarkerInfoPopUpController.Instance.toggleMarkerVisibility);

        if (md.acquiredOnline)
        {
            popUp.transform.FindChild("hideButton").gameObject.SetActive(false);
        }
        else
        {
            popUp.transform.FindChild("hideButton").gameObject.SetActive(true);
        }


        isDisplayed = true;
        popUp.SetActive(isDisplayed);
    }
Example #2
0
    /// <summary>
    /// Write marker list to an xml file stored in application storage.
    /// </summary>
    private void _SaveMarkerToDisk()
    {
        // Compose a XML data list.
        List <MarkerData> xmlDataList = new List <MarkerData>();

        foreach (GameObject obj in m_markerList)
        {
            // Add marks data to the list, we intentionally didn't add the timestamp, because the timestamp will not be
            // useful when the next time Tango Service is connected. The timestamp is only used for loop closure pose
            // correction in current Tango connection.
            MarkerData temp = new MarkerData();
            temp.m_type        = obj.GetComponent <ARMarker>().m_type;
            temp.m_position    = obj.transform.position;
            temp.m_orientation = obj.transform.rotation;
            xmlDataList.Add(temp);
        }

        string path       = Application.persistentDataPath + "/" + m_curAreaDescription.m_uuid + ".xml";
        var    serializer = new XmlSerializer(typeof(List <MarkerData>));

        using (var stream = new FileStream(path, FileMode.Create))
        {
            serializer.Serialize(stream, xmlDataList);
        }
    }
Example #3
0
    private void RemoveImpl(MarkerData data)
    {
        var info   = new MarkerPlayerInfo(1, 1, false);
        var player = markers_[data.id].GetComponent <Player>();
        var charge = markers_[data.id].GetComponent <ShotCharge>();

        if (player)
        {
            info.hp     = player.hp;
            info.isDead = player.isDead;
        }
        if (charge)
        {
            info.power = charge.power;
        }
        if (playerInfos_.ContainsKey(data.id))
        {
            playerInfos_[data.id] = info;
        }
        else
        {
            playerInfos_.Add(data.id, info);
        }

        if (markers_.ContainsKey(data.id))
        {
            Destroy(markers_[data.id].gameObject);
            markers_.Remove(data.id);
        }
        Sound.Play("MarkerLost");
    }
Example #4
0
    private void CreateImpl(MarkerData data)
    {
        if (!markers_.ContainsKey(data.id))
        {
            var gameObj = Instantiate(markerPrefab) as GameObject;
            gameObj.transform.SetParent(GlobalObjects.localStage.transform);
            var marker = gameObj.GetComponent <Marker>();
            markers_.Add(data.id, marker);
            Sound.Play("MarkerDetected");
        }

        Update(data);

        if (playerInfos_.ContainsKey(data.id))
        {
            var info   = playerInfos_[data.id];
            var player = markers_[data.id].GetComponent <Player>();
            var charge = markers_[data.id].GetComponent <ShotCharge>();
            if (player)
            {
                player.hp = info.hp;
                if (info.isDead)
                {
                    StartCoroutine(KillRevivalPlayer(player.gameObject));
                }
            }
            if (charge)
            {
                charge.power = info.power;
            }
        }
    }
Example #5
0
        private void DrawGetRectangle(List <MarkerData> stations, out Rectangle rc)
        {
            rc = new Rectangle(0, 7, 0x4e3, (int)this.CanvasRoot_ActualHeight);
            int        position = 0x7fffffff;
            int        num2     = -2147483648;
            MarkerData data     = null;

            foreach (MarkerData data2 in stations)
            {
                if (data2.Position < position)
                {
                    position = data2.Position;
                }
                if (data2.Position > num2)
                {
                    num2 = data2.Position;
                    data = data2;
                }
            }
            if (position != 0x7fffffff)
            {
                rc.X = position;
            }
            if (num2 != -2147483648)
            {
                rc.Width = num2 - rc.X;
            }
        }
    /// <summary>
    /// Gets the marker data.
    /// </summary>
    /// <returns>The marker data.</returns>
    public MarkerData GetMarkerData()
    {
        Transform trans = transform;
        Vector3 pos = trans.position;
        Vector3 scale = trans.localScale;

        Vector3 fwd = trans.forward * scale.z;
        Vector3 right = trans.right * scale.x;

        Vector3[] verts = new Vector3[4];
        verts[0] = pos + fwd + right;
        verts[1] = pos + fwd - right;
        verts[2] = pos - fwd - right;
        verts[3] = pos - fwd + right;

        MarkerData result = new MarkerData();

        result.verts = verts;
        result.ymin = pos.y -trans.localScale.y;
        result.ymax = pos.y + trans.localScale.y;
        result.area = Area;
        result.priority = Priority;

        return result;
    }
Example #7
0
 public void TestGetMarkerName01()
 {
     using (MarkerData markerData = MarkerDataFactory.CreateMarkerData01())
     {
         string str = markerData.GetMarkerName();
     }
 }
Example #8
0
 public void TestGetNewMarker01()
 {
     using (MarkerData markerData = MarkerDataFactory.CreateMarkerData01())
     {
         EtyMarker etyMarker = markerData.GetNewMarker();
     }
 }
Example #9
0
 private void DrawStation(MarkerData s, Rectangle rc)
 {
     if (s.Visible)
     {
         Line l = new Line();
         l.set_X1((double)s.Position);
         l.set_X2((double)s.Position);
         l.set_Y1((double)rc.Y);
         l.set_Y2(this.CanvasRoot_ActualHeight - rc.Y);
         l.set_Width(1251.0);
         l.set_Height(this.CanvasRoot_ActualHeight);
         if (s.Style == PositionMarkerStyle.MarkerStation)
         {
             l.set_StrokeThickness(2.0);
         }
         else if (s.Style == PositionMarkerStyle.MarkerIntermediateStop)
         {
             l.get_StrokeDashArray().Add(2.0);
             l.get_StrokeDashArray().Add(2.0);
             l.set_StrokeThickness(2.0);
         }
         else if (s.Style == PositionMarkerStyle.MarkerSegmentBorder)
         {
             l.set_StrokeThickness(1.0);
         }
         else
         {
             l.set_StrokeThickness(2.0);
         }
         l.set_Stroke(new SolidColorBrush(SilverlightHelper.ConvertToColor(s.Color)));
         this.LineAdjust1PixelsWidth(l);
         this.CanvasRoot.get_Children().Add(l);
     }
 }
Example #10
0
    public void ProfileAnalysis_SetupFrameBuckets_GeneratesExpectedValues()
    {
        var analysis = new ProfileAnalysis();

        var marker = new MarkerData("Test Marker");

        marker.presentOnFrameCount = 1;

        for (int i = 0; i < 20; ++i)
        {
            analysis.UpdateSummary(i, 1.0f * i);
        }

        analysis.SetupFrameBuckets(20);

        var summary = analysis.GetFrameSummary();

        Assert.IsTrue(2 == summary.buckets[0]);

        for (int i = 1; i < summary.buckets.Length - 1; ++i)
        {
            Assert.IsTrue(1 == summary.buckets[i]);
        }

        Assert.IsTrue(0 == summary.buckets[19]);
    }
    /// <summary>
    /// Save the game.
    ///
    /// Save will trigger 3 things:
    /// 1. Bundle adjustment for all marks position, please see _UpdateMarkersForLoopClosures() function header for
    ///     more details.
    /// 2. Save all marker to xml, save the Area Description if the learning mode is on.
    /// 3. Reload the scene.
    /// </summary>
    public void Save()
    {
        // We do a bundle adjustment to all the markers first, to make sure it's located at the most precise position.
        if (m_tangoApplication.m_enableAreaLearning)
        {
            _UpdateMarkersForLoopClosures();
        }

        // Compose a XML data list
        List <MarkerData> xmlDataList = new List <MarkerData>();

        foreach (GameObject obj in m_markerList)
        {
            // Add marks data to the list, we intentionally didn't add the timestamp, because the timestamp will not be
            // useful when the next time Tango Service is connected. The timestamp is only used for loop closure pose
            // correction in current Tango connection.
            MarkerData temp = new MarkerData();
            temp.m_type        = obj.GetComponent <ARMarker>().m_type;
            temp.m_position    = obj.transform.position;
            temp.m_orientation = obj.transform.rotation;
            xmlDataList.Add(temp);
        }

        // Disable interaction before saving.
        m_initialized = false;
        m_savingText.gameObject.SetActive(true);

        // Start saving process in another thread.
        ThreadStart work = delegate { _AsyncDataSaving(xmlDataList); };

        m_saveThread = new Thread(work);
        m_saveThread.Start();
    }
Example #12
0
    public void Update(MarkerData data)
    {
        if (float.IsNaN(data.pos.x) || float.IsNaN(data.pos.y) || float.IsNaN(data.pos.z))
        {
            return;
        }
        if (float.IsInfinity(data.pos.x) || float.IsInfinity(data.pos.y) || float.IsInfinity(data.pos.z))
        {
            return;
        }

        data_            = data;
        rawPos_          = data.pos;
        polygon_.polygon = data.polygon;
        polygon_.indices = data.indices;
        UpdateEdges(data.id, data.edges);
        UpdatePatterns(data.id, data.patterns);
        lostCount_ = 0;

        var dt = Time.time - lastTime_;

        if (dt == 0)
        {
            return;
        }

        velocity_      = (data.pos - prePos_) / dt;
        angleVelocity_ = (data.angle - preAngle_) / dt;
        currentAngle_  = preAngle_ = data.angle;
        prePos_        = rawPos_;
        lastTime_      = lastInterpTime_ = Time.time;
        ++updateCount_;
        interpCount_ = 0;
    }
Example #13
0
        private List <MarkerData> convertDataSetToClass(DataSet data)
        {
            var result = new List <MarkerData>();

            foreach (DataRow row in data.Tables[0].Rows)
            {
                MarkerData marker = new MarkerData();
                try
                {
                    marker.Owner      = row.Field <string>("OWNER");
                    marker.DocId      = row.Field <string>("DOCID");
                    marker.MarkerId   = row.Field <string>("MARKERID");
                    marker.MarkerType = row.Field <string>("MARKERTYPE");
                    // { position: {X:x, Y:y}, radius: {X:x, Y:y} }
                    marker.MarkerLoc = JsonConvert
                                       .DeserializeObject <MarkerLocation>(row.Field <string>("MARKERLOC"));
                    marker.ForeColor = row.Field <string>("FORECOLOR");
                    marker.BackColor = row.Field <string>("BACKCOLOR");

                    result.Add(marker);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(result);
        }
Example #14
0
    IEnumerator MarkerDetectedSequence(MarkerData markerData)
    {
        uiAnimator.SetTrigger("FoundMarker");
        yield return(new WaitForSeconds(3.0f));

        uiAnimator.SetTrigger("PlayVideo");
        yield return(new WaitForSeconds(1.0f));

        GameObject instance = Instantiate(currentVideoData.prefab, markerData.anchorTransform);

        currentVideoInstance = instance;

        VideoPlayerController videoController = instance.GetComponent <VideoPlayerController>();

        if (videoController != null)
        {
            videoController.videoData = currentVideoData;
            videoController.VideoEnded.AddListener(OnVideoEnded);
        }
        else
        {
            VideoPlayer videoPlayer = instance.GetComponent <VideoPlayer>();
            videoPlayer.clip              = currentVideoData.clip;
            videoPlayer.loopPointReached += OnVideoEnded;
            if (currentVideoData.playImmediately == true)
            {
                Debug.Log("Playing video...");
                videoPlayer.Play();
            }
        }
    }
    public void ShowMarkerOfFloor(GameObject floorObject) /* show marker in map */
    {
        GameObject markers = mapImage.transform.GetChild(0).gameObject;

        //destroy all marker
        foreach (Transform ch in markers.transform)
        {
            Destroy(ch.gameObject);
        }
        //create marker prefab
        List <GameObject> markerList = floorObject.GetComponent <FloorData>().markerList;

        foreach (GameObject markerob in markerList)
        {
            //instantiate marker at child of Markers
            GameObject markerDot  = Instantiate(markerPrefab);
            MarkerData markerdata = markerob.GetComponent <MarkerData>();
            markerDot.transform.SetParent(markers.transform);
            //recttransform coordinate xy 1000/mapimage.sizedelta
            markerDot.GetComponent <RectTransform>().anchoredPosition = new Vector2(
                markerdata.position.x * (mapImage.GetComponent <RectTransform>().sizeDelta.x / 1000),
                markerdata.position.z * (mapImage.GetComponent <RectTransform>().sizeDelta.y / 1000)
                );
        }
    }
Example #16
0
        /*
         * Add a vending map marker to the map
         */
        private bool AddMapMarker(ulong _npc_id, MarkerData _marker_data)
        {
            this.LogDebug(string.Format("Spawning npcvmm for npc id {0} with name '{1}' at position {2}", _npc_id, _marker_data.shop_name, _marker_data.position.ToString()));

            // Make sure to remove an already existing npcvmm first
            this.RemoveMapMarker(_npc_id);

            // Create and configure new marker
            VendingMachineMapMarker vmmm = GameManager.server.CreateEntity("assets/prefabs/deployable/vendingmachine/vending_mapmarker.prefab", _marker_data.position, UnityEngine.Quaternion.identity, true) as VendingMachineMapMarker;

            if (vmmm == null)
            {
                this.LogDebug("CreateEntity failed!");
                return(false);
            }
            vmmm.server_vendingMachine = null;

            // Set busy flag to have a green symbol
            vmmm.SetFlag(BaseEntity.Flags.Busy, true, false, true);

            // Set shop name and add shop info if available
            vmmm.markerShopName  = _marker_data.shop_name;
            vmmm.markerShopName += this.GetServerRewardsData(_npc_id.ToString());

            // Spawn marker on map
            vmmm.Spawn();
            vmmm.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);

            // Add marker to our marker list
            this.map_markers.Add(_npc_id, vmmm);

            this.LogDebug(string.Format("Successfully spawned npcvmm for npc id {0} with name '{1}' at position {2}", _npc_id, _marker_data.shop_name, _marker_data.position.ToString()));
            return(true);
        }
    /// <summary>
    /// Gets the marker data.
    /// </summary>
    /// <returns>The marker data.</returns>
    public MarkerData GetMarkerData()
    {
        Transform trans = transform;
        Vector3   pos   = trans.position;
        Vector3   scale = trans.localScale;

        Vector3 fwd   = trans.forward * scale.z;
        Vector3 right = trans.right * scale.x;

        Vector3[] verts = new Vector3[4];
        verts[0] = pos + fwd + right;
        verts[1] = pos + fwd - right;
        verts[2] = pos - fwd - right;
        verts[3] = pos - fwd + right;

        MarkerData result = new MarkerData();

        result.verts    = verts;
        result.ymin     = pos.y - trans.localScale.y;
        result.ymax     = pos.y + trans.localScale.y;
        result.area     = Area;
        result.priority = Priority;

        return(result);
    }
    private void ShowLine(GameObject begin, GameObject destination) /* show green navigate line on map */
    {
        UILineRenderer line = navline.GetComponent <UILineRenderer>();

        line.Points.Clear();
        MarkerData checkPoint = begin.GetComponent <MarkerData>();
        int        i          = 0;

        //Debug.Log("Write Line At " + checkPoint.markerName + " " + line.Points(i));
        while (checkPoint.successor != null)
        {
            // last point point to marker position
            line.Points.Add(new Vector2(
                                checkPoint.referencePosition.x * (mapImage.GetComponent <RectTransform>().sizeDelta.x / 1000),
                                checkPoint.referencePosition.z * (mapImage.GetComponent <RectTransform>().sizeDelta.y / 1000)
                                ));
            i++;
            checkPoint = checkPoint.successor.GetComponent <MarkerData>();
        }
        // add last point
        line.Points.Add(new Vector2(
                            checkPoint.referencePosition.x * (mapImage.GetComponent <RectTransform>().sizeDelta.x / 1000),
                            checkPoint.referencePosition.z * (mapImage.GetComponent <RectTransform>().sizeDelta.y / 1000)
                            ));
        line.Points.Add(new Vector2(
                            checkPoint.position.x * (mapImage.GetComponent <RectTransform>().sizeDelta.x / 1000),
                            checkPoint.position.z * (mapImage.GetComponent <RectTransform>().sizeDelta.y / 1000)
                            ));
        line.SetVerticesDirty();
    }
Example #19
0
        public string MarkerConfig()
        {
            var basePath         = AppDomain.CurrentDomain.BaseDirectory;
            var configMarkerPath = basePath + @"assets\img\Stamp\ImageMarker.config";

            var curPageIndex = -1;
            var curRowIndex  = -1;

            var settings = new XmlReaderSettings();

            settings.DtdProcessing = DtdProcessing.Parse;

            var listMarkerGroupData = new List <MarkerGroupData>();

            using (var reader = XmlReader.Create(configMarkerPath))
            {
                reader.MoveToContent();
                // Parse the file and display each of the nodes.
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        var elementName = reader.Name;
                        elementName = elementName.Substring(0, elementName.Length - 1).ToLower();

                        switch (elementName)
                        {
                        case "group":
                            var markerGroupData = new MarkerGroupData();
                            markerGroupData.GroupName       = reader.GetAttribute("display");
                            markerGroupData.MarkerDataTable = new List <IList <MarkerData> >();
                            listMarkerGroupData.Add(markerGroupData);
                            var pageId = reader.GetAttribute("page");
                            curPageIndex = _commonTool.GetSafeIntValue(pageId) - 1;
                            break;

                        case "row":
                            var rowId = reader.GetAttribute("row");
                            curRowIndex = _commonTool.GetSafeIntValue(rowId) - 1;
                            var rowMarkerData = new List <MarkerData>();
                            listMarkerGroupData[curPageIndex].MarkerDataTable.Add(rowMarkerData);
                            break;

                        case "item":
                            var markerData = new MarkerData();
                            markerData.DisplayText = reader.GetAttribute("display");
                            markerData.ImageName   = reader.GetAttribute("imagename").ToUpper();

                            listMarkerGroupData[curPageIndex].MarkerDataTable[curRowIndex].Add(markerData);
                            break;
                        }
                        break;
                    }
                }
            }

            return(_commonTool.GetJsonStringFromObject(listMarkerGroupData));
        }
Example #20
0
 public void TestSetFormType01()
 {
     using (MarkerData markerData = MarkerDataFactory.CreateMarkerData01())
     {
         FormType type = FormType.Edit;
         markerData.SetFormType(type);
     }
 }
Example #21
0
 public void TestInitializeComponent01()
 {
     using (MarkerData markerData = MarkerDataFactory.CreateMarkerData01())
     {
         Accessor markerDataAccessor = ReflectionAccessor.Wrap(markerData);
         markerDataAccessor.Call("InitializeComponent");
     }
 }
Example #22
0
        public void SetNewMarker(int newIndex)
        {
            markerIndexSP.intValue = newIndex;
            markerIdSP.stringValue = mainScript.GetMarkerList()[markerIndexSP.intValue];

            string filepath = Application.dataPath + "/Editor/markerImages/" + markerIdSP.stringValue + ".jpg";

            if (markerIndexSP.intValue == 0)
            {
                //filepath = Application.dataPath + "/Editor/markerImages/placeholder.jpg";
                filepath = Application.dataPath + "/PikkartAR/Assets/Images/placeholder.jpg";
                markerIdSP.stringValue = "";
            }

            // applicazione material
            var material = new Material(Shader.Find("Diffuse"));

            material.mainTexture = IMG2Sprite.instance.LoadTexture(filepath);
            if (markerObject.GetComponentInChildren <ReferenceImage>() != null)
            {
                markerObject.GetComponentInChildren <ReferenceImage>().gameObject.
                GetComponent <MeshRenderer>().material = material;
            }

            string     id        = markerIdSP.stringValue;
            MarkerData container = new MarkerData();

            if (id == "")
            {
                container.name   = "0";
                container.width  = 1;
                container.height = 1;
            }
            else
            {
                //caricamento xml e ridimensionamento
                string xmlPath = Application.streamingAssetsPath + "/xmls/" + id + ".xml";

                var serializer = new XmlSerializer(typeof(MarkerData));
                var stream     = new FileStream(xmlPath, FileMode.Open);
                container = serializer.Deserialize(stream) as MarkerData;
                stream.Close();
            }

            // riposizionamento e scala del quad
            if (markerObject.GetComponentInChildren <ReferenceImage>() != null)
            {
                Transform referenceImageTransform = markerObject.GetComponentInChildren <ReferenceImage>().transform;

                Vector3 newScale = new Vector3(container.width, container.height, 1);
                referenceImageTransform.localScale = newScale;

                referenceImageTransform.position = Vector3.zero;

                Vector3 newCenter = new Vector3(0 - container.width / 2, 0, container.height / 2);
                referenceImageTransform.localPosition = newCenter;
            }
        }
Example #23
0
    private IEnumerator JSONDecodeGoogleSearchResponse(string wwwResponse)
    {
        if (wwwResponse != null)
        {
            JSONObject j = new JSONObject(wwwResponse);

            if (j["status"].ToString().Contains("OK"))
            {
                lastResults = new List <MarkerData>();

                for (int i = 0; i < j["results"].Count; i++)
                {
                    md = new MarkerData();

                    md.acquiredOnline = true;
                    md.dateAdded      = Application.Utils.dateToday();

                    md.worldCoords = new Vector3(float.Parse(j["results"][i]["geometry"]["location"]["lng"].ToString()),
                                                 0,
                                                 float.Parse(j["results"][i]["geometry"]["location"]["lat"].ToString()));

                    md.name = j["results"][i].GetField("name").str.ToString();

                    if (j["results"][i].HasField("formatted_address"))
                    {
                        md.description += "Address:\n" + j["results"][i].GetField("formatted_address").str + "\n\n";
                    }
                    if (j["results"][i].HasField("rating"))
                    {
                        md.description += "Google users rating: " + j["results"][i]["rating"].ToString() + " stars \n";
                    }

                    md.visible = false;

                    lastResults.Add(md);
                }
            }
            else if (j["status"].ToString().Contains("ZERO_RESULTS"))
            {
                Debug.Log("NO RESULTS FOUND!");
                lastResults.Clear();
            }
            else
            {
                Debug.LogError("CANT DECODE MESSAGE WITH CONTENT:\n" + wwwResponse);
            }


            if (MarkersListController.Instance.isDisplayed)
            {
                MarkersListController.Instance.toggleMarkersMenu();              // hide menu
            }
            MarkersListController.Instance.toggleMarkersMenu(true, lastResults); // show menu with new data

            yield return(lastResults);
        }
    }
Example #24
0
        private IFeature ConvertToPointFeature(MarkerData markerData)
        {
            var point      = new Point(new Coordinate().FromLatLng(markerData.latlng));
            var attributes = new AttributesTable {
                { FeatureAttributes.NAME, markerData.title }
            };

            return(new Feature(point, attributes));
        }
Example #25
0
 public void loadFromMarkerData(MarkerData md)
 {
     data = md;
     setRelativeGamePosition();
     transform.gameObject.GetComponentInChildren <Button>().onClick.AddListener(
         delegate { MarkerInfoPopUpController.Instance.showMarkerInfoPopup(data); });
     transform.Rotate(new Vector3(0, 180, 0)); // Rotate the prefab
     transform.LookAt(new Vector3(0, -20, 0)); // Look at the camera
 }
Example #26
0
 public void TestTranslateCaption01()
 {
     using (MarkerData markerData = MarkerDataFactory.CreateMarkerData01())
     {
         markerData.SetFormType(FormType.Add);
         markerData.TranslateCaption();
         markerData.SetFormType(FormType.Edit);
         markerData.TranslateCaption();
     }
 }
Example #27
0
 private wptType ToWptType(MarkerData marker)
 {
     return(new wptType
     {
         lat = (decimal)marker.Latlng.Lat,
         lon = (decimal)marker.Latlng.Lng,
         name = marker.Title,
         type = marker.Type
     });
 }
Example #28
0
 public void ResetAllVertexData(GameObject floorObject)
 {
     foreach (GameObject markerObj in floorObject.GetComponent <FloorData>().markerList)
     {
         MarkerData markerData = markerObj.GetComponent <MarkerData>();
         markerData.cost        = Single.PositiveInfinity;
         markerData.predecessor = null;
         markerData.successor   = null;
     }
 }
Example #29
0
 public void TestDispose01()
 {
     using (MarkerData markerData = MarkerDataFactory.CreateMarkerData01())
     {
         bool     disposing          = true;
         Accessor markerDataAccessor = ReflectionAccessor.Wrap(markerData);
         markerDataAccessor.SetField("components", new System.ComponentModel.Container());
         markerDataAccessor.Call("Dispose", disposing);
     }
 }
Example #30
0
 private GpxWaypoint ToGpxWaypoint(MarkerData marker)
 {
     return(new GpxWaypoint(
                (GpxLongitude)marker.Latlng.Lng,
                (GpxLatitude)marker.Latlng.Lat)
            .WithName(marker.Title)
            .WithDescription(marker.Description)
            .WithLinks((marker.Urls ?? new List <LinkData>())
                       .Select(l => new GpxWebLink(l.Url, l.Text, l.MimeType)).ToImmutableArray())
            .WithClassification(marker.Type));
 }
Example #31
0
 private GameObject FindGameObjectFromMarkerData(GameObject floorObject, MarkerData markerData)
 {
     foreach (GameObject markerob in floorObject.GetComponent <FloorData>().markerList)
     {
         if (markerob.GetComponent <MarkerData>().markerName == markerData.markerName)
         {
             return(markerob);
         }
     }
     return(floorObject.GetComponent <FloorData>().markerList[0].gameObject);
 }
    /// <summary>
    /// The marker data.
    /// </summary>
    /// <returns>The marker data.</returns>
    public MarkerData GetMarkerData()
    {
        MarkerData result = new MarkerData();

        Transform trans = transform;
        Vector3 scale = trans.localScale;

        result.area = Area;
        result.priority = Priority;
        result.centerBase = trans.position - Vector3.up * scale.y * 0.5f;
        result.radius = scale.x;
        result.height = scale.y;

        return result;
    }
Example #33
0
        /// <summary>
        /// Creates a CodeLocation from the given marker.
        /// </summary>
        /// <param name="marker">
        /// The marker.
        /// </param>
        /// <returns>
        /// Returns the CodeLocation.
        /// </returns>
        private static CodeLocation CodeLocationFromMarker(MarkerData marker)
        {
            Param.AssertNotNull(marker, "marker");

            return new CodeLocation(marker.Index, marker.Index, marker.IndexOnLine, marker.IndexOnLine, marker.LineNumber, marker.LineNumber);
        }
Example #34
0
    /// <summary>
    /// Write marker list to an xml file stored in application storage.
    /// </summary>
    private void _SaveMarkerToDisk()
    {
        // Compose a XML data list.
        List<MarkerData> xmlDataList = new List<MarkerData>();
        foreach (GameObject obj in m_markerList)
        {
            // Add marks data to the list, we intentionally didn't add the timestamp, because the timestamp will not be
            // useful when the next time Tango Service is connected. The timestamp is only used for loop closure pose
            // correction in current Tango connection.
            MarkerData temp = new MarkerData();
            temp.m_type = obj.GetComponent<ARMarker>().m_type;
            temp.m_position = obj.transform.position;
            temp.m_orientation = obj.transform.rotation;
            xmlDataList.Add(temp);
        }

        string path = Application.persistentDataPath + m_curAreaDescription.m_uuid + ".xml";
        var serializer = new XmlSerializer(typeof(List<MarkerData>));
        using (var stream = new FileStream(path, FileMode.Create))
        {
            serializer.Serialize(stream, xmlDataList);
        }
    }
    /// <summary>
    /// Save the game.
    /// 
    /// Save will trigger 3 things:
    /// 1. Bundle adjustment for all marks position, please see _UpdateMarkersForLoopClosures() function header for 
    ///     more details.
    /// 2. Save all marker to xml, save the Area Description if the learning mode is on.
    /// 3. Reload the scene.
    /// </summary>
    public void Save()
    {
        // We do a bundle adjustment to all the markers first, to make sure it's located at the most precise position.
        if (m_tangoApplication.m_enableAreaLearning)
        {
            _UpdateMarkersForLoopClosures();
        }

        // Compose a XML data list
        List<MarkerData> xmlDataList = new List<MarkerData>();
        foreach (GameObject obj in m_markerList)
        {
            // Add marks data to the list, we intentionally didn't add the timestamp, because the timestamp will not be
            // useful when the next time Tango Service is connected. The timestamp is only used for loop closure pose
            // correction in current Tango connection.
            MarkerData temp = new MarkerData();
            temp.m_type = obj.GetComponent<ARMarker>().m_type;
            temp.m_position = obj.transform.position;
            temp.m_orientation = obj.transform.rotation;
            xmlDataList.Add(temp);
        }

        // Disable interaction before saving.
        m_initialized = false;
        m_savingText.gameObject.SetActive(true);

        // Start saving process in another thread.
        ThreadStart work = delegate { _AsyncDataSaving(xmlDataList); };
        m_saveThread = new Thread(work);
        m_saveThread.Start();
    }
Example #36
0
 private static CodeLocation CodeLocationFromMarker(MarkerData marker)
 {
     return new CodeLocation(marker.Index, marker.Index, marker.IndexOnLine, marker.IndexOnLine, marker.LineNumber, marker.LineNumber);
 }
    /// <summary>
    /// Unity Update function.
    /// 
    /// Mainly handle the touch event and place mark in place.
    /// </summary>
    public void Update()
    {
        if (m_saveThread != null && m_saveThread.ThreadState != ThreadState.Running)
        {
            // After saving an Area Description or mark data, we reload the scene to restart the game.
            _UpdateMarkersForLoopClosures();

            // Compose a XML data list.
            List<MarkerData> xmlDataList = new List<MarkerData>();
            foreach (GameObject obj in m_markerList)
            {
                // Add marks data to the list, we intentionally didn't add the timestamp, because the timestamp will not be
                // useful when the next time Tango Service is connected. The timestamp is only used for loop closure pose
                // correction in current Tango connection.
                MarkerData temp = new MarkerData();
                temp.m_type = obj.GetComponent<ARMarker>().m_type;
                temp.m_position = obj.transform.position;
                temp.m_orientation = obj.transform.rotation;
                xmlDataList.Add(temp);
            }

            _WriteToXml(m_curAreaDescription.m_uuid + ".xml", xmlDataList);
            Application.LoadLevel(Application.loadedLevel);
        }

        if (!m_initialized)
        {
            return;
        }

        if (EventSystem.current.IsPointerOverGameObject(0) || GUIUtility.hotControl != 0)
        {
            return;
        }

        if (Input.touchCount == 1)
        {
            Touch t = Input.GetTouch(0);
            Vector2 guiPosition = new Vector2(t.position.x, Screen.height - t.position.y);
            Camera cam = Camera.main;
            RaycastHit hitInfo;

            if (t.phase != TouchPhase.Began)
            {
                return;
            }

            if (m_selectedRect.Contains(guiPosition))
            {
                // do nothing, the button will handle it
            }
            else if (Physics.Raycast(cam.ScreenPointToRay(t.position), out hitInfo))
            {
                // Found a marker, select it (so long as it isn't disappearing)!
                GameObject tapped = hitInfo.collider.gameObject;
                if (!tapped.GetComponent<Animation>().isPlaying)
                {
                    m_selectedMarker = tapped.GetComponent<ARMarker>();
                }
            }
            else
            {
                // Place a new point at that location, clear selection
                m_selectedMarker = null;
                StartCoroutine(_WaitForDepthAndFindPlane(t.position));
                
                // Because we may wait a small amount of time, this is a good place to play a small
                // animation so the user knows that their input was received.
                RectTransform touchEffectRectTransform = Instantiate(m_prefabTouchEffect) as RectTransform;
                touchEffectRectTransform.transform.SetParent(m_canvas.transform, false);
                Vector2 normalizedPosition = t.position;
                normalizedPosition.x /= Screen.width;
                normalizedPosition.y /= Screen.height;
                touchEffectRectTransform.anchorMin = touchEffectRectTransform.anchorMax = normalizedPosition;
            }
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            Application.LoadLevel(Application.loadedLevel);
        }
    }