private void DrawingCut() { IntPtr left = CGAL.CreateMeshObject(); IntPtr right = CGAL.CreateMeshObject(); IntPtr stamp = CGAL.CreateMeshObject(); float[] verticesCoordinate = CGAL.ConvertToFloatArray(AdjacencyList.Instance.worldPositionVertices.ToArray()); if (CGAL.BuildPolyhedron(left, verticesCoordinate, verticesCoordinate.Length / 3, MeshManager.Instance.mesh.triangles, MeshManager.Instance.mesh.triangles.Length / 3) == -1) { Debug.Log(" 만들어지지 않음"); } if (CGAL.BuildPolyhedron(right, verticesCoordinate, verticesCoordinate.Length / 3, MeshManager.Instance.mesh.triangles, MeshManager.Instance.mesh.triangles.Length / 3) == -1) { Debug.Log(" 만들어지지 않음"); } ///left right 생성이 됨. ///이상태에서 ///plane의 노말값만 바꿔서 슬라이싱함. /// Vector3[] newVertices = new Vector3[rayList.Count * 2]; int[] newTriangles = new int[rayList.Count * 6]; CGAL.GenerateStamp(rayList, ref newVertices, ref newTriangles); float[] newVerticesCoordinate = CGAL.ConvertToFloatArray(newVertices); if (CGAL.BuildPolyhedron( stamp, newVerticesCoordinate, newVerticesCoordinate.Length / 3, newTriangles, newTriangles.Length / 3 ) == -1) { Debug.Log(" 만들어지지 않음"); } CGAL.FillHole(stamp); CGAL.ClipPolyhedronByMesh(left, stamp); // CGAL.GenerateNewObject(left, leftMaterial); // 여기에 이제 잘리고나서 작업 넣어줘야됨. 새로운 메쉬로 바꾸고 정리하는 형태가 되어야함. // 라인렌더러 넣어줘야함. MeshManager.Instance.Heart.SetActive(false); }
private void CGALCut() { if (isIntersected) { AdjacencyList.Instance.ListUpdate(); Debug.Log("intersected true"); IntPtr heart = CGAL.CreateMeshObject(); IntPtr stamp = CGAL.CreateMeshObject(); float[] verticesCoordinate = CGAL.ConvertToFloatArray(AdjacencyList.Instance.worldPositionVertices.ToArray()); if (CGAL.BuildPolyhedron(heart, verticesCoordinate, verticesCoordinate.Length / 3, MeshManager.Instance.mesh.triangles, MeshManager.Instance.mesh.triangles.Length / 3) == -1) { Debug.Log(" 만들어지지 않음"); return; } Vector3[] newVertices = new Vector3[rayList.Count * 2]; int[] newTriangles = new int[rayList.Count * 6]; CGAL.GenerateStampWithHeart(intersectedVerticesPos, rayList, ref newVertices, ref newTriangles); float[] newVerticesCoordinate = CGAL.ConvertToFloatArray(newVertices); if (CGAL.BuildPolyhedron( stamp, newVerticesCoordinate, newVerticesCoordinate.Length / 3, newTriangles, newTriangles.Length / 3 ) == -1) { Debug.Log(" 만들어지지 않음"); return; } if (CGAL.FillHole(stamp) == -1) { Debug.Log("fillhole error"); return; } if (CGAL.ClipPolyhedronByMesh(heart, stamp) == -1) { Debug.Log("Clip error"); return; } MeshManager.Instance.SetNewObject(CGAL.GenerateNewObject(heart, heartMaterial)); MakeDoubleFaceMesh.Instance.Reinitialize(); ////CGAL.GenerateNewObject(stamp, leftMaterial); //// 여기에 이제 잘리고나서 작업 넣어줘야됨. 새로운 메쉬로 바꾸고 정리하는 형태가 되어야함. ////MeshManager.Instance.Heart.SetActive(false); } else { IntPtr heart = CGAL.CreateMeshObject(); IntPtr stamp = CGAL.CreateMeshObject(); float[] verticesCoordinate = CGAL.ConvertToFloatArray(AdjacencyList.Instance.worldPositionVertices.ToArray()); if (CGAL.BuildPolyhedron(heart, verticesCoordinate, verticesCoordinate.Length / 3, MeshManager.Instance.mesh.triangles, MeshManager.Instance.mesh.triangles.Length / 3) == -1) { Debug.Log(" 만들어지지 않음"); return; } Vector3[] newVertices = new Vector3[rayList.Count * 2]; int[] newTriangles = new int[rayList.Count * 6]; CGAL.GenerateStamp(rayList, ref newVertices, ref newTriangles); float[] newVerticesCoordinate = CGAL.ConvertToFloatArray(newVertices); if (CGAL.BuildPolyhedron( stamp, newVerticesCoordinate, newVerticesCoordinate.Length / 3, newTriangles, newTriangles.Length / 3 ) == -1) { Debug.Log(" 만들어지지 않음"); return; } if (CGAL.FillHole(stamp) == -1) { Debug.Log("fillhole error"); return; } if (CGAL.ClipPolyhedronByMesh(heart, stamp) == -1) { Debug.Log("Clip error"); return; } MeshManager.Instance.SetNewObject(CGAL.GenerateNewObject(heart, heartMaterial)); MakeDoubleFaceMesh.Instance.Reinitialize(); //// 여기에 이제 잘리고나서 작업 넣어줘야됨. 새로운 메쉬로 바꾸고 정리하는 형태가 되어야함. ////MeshManager.Instance.Heart.SetActive(false); } }
private void CGALCut() { if (isIntersected) { Debug.Log("intersected true"); MultiMeshAdjacencyList.Instance.Initialize(); IntPtr HeartPart = CGAL.CreateMeshObject(); IntPtr stamp = CGAL.CreateMeshObject(); float[] verticesCoordinate = CGAL.ConvertToFloatArray(MultiMeshAdjacencyList.Instance.WorldPositionVertices[HitOBJIndex].ToArray()); if (CGAL.BuildPolyhedron(HeartPart, verticesCoordinate, verticesCoordinate.Length / 3, MultiMeshManager.Instance.Meshes[HitOBJIndex].triangles, MultiMeshManager.Instance.Meshes[HitOBJIndex].triangles.Length / 3) == -1) { Debug.Log(" 만들어지지 않음"); return; } Vector3[] newVertices = new Vector3[rayList.Count * 2]; int[] newTriangles = new int[rayList.Count * 6]; CGAL.MultiMeshGenerateStampWithHeart(intersectedVerticesPos, rayList, ref newVertices, ref newTriangles, HitOBJIndex); float[] newVerticesCoordinate = CGAL.ConvertToFloatArray(newVertices); if (CGAL.BuildPolyhedron( stamp, newVerticesCoordinate, newVerticesCoordinate.Length / 3, newTriangles, newTriangles.Length / 3 ) == -1) { Debug.Log(" 만들어지지 않음"); return; } if (CGAL.FillHole(stamp) == -1) { Debug.Log("fillhole error"); return; } if (CGAL.ClipPolyhedronByMesh(HeartPart, stamp) == -1) { Debug.Log("Clip error"); return; } MultiMeshManager.Instance.SetNewObject(CGAL.GenerateNewObject(HeartPart, heartMaterial, HitOBJIndex), HitOBJIndex); MultiMeshManager.Instance.ReInitialize(); } else { IntPtr HeartPart = CGAL.CreateMeshObject(); IntPtr stamp = CGAL.CreateMeshObject(); float[] verticesCoordinate = CGAL.ConvertToFloatArray(MultiMeshAdjacencyList.Instance.WorldPositionVertices[HitOBJIndex].ToArray()); if (CGAL.BuildPolyhedron(HeartPart, verticesCoordinate, verticesCoordinate.Length / 3, MultiMeshManager.Instance.Meshes[HitOBJIndex].triangles, MultiMeshManager.Instance.Meshes[HitOBJIndex].triangles.Length / 3) == -1) { Debug.Log(" 만들어지지 않음"); return; } Vector3[] newVertices = new Vector3[rayList.Count * 2]; int[] newTriangles = new int[rayList.Count * 6]; CGAL.GenerateStamp(rayList, ref newVertices, ref newTriangles); float[] newVerticesCoordinate = CGAL.ConvertToFloatArray(newVertices); if (CGAL.BuildPolyhedron( stamp, newVerticesCoordinate, newVerticesCoordinate.Length / 3, newTriangles, newTriangles.Length / 3 ) == -1) { Debug.Log(" 만들어지지 않음"); return; } if (CGAL.FillHole(stamp) == -1) { Debug.Log("fillhole error"); return; } if (CGAL.ClipPolyhedronByMesh(HeartPart, stamp) == -1) { Debug.Log("Clip error"); return; } MultiMeshManager.Instance.SetNewObject(CGAL.GenerateNewObject(HeartPart, heartMaterial, HitOBJIndex), HitOBJIndex); MultiMeshManager.Instance.ReInitialize(); } }