Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to Shorten or Scale the Length of an Obi Rod
#1
Hello,
I would like to either bake the shape of an Obi Rod or stop its simulation, and then shrink or extend its length.
Is there a way to achieve this through code?
Reply
#2
(6 hours ago)twocomet Wrote: Hello,
I would like to either bake the shape of an Obi Rod or stop its simulation, and then shrink or extend its length.
Is there a way to achieve this through code?

Hi,

It’s not possible, rods cannot have their rest length changed at runtime. See:
https://obi.virtualmethodstudio.com/manu...setup.html

Only option that comes to mind is baking the mesh generated by ObiRopeExtrudedRenderer, and then scaling the mesh. This doesn’t really “increase its length”, but rather just scale it which won’t give the same results unless the rod is completely straight and aligned with a local axis.

kind regards,
Reply
#3
(6 hours ago)twocomet Wrote: Hello,
I would like to either bake the shape of an Obi Rod or stop its simulation, and then shrink or extend its length.
Is there a way to achieve this through code?
Just dynamically change Sleep threshold to a large value https://obi.virtualmethodstudio.com/manu...olver.html
Reply
#4
(6 hours ago)josemendez Wrote: Hi,

It’s not possible, rods cannot have their rest length changed at runtime. See:
https://obi.virtualmethodstudio.com/manu...setup.html

Only option that comes to mind is baking the mesh generated by ObiRopeExtrudedRenderer, and then scaling the mesh. This doesn’t really “increase its length”, but rather just scale it which won’t give the same results unless the rod is completely straight and aligned with a local axis.

kind regards,

This is an intermediate result I tried.
I enabled the use of a Cursor in Obi Rod and fixed some bugs.
After deleting the cursor and reordering, I recorded a video showing that the length gets reduced at runtime.
It seems I need to make further adjustments for the extension part.
I feel like I might be approaching this too complicatedly—
is there really no alternative method besides the way I’m doing it?
Reply
#5
Rods rely on chain constraints to keep their length constant. Chain constraints affect *all* particles in the rod simultaneously (since they're solved using a tridiagonal matrix solver, which considers all particles and solves for their total length directly instead of iteratively), so changing the length of a rod requires rebuilding the chain constraint which is quite expensive. You could disable chain constraints, but this will usually result in the rod stretching excessively. Also, bend/shear attributes are not stored on particles but on constraints, so you'd need to access and copy these when extending the rod. These are the reasons why changing the length of a rod is not currently supported.

If you don't need chain constraints and don't need to add/remove particles from the rod, a considerably simpler solution would be to just scale the restLengths of the rod's stretch/shear constraints. See this on how to access and modify constraint values attributes at runtime.

Note that such a solution will affect collision detection negatively, as gaps may open in between particles. Also, the "segments" in the rod may become more visible. This is probably OK if the maximum/minimum length range of your rod is not very large.

kind regards,
Reply
#6
As a side note, I'm not entirely sure why you need to use rods instead of ropes. Your tentacles seem to be radially symmetric (so torsional effects will be hard to notice, if at all noticeable) and if you're going to procedurally control particle positions (as in the video in this thread), keeping a rest shape doesn't seem useful either as you'll be constantly driving the shape of the tentacles.
Reply