Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Obi Stitcher 's problem
#6
(07-08-2020, 01:20 PM)josemendez Wrote: Hi,

Without a more in-depth description of your setup, I cannot know what's going wrong. My best guess is that you've not added a ObiClothRenderer component to your cloth? That's the only possible cause for the mesh and the particles to be out of sync.
Hi,
this is some setup of my Obi Cloth
https://drive.google.com/drive/folders/1...sp=sharing

(07-08-2020, 01:20 PM)josemendez Wrote: Hi,

Without a more in-depth description of your setup, I cannot know what's going wrong. My best guess is that you've not added a ObiClothRenderer component to your cloth? That's the only possible cause for the mesh and the particles to be out of sync.
Some codes:

Code:
    private IEnumerator StitchCloth()
    {
        if (sewingIndexA != null
            && sewingIndexB != null
            && sewingIndexA.Count > 0
            && sewingIndexB.Count > 0)
        {
            GameObject stitchObj = new GameObject("Stitch Object");
            stitchObj.transform.SetParent(transform);
            meshA.transform.SetParent(stitchObj.transform);
            meshB.transform.SetParent(stitchObj.transform);

            meshA.gameObject.AddComponent<ObiCloth>();
            meshA.gameObject.AddComponent<ObiClothRenderer>();
            meshB.gameObject.AddComponent<ObiCloth>();
            meshB.gameObject.AddComponent<ObiClothRenderer>();

            // generate blueprintA:
            var blueprintA = ScriptableObject.CreateInstance<ObiClothBlueprint>();
            blueprintA.inputMesh = meshA.mesh;
            yield return StartCoroutine(blueprintA.Generate());
            ObiCloth clothA = meshA.GetComponent<ObiCloth>();
            clothA.clothBlueprint = blueprintA;

            // generate blueprintB:
            var blueprintB = ScriptableObject.CreateInstance<ObiClothBlueprint>();
            blueprintB.inputMesh = meshB.mesh;
            yield return StartCoroutine(blueprintB.Generate());
            ObiCloth clothB = meshB.GetComponent<ObiCloth>();
            clothB.clothBlueprint = blueprintB;

            // sew both sides together:
            ObiStitcher stitcher = stitchObj.AddComponent<ObiStitcher>();
            stitcher.Actor1 = clothA;
            stitcher.Actor2 = clothB;
            for (int i = 0; i < sewingIndexA.Count; i++)
            {
                stitcher.AddStitch(sewingIndexA[i], sewingIndexB[i]);
            }

            // adjust bending constraints to obtain a little less rigid fabric:
            InitClothParameters(clothA);
            InitClothParameters(clothB);

            // push stitcher index to the solver
            stitcher.PushDataToSolver();
        }
    }

    private void InitClothParameters(ObiCloth cloth)
    {
        ObiParticleRenderer particleRD = cloth.gameObject.AddComponent<ObiParticleRenderer>();
        particleRD.shader = Shader.Find("Obi/Particles");
        cloth.selfCollisions = true;
        cloth.maxBending = 0.04f;

        cloth.volumeConstraintsEnabled = false;
        cloth.aerodynamicsEnabled = false;
        cloth.tetherConstraintsEnabled = false;
        cloth.maxCompression = 0.2f;

        for (int i = 0; i < cloth.blueprint.principalRadii.Length; i++)
        {
            cloth.blueprint.principalRadii[i] = Vector3.one * 0.3f;
        }
    }

I don't think there's a problem with that.
Reply


Messages In This Thread
Obi Stitcher 's problem - by jackdos - 06-08-2020, 12:24 PM
RE: Obi Stitcher 's problem - by josemendez - 06-08-2020, 12:31 PM
RE: Obi Stitcher 's problem - by jackdos - 06-08-2020, 12:32 PM
RE: Obi Stitcher 's problem - by jackdos - 07-08-2020, 01:17 PM
RE: Obi Stitcher 's problem - by josemendez - 07-08-2020, 01:20 PM
RE: Obi Stitcher 's problem - by jackdos - 07-08-2020, 01:32 PM
RE: Obi Stitcher 's problem - by josemendez - 07-08-2020, 02:36 PM
RE: Obi Stitcher 's problem - by jackdos - 10-08-2020, 11:21 AM
RE: Obi Stitcher 's problem - by josemendez - 10-08-2020, 12:18 PM
RE: Obi Stitcher 's problem - by jackdos - 10-08-2020, 12:38 PM
RE: Obi Stitcher 's problem - by josemendez - 10-08-2020, 12:40 PM