Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to change the rest length of an existing rope at runtime?
#4
(27-05-2021, 05:42 PM)Hatchling Wrote: I am not sure if I am modifying the constraints loaded in the solver through the code I posted. Your suggestion seems like it'd be the better way to do things, as I'd be directly modifying the data used to simulate the rope. (Note that I intend to apply this change AFTER the rope and its blueprint are fully generated and ready to simulate.)

Your code only modifies the constraint data in the blueprint. See: http://obi.virtualmethodstudio.com/tutor...aints.html for an example on how to modify constraints loaded in the solver at runtime. I believe this is a better approach in your case.


(27-05-2021, 05:42 PM)Hatchling Wrote: I am modifying native data (the blueprint appears to create this data) but this code applies before the blueprint is assigned to the rope. I'm guessing then that modifying the blueprint afterwards will not change the behaviour of the rope.

Exactly. What you're doing is the equivalent of modifying an .fbx file on disk, then loading it. However, modifying the blueprint afterwards will not have an impact on the data that's already loaded.

You'd want to modify the data loaded to memory from the .fbx instead. The end result is the same.

(27-05-2021, 05:42 PM)Hatchling Wrote: I'll look into what this ObiRopeCursor class does. Also I'm guessing that "stretching scale" is what I'd need to use to modify the rope's length at runtime.

ObiRopeCursor add/removes particles and constraints from a rope at a given point, while keeping the same resolution (amount of particles per unit length). Like so:

Before:
(1)-------(2)----/cursor>/---(3)-------(4)

After:
(1)-------(2)----/cursor>/---(5)-------(6)-------(3)-------(4)

Cursors are used in the Crane and FreightLift sample scenes to change the length of the rope.

Setting the rope's stretchingScale parameter will scale the rest length of each distance constraint (each "edge" in the rope, if you will). This is basically the same thing you're doing. This results in longer rope, but also reduces resolution (less particles per unit length, as length increases but the amount of particles does not). Think of it as scaling the rope along its medial axis:

Scale x1:
(1)-------(2)-------(3)-------(4)

Scale x1.5:
(1)------------(2)------------(3)------------(4)

Scale x2:
(1)-----------------(2)------------------(3)-----------------(4)

You can see what this looks like by tinkering with it in play mode, it's exposed in the rope's inspector.
Reply


Messages In This Thread
RE: How to change the rest length of an existing rope at runtime? - by josemendez - 28-05-2021, 08:08 AM