void Update() { if (domaManager.HoleInWall2D != null) { if (!cube.activeSelf) { cube.SetActive(true); } cube.transform.position = domaManager.HoleInWall2D.mousePosition; Vector3 startPoint = domaManager.HoleInWall2D.Wall.StartPoint; Vector3 endPoint = domaManager.HoleInWall2D.Wall.EndPoint; Vector3 v = endPoint - startPoint; Quaternion rotation = Quaternion.LookRotation(v, Vector3.forward); rotation *= Quaternion.Euler(0, 90, 0); cube.transform.rotation = rotation; } else { cube.SetActive(false); } if (Input.GetMouseButtonDown(0)) { Vector3?position = domaManager.HoleInWall2D?.mousePosition; if (position != null) { DWall dWall = domaManager.HoleInWall2D.Wall; var hole = dWall.DrawHole3D(new Vector3(position.Value.x, domaManager.currentStatusDoma.activeFloor.LevelBottom + 1.1f, position.Value.y), 1f, 2.2f); dWall.DrawWallWithHole(hole); } } }
public SWall(DWall dWall) { Id = dWall.Id; FloorId = dWall.FloorId; Name = dWall.Name; Tag = dWall.Tag; StartPoint = new float[3] { dWall.StartPoint.x, dWall.StartPoint.y, dWall.StartPoint.z }; EndPoint = new float[3] { dWall.EndPoint.x, dWall.EndPoint.y, dWall.EndPoint.z }; Width = dWall.Width; Height = dWall.Height; BottomLevel = dWall.BottomLevel; Material = dWall.Material.name; Triangles3D = dWall.Instance3D.GetComponent <MeshFilter>().mesh.triangles; Vertices3D = new List <float[]>(); foreach (var v in dWall.Instance3D.GetComponent <MeshFilter>().mesh.vertices) { Vertices3D.Add(new float[3] { v.x, v.y, v.z }); } }
bool endOverlap = true; // pozwala kontrolować tylko jednokrotne wykonanie metody po ucieczce myszki z pola ściany // Start is called before the first frame update void Start() { domaManager = DomaManager.Instance; currentStatusDoma = domaManager.currentStatusDoma; wall = currentStatusDoma.GetWallByGameObject2D(gameObject); _collider = GetComponent <PolygonCollider2D>(); }
void Update() { // Pobranie œciany poprzez klikniêcie if (Input.GetMouseButtonDown(0)) { // Myszka znajduje siê nad œcian¹ if (domaManager.HoleInWall2D != null) { DWall wall = domaManager.HoleInWall2D.Wall; wall.GableWall3D(KneeWall); } } // Dzia³anie dla widoku 3D (zmiana poprzez klikniêcie na œcianie 3D) }
void Update() { if (domaManager.HoleInWall2D != null) { if (!cube.activeSelf) { cube.SetActive(true); } cube.transform.position = domaManager.HoleInWall2D.mousePosition; Vector3 startPoint = domaManager.HoleInWall2D.Wall.StartPoint; Vector3 endPoint = domaManager.HoleInWall2D.Wall.EndPoint; Vector3 v = endPoint - startPoint; Quaternion rotation = Quaternion.LookRotation(v, Vector3.forward); rotation *= Quaternion.Euler(0, 90, 0); cube.transform.rotation = rotation; } else { cube.SetActive(false); } if (Input.GetMouseButtonDown(0)) { Vector3?position = domaManager.HoleInWall2D?.mousePosition; if (position != null) { float width = 4.5f; float height = 1.5f; float space = 0.3f; float w; bool bW = float.TryParse(domaManager.widthInput.text, out w); if (bW) { width = w; } float h; bool bH = float.TryParse(domaManager.heightInput.text, out h); if (bH) { height = h; } float s; bool bS = float.TryParse(domaManager.spaceInput.text, out s); if (bS) { space = s; } print("w: " + width); print("h: " + height); print("s: " + space); DWall dWall = domaManager.HoleInWall2D.Wall; var hole = dWall.DrawHole3D(new Vector3(position.Value.x, domaManager.currentStatusDoma.activeFloor.LevelBottom + domaManager.currentStatusDoma.activeFloor.Height - space - (height / 2), position.Value.y), width, height); dWall.DrawWallWithHole(hole); } } }
void Update() { var nearestPoint = NearestPoint2D(0.5f); // Poszukiwanie punktu do zakończenia rysowania ściany var point = FindPointOn(domaManager.mousePosition2D, lastPoint, nearestPoint, KeyCode.LeftControl); if (Input.GetMouseButtonDown(0)) { lastPoint = point; startPoint2dView = point; startPoint3dView = GetPosition3dView(point, 2.5f); } else if (Input.GetMouseButton(0)) { domaManager.lengthWallText.text = System.Math.Round(Vector3.Distance(lastPoint, point), 2).ToString(); endPoint2dView = point; endPoint3dView = GetPosition3dView(point, 2.5f); tempLineRenderer.GetComponent <LineRenderer>().SetPosition(0, startPoint2dView); tempLineRenderer.GetComponent <LineRenderer>().SetPosition(1, endPoint2dView); } else if (Input.GetMouseButtonUp(0)) { lastPoint = point; endPoint2dView = point; endPoint3dView = GetPosition3dView(point, 2.5f); // ******************************************************************************** if (domaManager.currentStatusDoma.activeFloor.LevelBottom < 0f) { material = materialType1; } else { material = materialType2; } float widthWall = 0.2f; float height = currentStatusDoma.activeFloor.Height; float h; bool bH = float.TryParse(domaManager.heightInput.text, out h); if (bH) { height = h; } float w; bool bW = float.TryParse(domaManager.widthInput.text, out w); if (bW) { widthWall = w; } // 2D var obj2D = DrawMesh2D(startPoint2dView, endPoint2dView, widthWall, "Mesh2DPolygon"); // 3D var obj3D = DrawMesh3D(startPoint3dView, endPoint3dView, widthWall, height, "Mesh3DProBuilder"); // NEW DWall dWall = new DWall(currentStatusDoma.activeFloor.Id, startPoint2dView, endPoint2dView, widthWall, height, currentStatusDoma.activeFloor.LevelBottom, material, obj2D, obj3D.Item1); currentStatusDoma.appSystem.Walls.Add(dWall); } }