Edit control points properties from script - 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: Edit control points properties from script (/thread-3226.html) |
Edit control points properties from script - lufydad - 10-12-2021 Hi! I'm trying to create a rope from script that can be edited in runtime. Therefore, I need to add and edit control points in a blueprint in runtime. I found how to add control points with AddControlPoint(), but the only way I found to edit properties of a given control point in runtime, is by deleting all control points with this : Code: int nbrControlPoint = _blueprint.path.ControlPointCount - 1; 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 ? RE: Edit control points properties from script - josemendez - 10-12-2021 (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. 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: 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: 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. RE: Edit control points properties from script - lufydad - 13-12-2021 Thanks a lot ! I'll try this solution. |