示例#1
0
        // обработчик события создания прямой модели
        private void Model_LineCreated(CMShape shape, CMLine line)
        {
            // создание вида для очередной линии
            CVLine lineView = new CVLine(linesObj, line);

            lineView.Selected += LineView_Selected;
            for (int j = 0; j < line.PointsCount; j++)
            {
                lineView.AddPoint(pointViewDict[line.PointAt(j).Id]);
            }
            lineViewDict.Add(line.Id, lineView);
        }
示例#2
0
        private CVLineSegment Init(CVLine line, Transform parentObj, Vector3 localPos1, Vector3 localPos2)
        {
            Owner            = line;
            transform.parent = parentObj;

            SetPositions(localPos1, localPos2);
            var collider = transform.GetComponent <CapsuleCollider>();

            collider.radius = 2;
            collider.height = 1.9f;
            name            = string.Format("line {0}({1})", Model.Id, Owner.Count);

            StartCoroutine(CalcSegmentName());

            return(this);
        }
示例#3
0
        // отложенная обработка события выбора отрезка
        private IEnumerator LineView_Selected_Coroutine(CVLine view, CVLineSegment segment)
        {
            switch (CurState)
            {
            case State.SetAngle:
                if (activeSegments.Count != 0 && segment.GetCommonPoint(activeSegments.Top) == null)
                {
                    activeSegments.Clear();
                }
                activeSegments.ToXor(segment);
                break;

            case State.BuildLine:
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (curAction != null && curAction.IsDone)
                {
                    curAction.Undo();
                    yield return(null);
                }
                RaycastHit raycastHit = new RaycastHit();
                if (activePoints.Top != null && Physics.Raycast(ray, out raycastHit))
                {
                    CVLineSegment correctSegment = raycastHit.transform.gameObject.GetComponent <CVLineSegment>();
                    curAction = new CBuildLineAction(this, activePoints.Top, correctSegment, raycastHit.point);
                    curAction.Do();
                }
                break;

            case State.DivideLine:
                activeSegments.ToXor(segment);
                break;

            case State.Static:
                break;
            }
            yield return(null);
        }
示例#4
0
 // обработчик события выбора отрезка
 private void LineView_Selected(CVLine view, CVLineSegment segment)
 {
     StartCoroutine(LineView_Selected_Coroutine(view, segment));
 }
示例#5
0
 public CDivideLineAction(CVShape owner, CVLine line, int segmentIndex, Vector3 pointPosition) : base(owner)
 {
     pointAction = new CCreatePointAction(owner, pointPosition);
     segment     = new CVSegmentWrap(owner, line.Model.Id, segmentIndex);
     ratio       = 0;
 }
示例#6
0
 public CDivideLineAction(CVShape owner, CVLine line, int segmentIndex, float ratio)
     : this(owner, line, segmentIndex, Vector3.zero)
 {
     this.ratio = ratio;
 }
示例#7
0
 public static CVLineSegment Create(CVLine line, Transform parent, Vector3 localStartPos, Vector3 localEndPos)
 {
     return(GameObject.CreatePrimitive(PrimitiveType.Cylinder)
            .AddComponent <CVLineSegment>()
            .Init(line, parent, localStartPos, localEndPos));
 }