Ejemplo n.º 1
0
        public void FinishAddingMarkers()
        {
            try
            {
                shouldUpdateMetrics           = false;
                shouldUpdateMovingSegmentLine = false;

                var lastMarker = new Marker()
                {
                    Previous = MarkerList.Last(),
                    Position = MarkerList.First().Position,
                };

                Vector3 initialPos = MarkerList.Last().Position;
                Vector3 finalPos   = MarkerList.First().Position;

                perimeterDistance += Vector3.Distance(finalPos, initialPos);
                debugText.text     = perimeterDistance > 1 ? $"\n TOTAL: {Math.Round(perimeterDistance, 2)} mts." : $"\n TOTAL: {Math.Round(perimeterDistance, 2) * 100} cms.";

                BuildSegmentLine(initialPos, finalPos);
                movingSegmentLine.SetActive(false);

                MarkerList.Add(lastMarker);
                CreateMesh();
            }
            catch (Exception ex)
            {
                debugText.text = ex.Message;
            }
        }
Ejemplo n.º 2
0
        public void CreateMarker()
        {
            try
            {
                GameObject prefab = Resources.Load($"Prefabs/Marker") as GameObject;
                CurrentMarker = Instantiate(prefab);

                var newMarker = new Marker()
                {
                    Previous = (MarkerList != null && MarkerList.Count > 0) ? MarkerList.Last() : null,
                    Position = CurrentMarker.transform.position,
                };

                MarkerList.Add(newMarker);
                shouldUpdateMovingSegmentLine = true;

                if (MarkerList.Count > 1)
                {
                    BuildSegmentLine(PreviousMarker.transform.position, CurrentMarker.transform.position);
                }

                shouldUpdateMetrics = true;
            }
            catch (Exception ex)
            {
                debugText.text = $"{ex.Message}";
            }
        }
Ejemplo n.º 3
0
        IEnumerator UpdateMovingSegmentLine()
        {
            // segment line
            var finalPos   = planeFinder.GetComponent <PlaneFinderBehaviour>().PlaneIndicator.transform.localPosition;
            var initialPos = MarkerList.Last().Position;

            Vector3 between  = finalPos - initialPos;
            float   distance = between.magnitude;

            movingSegmentLine.transform.localScale = new Vector3(0.01f, 0.01f, distance);
            var pos = initialPos + (between / 2);

            movingSegmentLine.transform.position = pos;
            movingSegmentLine.transform.LookAt(finalPos);

            yield return(new WaitForSeconds(.1f));
        }
Ejemplo n.º 4
0
        IEnumerator UpdateMetrics()
        {
            // total distance
            perimeterDistance = 0.0f;

            if (MarkerList != null && MarkerList.Count > 1)
            {
                foreach (var marker in MarkerList)
                {
                    var dist = marker.LastSegmentDistance;
                    perimeterDistance += dist;
                }
            }

            debugText.text = perimeterDistance > 1 ? $"\n TOTAL: {Math.Round(perimeterDistance, 2)} mts." : $"\n TOTAL: {Math.Round(perimeterDistance, 2) * 100} cms.";

            // last segment distance
            if (MarkerList != null && MarkerList.Count > 0)
            {
                var dist = Vector3.Distance(planeFinder.GetComponent <PlaneFinderBehaviour>().PlaneIndicator.transform.localPosition, MarkerList.Last().Position);
                debugText.text += dist > 1 ? $"\n CURRENT: {Math.Round(dist, 2)} mts." : $"\n CURRENT: {Math.Round(dist, 2) * 100} cms.";
            }

            //angle
            //var from = CurrentMarker.transform.position - PreviousMarker.transform.position;
            //var to = Vector3.ProjectOnPlane(from, -CurrentMarker.transform.up);
            //var angle = Vector3.Angle(from, to);

            //debugText.text += $" ANGLE: {Math.Round(angle, 2)} dgs.";

            yield return(new WaitForSeconds(.1f));
        }