Obi Official Forum
Help Circular rope? - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Help Circular rope? (/thread-3266.html)



Circular rope? - ECoins - 09-01-2022

Hi Jose,

I'm wondering what is the best way to create a rope that is circular. As the path edit tool isn't too accurate when used in the editor, I attempted to do this in code/runtime with the below, I've just taken out parts relevant to the co-ordinates of the points. The result is a square with rounded corners aha. Any assistance would be appreciated.

[attachment=1221]



Code:
var p0 = new Vector3(0, 0, -1);
var p1 = new Vector3(1, 0, 0);
var p2 = new Vector3(0, 0, 1);
var p3 = new Vector3(-1, 0, 0);

bluePrint.path.AddControlPoint(p0, new Vector3(-1, 0, 0), new Vector3(1, 0, 0), Vector3.up, 0.1f, 0.1f, 1, 1, Color.yellow, "p0");
bluePrint.path.AddControlPoint(p1, new Vector3(0, 0, -1), new Vector3(0, 0, 1), Vector3.up, 0.1f, 0.1f, 1, 1, Color.yellow, "p1");
bluePrint.path.AddControlPoint(p2, new Vector3(1, 0, 0), new Vector3(-1, 0, 0), Vector3.up, 0.1f, 0.1f, 1, 1, Color.yellow, "p2");
bluePrint.path.AddControlPoint(p3, new Vector3(0, 0, 1), new Vector3(0, 0, -1), Vector3.up, 0.1f, 0.1f, 1, 1, Color.yellow, "p3");



RE: Circular rope? - josemendez - 09-01-2022

(09-01-2022, 04:36 PM)ECoins Wrote: Hi Jose,

I'm wondering what is the best way to create a rope that is circular. As the path edit tool isn't too accurate when used in the editor, I attempted to do this in code/runtime with the below, I've just taken out parts relevant to the co-ordinates of the points. The result is a square with rounded corners aha. Any assistance would be appreciated.





Code:
var p0 = new Vector3(0, 0, -1);
var p1 = new Vector3(1, 0, 0);
var p2 = new Vector3(0, 0, 1);
var p3 = new Vector3(-1, 0, 0);

bluePrint.path.AddControlPoint(p0, new Vector3(-1, 0, 0), new Vector3(1, 0, 0), Vector3.up, 0.1f, 0.1f, 1, 1, Color.yellow, "p0");
bluePrint.path.AddControlPoint(p1, new Vector3(0, 0, -1), new Vector3(0, 0, 1), Vector3.up, 0.1f, 0.1f, 1, 1, Color.yellow, "p1");
bluePrint.path.AddControlPoint(p2, new Vector3(1, 0, 0), new Vector3(-1, 0, 0), Vector3.up, 0.1f, 0.1f, 1, 1, Color.yellow, "p2");
bluePrint.path.AddControlPoint(p3, new Vector3(0, 0, 1), new Vector3(0, 0, -1), Vector3.up, 0.1f, 0.1f, 1, 1, Color.yellow, "p3");

Hi!

Your control point tangents seem too long. Just make them shorter.

To approximate a unit circle using a bézier path, a good tangent length is around 0.5 as explained here:
https://stackoverflow.com/questions/1734745/how-to-create-circle-with-bézier-curves


RE: Circular rope? - ECoins - 10-01-2022

(09-01-2022, 08:59 PM)josemendez Wrote: Hi!

Your control point tangents seem too long. Just make them shorter.

To approximate a unit circle using a bézier path, a good tangent length is around 0.5 as explained here:
https://stackoverflow.com/questions/1734745/how-to-create-circle-with-bézier-curves

I have taken the number (0.55...) from the post and it works perfectly now. Thank you!