Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope saving and restore by Json
#15
Hi!

Neither of these will work.

(11-07-2024, 07:21 AM)tapLucas Wrote: 1. I found that the order of rope.elements is continuous, so I tried to store this and restore it to solver.positions[particlesIndices[i]], but it did not work.

Storing particle data in the order dictated by elements isn't the same as storing particles in their original order and then accessing them in the order defined by elements. For starters you will be duplicating the amount of particles, and to make things worse the order in which particles are accessed will be broken. You need to store elements themselves, then restore the elements when loading the rope.

(11-07-2024, 07:21 AM)tapLucas Wrote: 2. I tried to store the index of rope.solverIndices and the corresponding solver.positions[particlesIndices[i]] and restore them, but it did not work.

This will ignore elements completely, so the order of particles will also be wrong.

Ropes are very similar to meshes: there's a list of vertex (particle) positions, and then a list of triangles (elements) that tell you how vertices/particles are attached to each other. You must store both if you want to keep the shape of the rope. For instance, imagine these are your particles:

A,B,C,D,E

and these your elements:

(0,2)(1,3)(3,4)

The resulting rope would be:

A--C  B--D--E

Notice how the order in which particles appear in the rope is different to the order in which they are stored, and how there's a cut in the rope (as particles C and B aren't connected by any element). There's 5 particles but only 3 elements. You need to reflect this in the data you store for your ropes, otherwise particles won't be properly connected. This can only be done by storing both particles and elements, altering the order in which you store the particles is not enough.

kind regards,
Reply


Messages In This Thread
Rope saving and restore by Json - by tapLucas - 22-06-2024, 03:32 PM
RE: Rope saving and restore by Json - by tapLucas - 22-06-2024, 06:37 PM
RE: Rope saving and restore by Json - by tapLucas - 25-06-2024, 09:02 AM
RE: Rope saving and restore by Json - by tapLucas - 25-06-2024, 09:31 AM
RE: Rope saving and restore by Json - by tapLucas - 25-06-2024, 09:55 AM
RE: Rope saving and restore by Json - by tapLucas - 25-06-2024, 10:26 AM
RE: Rope saving and restore by Json - by tapLucas - 27-06-2024, 11:54 AM
RE: Rope saving and restore by Json - by tapLucas - 27-06-2024, 12:59 PM
RE: Rope saving and restore by Json - by tapLucas - 11-07-2024, 07:21 AM
RE: Rope saving and restore by Json - by josemendez - 12-07-2024, 08:50 AM
RE: Rope saving and restore by Json - by tapLucas - 17-08-2024, 09:02 AM
RE: Rope saving and restore by Json - by tapLucas - 17-08-2024, 10:37 AM
RE: Rope saving and restore by Json - by tapLucas - 17-08-2024, 11:10 AM