Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any tutorial for stitcher?
#3
Thank you for your help.
I finally make it work perfectly all in runtime without exporting/importing xml files or manual property painting.

My concern, at this moment, is that I may have problem when obi simulation keeps going and moves particles away while the AutoStitcher.cs is trying to find out particle pairs within the range of designated distance. 
Let me know your thought. Should I set stitches before starting (building) a game?
Code:
    public void StitchActorsRuntime()
    {
        ObiStitcher obiStitcher = gameObject.AddComponent<ObiStitcher>();
        obiStitcher.Actor1 = actor1;
        obiStitcher.Actor2 = actor2;

        int mask = 0;
        int category = 0;
        int filter = ObiUtils.MakeFilter(mask, category);

        for (int i = 0; i < actor1.particleCount; i++)
        {

            int index1 = actor1.GetParticleRuntimeIndex(i);
            Vector3 pos1 = actor1.GetParticlePosition(index1);

            for (int l = 0; l < actor2.particleCount; l++)
            {
                int index2 = actor2.GetParticleRuntimeIndex(l);
                Vector3 pos2 = actor2.GetParticlePosition(index2);
                float distance = Vector3.Distance(pos1, pos2);
                if (distance < stitchMergin)
                {
                    obiStitcher.AddStitch(i, l);
                   
                    int solverIndex = actor1.solverIndices[i];
                    solver.filters[index1] = filter;
                }
            }
        }

        obiStitcher.PushDataToSolver();
    }
Reply


Messages In This Thread
Any tutorial for stitcher? - by Snail921 - 16-10-2021, 11:23 AM
RE: Any tutorial for stitcher? - by josemendez - 18-10-2021, 07:39 AM
RE: Any tutorial for stitcher? - by Snail921 - 21-10-2021, 06:45 AM
RE: Any tutorial for stitcher? - by josemendez - 21-10-2021, 08:33 AM
RE: Any tutorial for stitcher? - by Snail921 - 21-10-2021, 05:16 PM
RE: Any tutorial for stitcher? - by josemendez - 22-10-2021, 07:44 AM
RE: Any tutorial for stitcher? - by Snail921 - 23-10-2021, 08:36 AM
RE: Any tutorial for stitcher? - by josemendez - 25-10-2021, 09:15 AM