I have recently purchased Curvy V8 and need to model twisting objects (e.g. a ribbon). What I want to be able to do is have one end of a spline fixed, and the rest of it free to be twisted an arbitrary number of times. So if it is rotated 720 degrees, it will have two twists which will remain until I apply counter rotations to reverse them. I have tried two approaches so far, and do not understand what needs to happen to get this to work:
1) Using code and a generator to create a mesh that looks like what I need and applying rotations to the X axis of the segments of the associated spline.
2) Modifying the CGDeformMesh_BarbedWire example to use a Cube game object rescaled to look like a ribbon and manually adjusting the X rotation value on the first CP of the spline.
In case 1, I can twist the spline and the entire mesh does rotate but I cannot see how to fix one end, say to a stationary game object. I tried iterating through all of the CPs (rotating each of them) with the exception of the very last point in the spline that I want to remain unrotated, thinking that might work, but it does not. The entire mesh rotates even if I leave out that last point.
In case 2, I can manually change the X axis and get the mesh to twist but as soon as it passes 180 degrees the mesh flips rather than accumulating the multi-turn twists I am after.
How do I attach one end of a spline/mesh so that either the first or the last segment remains fixed and the rest is free to rotate and visually twist up? What would be helpful is a code example showing how to do this. I have looked at the API and it is great if you already know what you are doing but it is very sparse when it comes to example snippets for Curvy beginners. I would appreciate some assistance if anyone has any suggestions as to what I can try.
The key element you are missing is the Swirl and Turns parameters of Control Points. An additional concept that can be helpful is the Orientation Anchor. To learn more about these, check the documentation here:
https://curvyeditor.com/documentation/splines/curvysplinesegment
Once you understand these concepts, applying them via API should be easy. For example:
yourSpline.Turns = 2;
Make sure the 3d mesh you are twisting has enough vertices to allow for a twist that looks nice.
Did this help?
Have a nice day.
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Unfortunately, that does help and perhaps I have not been clear enough. I have already looked at the API entry for CurvySplineSegment and I cannot understand what needs to happen to solve what I am trying to do, as I explained above.
I am not trying to simply twist a spline all at once (e.g. by setting mySpline.Turns = 2), but I want to continuously rotate the spline to arrive at the final rotation. So I tried this:
for (int i = 0; i < Single_Ribbon_Spline.ControlPointsList.Count- 2; i++) // the number of segments is 1 less than the number of CPs by definition, but we do not want to twist the last segment, hence why the index is -2
{
CurvySplineSegment thisSegmentToTwist = Single_Ribbon_Spline.ControlPointsList[i];
thisSegmentToTwist.transform.rotation = Quaternion.Euler(syncEulerAngles.y, 0, 0); // rotate each segment
msh_0.transform.rotation = Single_Ribbon_Spline.transform.rotation; // this works but twists the entire spline including what should be the fixed end
}
That does not work and I do not know why.
I do not know how orientation anchors will help. -Perhaps they are the answer, but the API documentation lacks clear examples to explain how that might work.
So lets try again with a simple conceptual example:
We have a cube on each end of a spline.
Both cubes are attached (parented? somehow anchored?) to the spline.
One cube remains fixed (Cube 1), while the other cube (Cube 2) rotates continuously sharing the same axis as the spline.
Because Cube 2 is rotating, the result will be that the spline (and its associated mesh with enough vertices) twists like a rope.
If we continue twisting it will knot up, if we reverse twist it will unknot -just like a rope.
Sounds simple but I have hit a wall with the API and referring me back to it at this point will not help.
Given that your expertise with Curvy far exceeds my own at the moment, can you (or anyone) provide a code sample showing how what I am trying to implement can be accomplished? Suggestion: it would be great to add something like this to the Curvy deformation examples!
Rotating a Control Point to induce a spline twist works only up to 180°. Anything beyond needs the Swirl feature.
Every CP in the spline is part of an Orientation Anchor Group. A group is limited by two Orientation Anchors. By default, a spline has only one group, and the anchors are the first and last CPs.
To visually distinguish Orientation Anchors, make sure to set the right visualization settings, and look for the anchor icons
Swirl settings are available only to orientation anchors. When you set a swirl, you can choose to apply it to a segment, or to a whole group.
To set a CP as an Orientation Anchor, tick the Orientation Anchor setting in its inspector.
I attached a scene that does what I understood you need. The second cube is place just at the end of the swirling group. Since it has a spline controller, its orientation is defined by the splines'. In other words: Swirl -> change spline orientation -> change cube orientation.
To learn more about spline orientation, here is a link to this tutorial. It is old now, so the settings shown in the video have a bit changed since, but you can get the global idea I believe:
https://www.youtube.com/watch?v=hHLdW_FRtfw
Please let me know if this helped or not.
Have a nice day.
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Ok, spline CPs not being able to rotate beyond 180 degrees accounts for part of what I was encountering. I have imported the scene you posted and have set the swirl type to Anchor Group Abs to assure a constant rotation rate. From your (very helpful) explanation, it certainly does look like Swirl combined with Anchors will do exactly what I need and I appreciate your assistance with this.
I am out of time today and will look at the tutorial you suggested tomorrow along with trying this out in my project. Now I have a path forward and I will get back to you with the results.
-thanks
(05-10-2024, 01:36 PM)_Aka_ Wrote: Hi,
Rotating a Control Point to induce a spline twist works only up to 180°. Anything beyond needs the Swirl feature.
Every CP in the spline is part of an Orientation Anchor Group. A group is limited by two Orientation Anchors. By default, a spline has only one group, and the anchors are the first and last CPs.
To visually distinguish Orientation Anchors, make sure to set the right visualization settings, and look for the anchor icons
Swirl settings are available only to orientation anchors. When you set a swirl, you can choose to apply it to a segment, or to a whole group.
To set a CP as an Orientation Anchor, tick the Orientation Anchor setting in its inspector.
I attached a scene that does what I understood you need. The second cube is place just at the end of the swirling group. Since it has a spline controller, its orientation is defined by the splines'. In other words: Swirl -> change spline orientation -> change cube orientation.
To learn more about spline orientation, here is a link to this tutorial. It is old now, so the settings shown in the video have a bit changed since, but you can get the global idea I believe:
https://www.youtube.com/watch?v=hHLdW_FRtfw
Please let me know if this helped or not.
Have a nice day.