Spline interpolation w/o SplineObject?
On 15/01/2017 at 20:10, xxxxxxxx wrote:
Cinema 4D Version: R18
Platform: Mac ;
Language(s) : C++ ;
Greetings to all.
Is there any way to perform spline interpolation in C4D without creating a SplineObject?
I have a plugin that needs to reinterpolate a bunch of points along a 3D spline. I'm currently creating a bunch of SplineObjects to do this, using them to calculate the interpolated vertices without actually adding them to the scene, then throwing them away. I'm also using SplineLengthData to (approximately) interpolate uniformly across the length of the spline.
This kinda works... except it doesn't, really.
My problem is that SplineObject doesn't seem to interpolate values across the mathematical curve created by the input vertices. Instead, it appears to be interpolating values across the line object representation of that spline, similar to what you see in the viewport if the intermediary points setting is set to "uniform" and the "number" setting is exceptionally low (1 or 2). I can actually see the facets of the spline in the interpolated data, which is no good.
I have found that I can twiddle with the settings of the SplineObject to change this behaviour (exactly as you'd do for a spline object in the attribute manager), but this still doesn't solve my problem. Even if I set the intermediary points to uniform and give it an arbitrarily high value (1024 or 2048), under certain circumstances I can still see the facets of the line object SplineObject appears to be interpolating with.
Is there any way to work around this behaviour? Or am I going to have to write my own 3D spline solver library? I'd rather not re-implement a bunch of spline types C4D already supports natively, but it seems like there's no way to interpolate a curve smoothly without the subdivision settings of SplineObject affecting the results. If I am going to have to write my own 3D spline library, does anyone have any resources that would be a good place to start (or any sample code I could see)?
On 16/01/2017 at 09:13, xxxxxxxx wrote:
please have a look at CalcSplinePoint() and see if it suits your needs.
On 18/01/2017 at 00:30, xxxxxxxx wrote:
That kinda looks like what I'm after, since the interpolated results certainly seem to be higher quality (and I don't have to muck around with the parameters on a SplineObject). Unfortunately, it also appears to be very slow, which I'm guessing has something to do with the fact that it's not a class that can save and reuse some of the internal state required to interpolate values across the spline (so those are being recalculated on each call). It also doesn't seem to work with SplineLengthData (since it's not a SplineObject), and I can't seem to find any equivalent for that either.
Anyways, thanks for your response. Looks like I'm going to have to try and write my own code to handle this instead. I'm guessing there's no way MAXON would ever consider posting the code they use to interpolate values over Cubic/B-Spline/Akima splines, is there? That would be of great help to me, though I can understand why that might not be possible.