public void SetEndVerticesDF() { // 여기에 라인렌더러 넣는걸 endScreenRay = MeshManager.Instance.cam.ScreenPointToRay(Input.mousePosition); Intersections.GetIntersectedValues(endScreenRay); isEndToVtx = false; }
public string CheckSelected(GameObject leftHeart, GameObject rightHeart) { string result = "none"; Ray ray = MeshManager.Instance.cam.ScreenPointToRay(Input.mousePosition); leftWorldPos = AdjacencyList.Instance.LocalToWorldPosition(leftHeart.GetComponent <MeshFilter>().mesh); rightWorldPos = AdjacencyList.Instance.LocalToWorldPosition(rightHeart.GetComponent <MeshFilter>().mesh); IntersectedValues valuesLeft = Intersections.GetIntersectedValues(ray, leftHeart.GetComponent <MeshFilter>().mesh.triangles, leftWorldPos); IntersectedValues valuesRight = Intersections.GetIntersectedValues(ray, rightHeart.GetComponent <MeshFilter>().mesh.triangles, rightWorldPos); // 돌렸을때 두개다 만져지면 문제임. if (valuesLeft.Intersected && valuesRight.Intersected) { if (valuesLeft.IntersectedPosition.z > valuesRight.IntersectedPosition.z) { result = "left"; } else { result = "right"; } } else if (valuesLeft.Intersected) { result = "left"; } else if (valuesRight.Intersected) { result = "right"; } return(result); }
public void SetEndVerticesDF() { endScreenRay = MeshManager.Instance.cam.ScreenPointToRay(Input.mousePosition); IntersectedValues intersectedValues = Intersections.GetIntersectedValues(); endVertexPosition = intersectedValues.IntersectedPosition; endOuterTriangleIndex = intersectedValues.TriangleIndex; }
public void SetStartVerticesDF() { // screen point도 저장해야됨. isStartFromVtx = false; startScreenRay = MeshManager.Instance.cam.ScreenPointToRay(Input.mousePosition); firstScreenRay = startScreenRay; Intersections.GetIntersectedValues(endScreenRay); firstVertexPosition = startVertexPosition; firstTriangleIndex = startTriangleIndex; }
public void SetEndVertices(Ray endRay) { // 여기에 라인렌더러 넣는걸 // 두번 중복되어있음... endScreenRay = endRay; IntersectedValues intersectedValues = Intersections.GetIntersectedValues(endScreenRay); endVertexPosition = intersectedValues.IntersectedPosition; endTriangleIndex = intersectedValues.TriangleIndex; isEndToVtx = false; }
void Update() { // 패치 방법부터 바꿔야됨. Ray cameraRay = MeshManager.Instance.cam.ScreenPointToRay(Input.mousePosition); if (isLastPatch) { Destroy(lineRenderer.lineObject); patchManager.GenerateMeshForMeasure(); isLastPatch = false; Destroy(this); } else if (Input.GetMouseButtonDown(0)) { Ray ray = MeshManager.Instance.cam.ScreenPointToRay(Input.mousePosition); IntersectedValues intersectedValues = Intersections.GetIntersectedValues(); if (intersectedValues.Intersected) { firstRay = ray; oldRay = ray; firstPosition = intersectedValues.IntersectedPosition; oldPosition = intersectedValues.IntersectedPosition; EventManager.Instance.Events.InvokeModeManipulate("StopAll"); AdjacencyList.Instance.ListUpdate(); patchManager.Generate(); patchManager.AddVertex(intersectedValues.IntersectedPosition); } } else if (Input.GetMouseButtonUp(0)) { if (oldPosition == Vector3.zero) { return; } EventManager.Instance.Events.InvokeModeManipulate("EndAll"); lineRenderer.SetLineRenderer(oldRay.origin + oldRay.direction * 100, firstRay.origin + firstRay.direction * 100); isLastPatch = true; } else if (Input.GetMouseButton(0)) { if (oldPosition == Vector3.zero) { return; } Ray ray = MeshManager.Instance.cam.ScreenPointToRay(Input.mousePosition); IntersectedValues intersectedValues = Intersections.GetIntersectedValues(); if (intersectedValues.Intersected) { //first position이 저장되어 있어야함. if (patchCount > 10 && Vector3.Distance(firstPosition, intersectedValues.IntersectedPosition) < 1.0f * MeshManager.Instance.pivotTransform.lossyScale.z) { EventManager.Instance.Events.InvokeModeManipulate("EndAll"); isLastPatch = true; return; } if (patchCount != 0) { lineRenderer.SetLineRenderer(oldRay.origin + oldRay.direction * 100, ray.origin + ray.direction * 100); } else { lineRenderer.SetFixedLineRenderer(oldRay.origin + oldRay.direction * 100, ray.origin + ray.direction * 100); } if (Vector3.Distance(firstPosition, intersectedValues.IntersectedPosition) > 1.5f * MeshManager.Instance.pivotTransform.lossyScale.z) { patchManager.AddVertex(intersectedValues.IntersectedPosition); patchCount++; oldPosition = intersectedValues.IntersectedPosition; oldRay = ray; return; } } else { if (patchCount == 0) { return; } Destroy(lineRenderer.lineObject); patchManager.RemovePatchVariables(); ChatManager.Instance.GenerateMessage(" 패치 라인이 심장을 벗어났습니다."); FirstSet(); } } return; }
void Update() { if (isFirst) { Debug.Log("Boundary cut 실행"); MeshManager.Instance.SaveCurrentMesh(); AdjacencyList.Instance.ListUpdate(); isFirst = false; boundaryCount = 0; return; } else if (isLast) { CGALCut(); AdjacencyList.Instance.ListUpdate(); EventManager.Instance.Events.InvokeModeManipulate("EndAll"); //EventManager.Instance.Events.InvokeModeChanged("ResetButton"); Destroy(lineRenderer.lineObject); Destroy(this); } else if (Input.GetMouseButtonDown(0)) { EventManager.Instance.Events.InvokeModeManipulate("StopAll"); Ray ray = MeshManager.Instance.cam.ScreenPointToRay(Input.mousePosition); IntersectedValues intersectedValues = Intersections.GetIntersectedValues(); rayList.Add(ray); oldRay = ray; firstRay = ray; boundaryCount++; if (intersectedValues.Intersected) { intersectedVerticesPos.Add(intersectedValues.IntersectedPosition); } else { isIntersected = false; } } else if (Input.GetMouseButton(0)) { Ray ray = MeshManager.Instance.cam.ScreenPointToRay(Input.mousePosition); IntersectedValues intersectedValues = Intersections.GetIntersectedValues(); lineRenderer.SetFixedLineRenderer(oldRay.origin + oldRay.direction * 100f, ray.origin + ray.direction * 100f); if (boundaryCount > 8 && Vector3.Distance(firstRay.origin, ray.origin) < 0.01f) { lineRenderer.SetLineRenderer(oldRay.origin + oldRay.direction * 100f, firstRay.origin + firstRay.direction * 100f); isLast = true; } else if (Vector3.Distance(oldRay.origin, ray.origin) > 0.005f) { boundaryCount++; lineRenderer.SetLineRenderer(oldRay.origin + oldRay.direction * 100f, ray.origin + ray.direction * 100f); oldRay = ray; rayList.Add(ray); if (intersectedValues.Intersected) { intersectedVerticesPos.Add(intersectedValues.IntersectedPosition); } else { isIntersected = false; } } } else if (Input.GetMouseButtonUp(0)) { lineRenderer.SetLineRenderer(oldRay.origin + oldRay.direction * 100f, firstRay.origin + firstRay.direction * 100f); isLast = true; } }
private void handleIncision() { IntersectedValues intersectedValues = Intersections.GetIntersectedValues(); bool checkInside = intersectedValues.Intersected; if (Input.GetMouseButtonDown(0) && checkInside) { EventManager.Instance.Events.InvokeModeManipulate("StopAll"); firstIncision = true; incisionDistance.SetActive(true); oldPosition = intersectedValues.IntersectedPosition; IncisionManager.IncisionUpdate(); AdjacencyList.Instance.ListUpdate(); IncisionManager.SetStartVerticesDF(); } else if (Input.GetMouseButton(0)) { if (!firstIncision) { return; } if (!checkInside) { Destroy(lineRenderer.lineObject); ChatManager.Instance.GenerateMessage(" 심장을 벗어났습니다."); EventManager.Instance.Events.InvokeModeManipulate("EndAll"); Destroy(incisionDistance); Destroy(this); } Vector3 currentPosition = intersectedValues.IntersectedPosition; Vector3 curPos = currentPosition; Vector3 oldPos = oldPosition; Vector2 newRectPos; RectTransformUtility.ScreenPointToLocalPointInRectangle(rectCanvas.transform as RectTransform, Input.mousePosition, rectCanvas.worldCamera, out newRectPos); incisionDistance.GetComponent <RectTransform>().localPosition = newRectPos; incisionDistance.GetComponent <Text>().text = (Vector3.Distance(oldPos, curPos) / MeshManager.Instance.pivotTransform.localScale.z).ToString("N3") + " mm"; lineRenderer.SetFixedLineRenderer(oldPos, curPos); } else if (Input.GetMouseButtonUp(0) && firstIncision) { if (checkInside) { Vector3 currentPosition = intersectedValues.IntersectedPosition; if (Vector3.Distance(oldPosition, currentPosition) < 2.5f * MeshManager.Instance.pivotTransform.lossyScale.z) { Destroy(incisionDistance); Destroy(lineRenderer.lineObject); EventManager.Instance.Events.InvokeModeManipulate("EndAll"); ChatManager.Instance.GenerateMessage(" incision 거리가 너무 짧습니다."); IncisionManager.IncisionUpdate(); firstIncision = false; return; } } Destroy(lineRenderer.lineObject); bool checkEdge = false; IncisionManager.SetEndVerticesDF(); IncisionManager.SetDividingListDF(ref checkEdge); if (checkEdge) { IncisionManager.leftSide.RemoveAt(IncisionManager.currentIndex); IncisionManager.rightSide.RemoveAt(IncisionManager.currentIndex); //incisionCount--; IncisionManager.IncisionUpdate(); EventManager.Instance.Events.InvokeModeManipulate("EndAll"); Destroy(incisionDistance); Destroy(this); return; } // 위에서 잘못되면 끊어야됨. Debug.Log(MeshManager.Instance.mesh.vertexCount); IncisionManager.ExecuteDividing(); AdjacencyList.Instance.ListUpdate(); IncisionManager.GenerateIncisionList(); MakeDoubleFaceMesh.Instance.MeshUpdateInnerFaceVertices(); //MeshManager.Instance.SaveCurrentMesh(); IncisionManager.currentIndex++; MeshManager.Instance.mesh.RecalculateNormals(); // chatmanager 대신 popup manager에서 팝업 호출하기. ChatManager.Instance.GenerateMessage(" 절개하였습니다. 확장이 가능합니다."); Destroy(incisionDistance); mode = "extand"; EventManager.Instance.Events.InvokeModeManipulate("EndWithoutScaling"); } }