void Start() { camera2d = GameObject.Find("Camera2d").GetComponent <Camera> (); VectorLine.SetCanvasCamera(camera2d); VectorLine.canvas3D.sortingLayerName = "World"; gridLine = new VectorLine("Grid", new Vector2[0], null, 1.0f); drawLine = new VectorLine("DrawLine", new Vector3[0], null, 1.0f, isContinue? LineType.Continuous : LineType.Discrete, isContinue ? Joins.None : Joins.None); //drawLine.rectTransform.gameObject.AddComponent<Outline>(); rulerLine = new VectorLine("Ruler", new Vector3[0], null, 1.0f, LineType.Discrete); segmentOutline = new VectorLine("SegmentOutline", new Vector3[0], null, 1.0f, LineType.Discrete); segmentFill = new WallFill(VectorLine.canvas3D, "SegmentFill"); Vector2[] room = RoomQuad.GetVertex(); //DrawWall(room); List <Wall2D> roomWalls = DrawHelper.ContinueToDiscrete(room); Home.Get().AddWallList(roomWalls); // VectorLine testLine = new VectorLine("test", new Vector3[] { Vector3.zero, new Vector3(1.0f, 0f, 0f), Vector3.one }, null, 2.0f, LineType.Continuous); // testLine.Draw3D(); // Align 1-pixel lines on the pixel grid, so they don't potentially get messed up by anti-aliasing //gridLine.rectTransform.anchoredPosition = new Vector2 (.5f, .5f); gridLine.rectTransform.anchoredPosition = new Vector2(0f, 0f); //MakeGrid (); //SetScale(DrawHelper.unitPixels); DrawHelper.OnScaleChanged = MakeGrid2; DrawHelper.SetScale(camera2d, DrawHelper.unitPixels); mState = State2D.Idle; }
void Start() { camera2d = GameObject.Find ("Camera2d").GetComponent<Camera> (); VectorLine.SetCanvasCamera (camera2d); VectorLine.canvas3D.sortingLayerName = "World"; gridLine = new VectorLine ("Grid", new Vector2[0], null, 1.0f); drawLine = new VectorLine("DrawLine", new Vector3[0], null, 1.0f, isContinue? LineType.Continuous : LineType.Discrete, isContinue ? Joins.None : Joins.None); //drawLine.rectTransform.gameObject.AddComponent<Outline>(); rulerLine = new VectorLine("Ruler", new Vector3[0], null, 1.0f, LineType.Discrete); segmentOutline = new VectorLine("SegmentOutline", new Vector3[0], null, 1.0f, LineType.Discrete); segmentFill = new WallFill(VectorLine.canvas3D, "SegmentFill"); Vector2[] room = RoomQuad.GetVertex(); //DrawWall(room); List<Wall2D> roomWalls = DrawHelper.ContinueToDiscrete(room); Home.Get().AddWallList(roomWalls); // VectorLine testLine = new VectorLine("test", new Vector3[] { Vector3.zero, new Vector3(1.0f, 0f, 0f), Vector3.one }, null, 2.0f, LineType.Continuous); // testLine.color = Color.red; // testLine.Draw3D(); // Align 1-pixel lines on the pixel grid, so they don't potentially get messed up by anti-aliasing //gridLine.rectTransform.anchoredPosition = new Vector2 (.5f, .5f); gridLine.rectTransform.anchoredPosition = new Vector2(0f, 0f); //MakeGrid (); //SetScale(DrawHelper.unitPixels); DrawHelper.OnScaleChanged = MakeGrid2; DrawHelper.SetScale(camera2d, DrawHelper.unitPixels); mState = State2D.Idle; }
void DrawWall(Vector2[] room) { bool isClose = false; if(room[0] == room[room.Length-1]){ isClose = true; } if(isClose){ List<Vector2> outter; RoomQuad.GetPoint(room, true, out outter); List<Vector2> inner; RoomQuad.GetPoint(room, false, out inner); WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill"); wallFill.Add(outter, inner); wallFill.Draw(); if(inner.Count > 0){ VectorLine roomInner = new VectorLine("RoomInner", inner, null, 1.0f, LineType.Continuous, Joins.Weld); roomInner.SetColor(Color.black); roomInner.Draw3D(); } if(outter.Count > 0){ VectorLine roomOutter = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.Weld); roomOutter.SetColor(Color.black); roomOutter.Draw3D(); } } else { Parallel parallel = new Parallel(); List<Vector2> outter = parallel.Execute(room, wallThick, false); List<Vector2> inner = parallel.Execute(room, wallThick, true); WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill"); wallFill.Add(outter, inner); wallFill.Draw(); // if(inner.Count > 0){ // VectorLine roomInner = new VectorLine("RoomInner", inner, null, 1.0f, LineType.Continuous, Joins.None); // roomInner.SetColor(Color.black); // roomInner.Draw3D(); // } // // if(outter.Count > 0){ // VectorLine roomOutter = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.None); // roomOutter.SetColor(Color.black); // roomOutter.Draw3D(); // } // List<Vector3> outter; // bool counterClockwise = RoomQuad.GetPoint(room, isClose, true, out outter); // // int length = outter.Count-1; // // int startA = -1; // int startB = -1; // int endC = -1; // int endD = -1; // for(int i=0; i < length; i++){ // Vector2 dist = outter[i] - room[0]; // float wallThick = (float)RoomQuad.WallThick; // if(Mathf.Abs(dist.sqrMagnitude - wallThick/2*wallThick/2) < 0.001f){ // if(startA == -1){ // startA = i; // } // else{ // startB = i; // } // } // // dist = outter[i] - room[room.Length-1]; // if(Mathf.Abs(dist.sqrMagnitude - wallThick/2*wallThick/2) < 0.001f){ // if(endC == -1){ // endC = i; // } // else{ // endD = i; // } // } // } // // Debug.Log(string.Format("start index: ({0}, {1}), ", startA, startB)); // // Debug.Log("orientation: " + counterClockwise); // // List<Vector3> a = new List<Vector3>(); // List<Vector3> b = new List<Vector3>(); // // if(counterClockwise){ // // Vector3[] tmp = new Vector3[length+1]; // outter.CopyTo(0, tmp, 0, length); // //// if(length%2 == 1){ //// tmp[length] = tmp[length-1]; //// length++; //// } // // for(int i = startA; i > startA - length/2; i--){ // b.Add(tmp[(i+length)%length]); // } // // for(int i = startB; i < startB + length/2; i++){ // a.Add(tmp[i%length]); // } // // WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill"); // wallFill.Draw(a, b); // } // if(outter.Count > 0){ // VectorLine roomInner = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.Weld); // roomInner.SetColor(Color.blue); // roomInner.Draw3D(); // } } }
void DrawWall(Vector2[] room) { bool isClose = false; if (room[0] == room[room.Length - 1]) { isClose = true; } if (isClose) { List <Vector2> outter; RoomQuad.GetPoint(room, true, out outter); List <Vector2> inner; RoomQuad.GetPoint(room, false, out inner); WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill"); wallFill.Add(outter, inner); wallFill.Draw(); if (inner.Count > 0) { VectorLine roomInner = new VectorLine("RoomInner", inner, null, 1.0f, LineType.Continuous, Joins.Weld); roomInner.SetColor(Color.black); roomInner.Draw3D(); } if (outter.Count > 0) { VectorLine roomOutter = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.Weld); roomOutter.SetColor(Color.black); roomOutter.Draw3D(); } } else { Parallel parallel = new Parallel(); List <Vector2> outter = parallel.Execute(room, wallThick, false); List <Vector2> inner = parallel.Execute(room, wallThick, true); WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill"); wallFill.Add(outter, inner); wallFill.Draw(); // if(inner.Count > 0){ // VectorLine roomInner = new VectorLine("RoomInner", inner, null, 1.0f, LineType.Continuous, Joins.None); // roomInner.SetColor(Color.black); // roomInner.Draw3D(); // } // // if(outter.Count > 0){ // VectorLine roomOutter = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.None); // roomOutter.SetColor(Color.black); // roomOutter.Draw3D(); // } // List<Vector3> outter; // bool counterClockwise = RoomQuad.GetPoint(room, isClose, true, out outter); // // int length = outter.Count-1; // // int startA = -1; // int startB = -1; // int endC = -1; // int endD = -1; // for(int i=0; i < length; i++){ // Vector2 dist = outter[i] - room[0]; // float wallThick = (float)RoomQuad.WallThick; // if(Mathf.Abs(dist.sqrMagnitude - wallThick/2*wallThick/2) < 0.001f){ // if(startA == -1){ // startA = i; // } // else{ // startB = i; // } // } // // dist = outter[i] - room[room.Length-1]; // if(Mathf.Abs(dist.sqrMagnitude - wallThick/2*wallThick/2) < 0.001f){ // if(endC == -1){ // endC = i; // } // else{ // endD = i; // } // } // } // // Debug.Log(string.Format("start index: ({0}, {1}), ", startA, startB)); // // Debug.Log("orientation: " + counterClockwise); // // List<Vector3> a = new List<Vector3>(); // List<Vector3> b = new List<Vector3>(); // // if(counterClockwise){ // // Vector3[] tmp = new Vector3[length+1]; // outter.CopyTo(0, tmp, 0, length); // //// if(length%2 == 1){ //// tmp[length] = tmp[length-1]; //// length++; //// } // // for(int i = startA; i > startA - length/2; i--){ // b.Add(tmp[(i+length)%length]); // } // // for(int i = startB; i < startB + length/2; i++){ // a.Add(tmp[i%length]); // } // // WallFill wallFill = new WallFill(VectorLine.canvas3D, "wallFill"); // wallFill.Draw(a, b); // } // if(outter.Count > 0){ // VectorLine roomInner = new VectorLine("RoomOutter", outter, null, 1.0f, LineType.Continuous, Joins.Weld); // roomInner.SetColor(Color.blue); // roomInner.Draw3D(); // } } }