// Use this for initialization
 void Start()
 {
     Vertices       = new HashSet <Vertex>();
     Edges          = new HashSet <Edge>();
     trapezoidalMap = GameObject.Find("TrapezoidalMap").GetComponent <TrapezoidalMap>();
 }
示例#2
0
 // Use this for initialization
 void Start()
 {
     trapezoidalMap = GameObject.Find("TrapezoidalMap").GetComponent <TrapezoidalMap>();
 }
示例#3
0
        void DrawTrapezoidalDecomposition()
        {
            //var map =  TrapezoidalMap;
            //var verticalLines = map.naiveMap(height, weight);
            //
            GameObject parent = PlayerTrapezoidCollection[playerIndex];

            while (parent.transform.childCount > 0)
            {
                DestroyImmediate(parent.transform.GetChild(0).gameObject);
            }


            //TDShape newShape = new Shape(listCopy);



            var VerticalLines = new List <LineSegment>();


            //prepare inserted line segments (shapes) for trapezoidal decomposition
            int            index  = 0;
            List <TDShape> shapes = new List <TDShape>();

            foreach (Polygon2D polygon in PlayerPolygons[playerIndex])
            {
                foreach (LineSegment seg in polygon.Segments)
                {
                    var smallshape = new List <TDPoint>();
                    smallshape.Add(new TDPoint(seg.Point1.x, seg.Point1.y));
                    smallshape.Add(new TDPoint(seg.Point2.x, seg.Point2.y));

                    TDShape newShape = new TDShape(smallshape);
                    newShape.index = index++;
                    shapes.Add(newShape);
                }
            }

            Debug.Log(shapes.Count);
            //Incremental construction
            TrapezoidalMap Map = new TrapezoidalMap(shapes);

            Map.incrementalMap();
            var tlines = Map.naiveMap(10f, 10f);

            Debug.Log(tlines.Count);
            foreach (var line in tlines)
            {
                var     tp1 = line.getStart();
                var     tp2 = line.getEnd();
                Vector2 p1  = new Vector2(tp1.x, tp1.y);
                Vector2 p2  = new Vector2(tp2.x, tp2.y);
                VerticalLines.Add(new LineSegment(p1, p2));
            }


            //draw lines;
            foreach (var seg in VerticalLines)
            {
                //draw line segment,
                var mesh = Instantiate(TrapezoidLinePrefab, Vector3.forward, Quaternion.identity) as GameObject;

                mesh.transform.parent = parent.transform;
                //mesh.GetComponent<P2Segment>(seg.Point1, seg.Point2, player1Turn);

                instantObjects.Add(mesh);
                //Trapezoid1[playerIndex].Add(mesh);
                var meshScript = mesh.GetComponent <ReshapingMesh>();
                meshScript.CreateNewMesh(seg.Point1, seg.Point2);
            }



            /*  not working
             * GL.PushMatrix();
             *
             * // Set transformation matrix for drawing to
             * // match our transform
             * GL.MultMatrix(transform.localToWorldMatrix);
             *
             * P2Drawer drawer = new P2Drawer();
             * drawer.CreateLineMaterial();
             * drawer.Draw(VerticalLines);
             *
             * GL.PopMatrix();
             */
        }
示例#4
0
 // Use this for initialization
 void Start()
 {
     trapezoidalMap = GameObject.Find("TrapezoidalMap").GetComponent <TrapezoidalMap>();
     dagCamera      = GameObject.Find("DAG Camera").GetComponent <Camera>();
 }