Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manually Placing Rope Particles
#2
(17-07-2017, 02:02 PM)PhantomBadger Wrote: I'm looking to sync the position of the rope over a network, my initial test is getting the positions of the particles via the


Code:
ObiRope.GetParticles(index)

method, networking these values, then setting them on the other side, however I cannot seem to set them. My current attempt is as follows;



Code:
   private void SetPositions()
   {
       if (entity.isAttached)
       {
           for (int i = 0; i < ObiRope.UsedParticles && i < PositionArrayHardLimit; i++)
           {
               state.RopePositions[i] = ObiRope.GetParticlePosition(i);
           }
       }
   }

   private void GetPositions()
   {
       if (entity.isAttached)
       {
           for (int i = 0; i < ObiRope.UsedParticles && i < PositionArrayHardLimit; i++)
           {
               ObiRope.Solver.renderablePositions[ObiRope.particleIndices[i]] = state.RopePositions[i];
               ObiRope.Solver.UpdateActiveParticles();
           }
       }
   }
I can confirm that state.RopePositions contains the correct values when referenced by the client, but I'm unable to tell the solver to use these positions. Is this a thing that is even possible with ObiRope? Am I going about this all wrong? Any help would be appreciated!

GetParticlePosition() returns the final rendered position of a particle, so it's good when you want to post-process particle positions each frame. Not good at all if you want to transfer positions to another rope. The rendered position is usually not the same as the actual, physical position in the simulation due to several reasons:

- The rendered position might be the result of interpolating the previous frame's position and the current one (when the solver has interpolation enabled).
- Modifiers such as particle smoothing might offset the particle position only for rendering purposes. This modified position is not fed back into the simulation for the next frame.

The easiest (and fastest) way to do what you look for is to use the low-level getters/setters. These give you access to the solver particle positions/velocities/masses/etc directly. Take a look at the last part of this page:

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


Messages In This Thread
RE: Manually Placing Rope Particles - by josemendez - 17-07-2017, 03:43 PM