Пример #1
0
    private void Start()
    {
        int     pointsCount = verticesPos.Length;
        CMShape model       = new CMShape();

        shapeView.Init(model, verticesPos);
        shapeView.name = "Shape";
        model.Init(pointsCount, linesOfPoints, planesOfLines);
    }
Пример #2
0
        // обработчик события создания точки модели
        private void Model_PointCreated(CMShape shape, CMPoint point)
        {
            // создание вида для очередной точки
            const string letters   = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789";
            string       pointName = letters[pointViewDict.Count].ToString();
            CVPoint      pointView = CVPoint.Create(pointName, point, pointsObj, nextPointsPos.Dequeue());

            pointView.MouseDown += PointView_MouseDown;
            pointViewDict.Add(point.Id, pointView);
        }
Пример #3
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);
        }
Пример #4
0
        // pointsPos - coordinates of the shape's points
        public CVShape Init(CMShape model, IEnumerable <Vector3> pointsPos)
        {
            if (this.model != null)
            {
                throw new Exception("Second initialization of the shape view");
            }


            pointsObj        = new GameObject("points").transform;
            linesObj         = new GameObject("lines").transform;
            anglesObj        = new GameObject("angles").transform;
            pointsObj.parent = linesObj.parent = anglesObj.parent = transform;

            nextPointsPos = new Queue <Vector3>(pointsPos);
            pointsPos     = null;

            this.model          = model;
            model.PointCreated += Model_PointCreated;
            model.LineCreated  += Model_LineCreated;

            return(this);
        }