Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Edit control points properties from script
#2
(10-12-2021, 04:39 PM)lufydad Wrote: And re-add control points with the new properties. However, I think this method is neither efficient, nor clean.

Is there another way to do it ?

Hi!

Yes, you can modify the path's data channels directly. When you add a control point, all the data passed to AddControlPoint() is stored in data channels (arrays) that you can then query for interpolated values along the spline. You can also read and write data directly from these. No need to wipe the path clean and redo everything. See the API documentation for the ObiPath class:

[Image: plZZDK0.png]

You can for instance set the third control point position to 10,0,0, and its color to red:

Quote:// winged points are value types (structs) so get a copy of it, modify and write back:
var point = blueprint.path.points[2];
point.position = new Vector3(10, 0, 0);
blueprint.path.points[2] = point;

// set the color to red:
blueprint.path.colors[2] = Color.red;

FYI, the reason why data is internally stored in separate arrays is because the interpolation method is different for each data type. For instance positions are interpolated using catmull-rom, filters/phases interpolated using constant interpolation, etc. It also allows for easy addition/removal of extra data channels for a path.
Reply


Messages In This Thread
RE: Edit control points properties from script - by josemendez - 10-12-2021, 05:36 PM