Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reset rope starting shape?
#2
(13-02-2020, 12:18 PM)basilisk Wrote: I have a coiled rope that unwinds nicely when the rope is enabled. I want to have the rope reset to it's starting coiled shape every time I activate it. How to I reset the rope to it's original shape?

All you need to do is set the solver's particle positions/velocities to the ones stored in the blueprint. If you're using a rod (which makes use of oriented particles), do the same with particle orientations/angular velocities.

Only thing you need to be a bit careful with is converting the blueprint data (which is expressed in local space) to solver space. Like this:

Code:
void Reset(ObiActor actor)
{
        if (actor.isLoaded)
        {
            Matrix4x4 l2sTransform = actor.actorLocalToSolverMatrix;
            Quaternion l2sRotation = l2sTransform.rotation;

            for (int i = 0; i < actor.particleCount; ++i)
            {
                int solverIndex = actor.solverIndices[i];

                actor.solver.positions[solverIndex]  = l2sTransform.MultiplyPoint3x4(actor.blueprint.positions[i]);
                actor.solver.velocities[solverIndex] = l2sTransform.MultiplyVector(actor.blueprint.velocities[i]);

                if (actor.usesOrientedParticles)
                {
                    actor.solver.orientations[solverIndex] = l2sRotation * actor.blueprint.orientations[i];
                    actor.solver.angularVelocities[solverIndex] = l2sTransform.MultiplyVector(actor.blueprint.angularVelocities[i]);
                }
            }
        }
}

See:
http://obi.virtualmethodstudio.com/tutor...icles.html
Reply


Messages In This Thread
Reset rope starting shape? - by basilisk - 13-02-2020, 12:18 PM
RE: Reset rope starting shape? - by josemendez - 13-02-2020, 01:11 PM
RE: Reset rope starting shape? - by basilisk - 13-02-2020, 02:54 PM
RE: Reset rope starting shape? - by josemendez - 13-02-2020, 05:15 PM
RE: Reset rope starting shape? - by basilisk - 13-02-2020, 06:04 PM