Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy ropes in play mode
#3
(16-01-2024, 08:41 AM)josemendez Wrote: Hi!

Assuming both ropes have the same amount of particles, it's just a matter of iterating trough their elements copying particle positions as you go. Each element points to the correct indices in solver.positions for the current rope. See: http://obi.virtualmethodstudio.com/manua...ropes.html

If they have different amounts of particles, then things get considerably more complex as you need to decide whether to remove excess particles from one rope, add extra particles to the other one, where to remove/add particles from/to, connect them using new constraints, etc. Most of this can be handled automatically using a ObiRopeCursor, however it works in terms of length - instead of particles - so it would also require some non trivial work.


Not sure what you mean, sorry. All ObiParticleRenderer does is render the particles so that you can visualize them: it doesn't copy particles, duplicate the rope or anything similar?
I was trying to anticipate the answer and said that you can get what you want if you just change the material in ObiParticleRenderer, so we would kind of change the ropes visually, but their background would stay the same. However, I happen to have two ObiRope, and so far this way excludes risks related to future requirements. Yes, I already guessed that it is possible to copy their positions into the new obiRope before disconnecting the old obiRope. However, if I understand correctly we get access to the particles from solver.positions, and there may be positions of particles of other ropes of solver. I need the positions of a separate obiRope. And yes, you are right, I need to add the missing particles to the front or back of the rope. ObiRopeCursor as far as I know only works in rantime, and if we add 100 particles in 1 frame it will cause jerks, also if we do it asynchronously in n milliseconds it may still not work stable until we slow it down enough to stop causing jerks, and slow lengthening and shortening is not really what is needed. Another thing is to collect a rope from particles of another rope while its modeling is turned off, and after turning it on, set velocity on each particle to 0 (I hope so we can prevent jerks) and then we can stably replace one rope with another, with longer ends on those parts where the first rope had no particles at all. The question is this:
- how to get the positions and velocities of a separate ObiRope
- how to safely place all new particles on the places of old ones before starting modeling of the copied rope, while adding missing ones to the beginning or end.
- How to turn on the copied rope and avoid jerks and vibrations.

As you can see from the code, I create a BluePrint from the code according to the distance from object a to object b, and sometimes there is an object in the middle between a and b. And as far as I know the number of particles is created automatically. So in one case where there are 10 unit meters from a to b, roughly speaking a rope of 10 particles will be created. The rope to be created at a different distance, for example we add object c and we need to extend it to 15 units. So we will have two ropes, one with 15 particles, the other with 10. If I copy the positions from 1 to 10 particles, the 5 will remain in the old places and there will be a jump. How to avoid this.


or another question, how to create a rope with 10 units, and already copy the positions of the first to the second. In the code I provided I don't control the number of particles, and they are created depending on the distance of the two ControlPoints.
Maybe to create new ControlPoints I can copy the positions from the old ControlPoints from the first rope. Then FlushEvents on the new rope should logically create the same number of particles than the current number of particles on the old rope.
Reply


Messages In This Thread
Copy ropes in play mode - by Alexander34 - 08-01-2024, 03:53 PM
RE: Copy ropes in play mode - by josemendez - 16-01-2024, 08:41 AM
RE: Copy ropes in play mode - by Alexander34 - 16-01-2024, 02:47 PM
RE: Copy ropes in play mode - by josemendez - 16-01-2024, 07:42 PM
RE: Copy ropes in play mode - by Alexander34 - 16-01-2024, 08:08 PM
RE: Copy ropes in play mode - by josemendez - 17-01-2024, 11:08 AM