(07-08-2020, 01:20 PM)josemendez Wrote: Hi,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.
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,Some codes:
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.
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.