Esempio n. 1
0
    public void Simulate()
    {
        GameObject   go           = new GameObject("A piece of cloth");
        DeformObject deformObject = go.AddComponent <DeformObject>();

        go.transform.parent        = deformManager.transform.parent;
        go.transform.localPosition = new Vector3(0, 1, 0);
        go.transform.localRotation = Quaternion.AngleAxis(90, new Vector3(1, 0, 0));

        Mesh mesh = clothModels[0].GetComponent <BoundaryPointsHandler>().GetComponent <MeshFilter>().sharedMesh;

        //deformObject.SetMesh(mesh);
        //deformObject.SetMaterial(garmentMaterial);
        deformObject.mesh     = mesh;
        deformObject.material = garmentMaterial;


        //deformManager.Reset();


        //////////////
        //yolo
        /////////////
        List <int> yobro = VibbiMeshUtils.DefineSeamFromLines(clothModels[1].GetComponent <BoundaryPointsHandler>().boundaryLines[0], clothModels[0].GetComponent <BoundaryPointsHandler>().boundaryLines[1]);

        Debug.Log(yobro.Count);
        for (int i = 0; i < yobro.Count; i += 2)
        {
            Debug.Log(yobro[i] + " " + yobro[i + 1]);
        }
    }
Esempio n. 2
0
    /*public bool ClothIsLoaded(GameObject cloth){
     *      var clothModelMesh = cloth.GetComponent<MeshFilter> ().sharedMesh;
     *
     *      for (int index = 0; index < clothPieces.Count; index++) {
     *              if (clothPieces[index].GetComponent<MeshFilter> ().sharedMesh.Equals (clothModelMesh)) {
     *                      return true;
     *              }
     *      }
     *      return false;
     * }*/

    public void LoadSeam(GameObject seam)
    {
        Debug.Log("Load Seam");
        var  seamBehaviour       = seam.GetComponent <SeamBehaviour> ();
        int  firstLineMeshIndex  = -1;
        int  secondLineMeshIndex = -1;
        bool firstMeshFound      = false;
        bool secondMeshFound     = false;



        for (int index = 0; index < clothPieces.Count; index++)
        {
            //Check if first cloth is loaded
            if (clothPieces[index].GetComponent <MeshFilter> ().sharedMesh.Equals(seamBehaviour.GetFirstMesh()))
            {
                Debug.Log("Mesh 1 is previously loaded");
                firstLineMeshIndex = index;
                firstMeshFound     = true;
            }

            //Check if second cloth is loaded
            if (clothPieces[index].GetComponent <MeshFilter> ().sharedMesh.Equals(seamBehaviour.GetSecondMesh()))
            {
                Debug.Log("Mesh 2 is previously loaded");
                secondLineMeshIndex = index;
                secondMeshFound     = true;
            }
        }


        if (firstMeshFound && secondMeshFound)
        {
            List <int> LineVerticeIndices = VibbiMeshUtils.DefineSeamFromLines(seamBehaviour.GetFirstLine(), seamBehaviour.GetSecondLine());

            if (LineVerticeIndices.Count <= 0)
            {
                Debug.Log("Seam edge contains 0 vertices, aborting!");
                return;
            }

            CreateGarmentSeam(firstLineMeshIndex, secondLineMeshIndex, LineVerticeIndices, seam);
        }
    }
Esempio n. 3
0
 //Called when triangulating
 public void UpdateIndices()
 {
     lineVerticeIndices = VibbiMeshUtils.DefineSeamFromLines(seam.GetComponent <SeamBehaviour>().GetFirstLine(), seam.GetComponent <SeamBehaviour>().GetSecondLine());
 }