Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Match object orientation with a rope section (or particle)
#1
Hi,

I'm trying to create a 3D ring around the specific point of the rope. So far I have been able to set the position correctly using ObiPathSmoother.GetSectionAt() and some TransformPoint(). However, I couldn't get the orientation right. The ObiPathFrame given to me from ObiPathSmoother.GetSectionAt() do have main axis data (normal, binormal, and tangent), however, they seem to not align with the section orientation. It sometimes align sometimes don't (I Debug.DrawRay all 3 values and they're not align). Am I missing something here?

I'm using rope, so I think I can't use the orientation of the particle itself as I thought rope don't simulate particle orientation?

Here's the code for setting both position and rotation.
Code:
ObiPathFrame section = mainRopePath.GetSectionAt(normalizeRopePoseOf62CM);
ring62CMHighlight.transform.position = mainRopePath.transform.TransformPoint(section.position);
ring62CMHighlight.transform.rotation = Quaternion.LookRotation(section.tangent, section.binormal);

Thanks
Reply
#2
(21-08-2023, 12:04 PM)Alberos Wrote: Hi,

I'm trying to create a 3D ring around the specific point of the rope. So far I have been able to set the position correctly using ObiPathSmoother.GetSectionAt() and some TransformPoint(). However, I couldn't get the orientation right. The ObiPathFrame given to me from ObiPathSmoother.GetSectionAt() do have main axis data (normal, binormal, and tangent), however, they seem to not align with the section orientation. It sometimes align sometimes don't (I Debug.DrawRay all 3 values and they're not align). Am I missing something here?

Hi! the frames returned by GetSectionAt() are used to build the rope mesh every frame, so they must match the rope.

Your code correctly transforms the frame position from actor to world space, however it doesn't do the same with rotation. So unless your rope transform is exactly at 0,0,0, with zero rotation, the rotation value will be completely wrong. Here's the fixed code:

Code:
var trfm = smoother.transform;
ObiPathFrame section = smoother.GetSectionAt(m);
ring62CMHighlight.transform.position = trfm.TransformPoint(section.position);
ring62CMHighlight.transform.rotation = trfm.rotation * Quaternion.LookRotation(section.tangent, section.binormal);

(21-08-2023, 12:04 PM)Alberos Wrote: I'm using rope, so I think I can't use the orientation of the particle itself as I thought rope don't simulate particle orientation?

Correct, rope particles don't have any orientation information. The frames returned by GetSectionAt() are built using parallel transport, that is: an orthonormal frame is "transported" along the path defined by particle positions, aligned to the path's tangent while trying to minimize rotation. This gives an accurate estimate for 2 out of all 3 axis, but the third one (torsion along the rope) is essentially random.

kind regards,
Reply
#3
Hi, as always, thanks for the quick respond. I have edited my code using your reply and it working perfectly now, thanks!
Reply