Sign in to follow this  

Curves Editor + Splines

This topic is 3316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First, can anyone recommend a good curve editor? Something that works well with either 2D bezier-curves or 2D splines? Right now I'm using Photoshop's "Curve" editor to generate my curves (saved to .acv) but I'd rather not be tied down to Photoshop and don't like that it maps values to a byte (remapping to a normalized value is not a big deal but I wouldn't mind something that did this for me). I want to edit curves for things like input remaps and GUI element movement so the interface can be relatively simple (as it should be). An editor/viewer seems pretty quick and simple to cook up but I wanted to see if any good solutions existed before writing my own. And yes, I did search google without any acceptable results (as a standalone win32 app meeting these criteria). Second, I'm using the algorithm described in "numerical recipes in c" to generate my spline based off of the curve points but it's a bit slow and inefficient for my tastes. I'll be calling the "spline interpolation" function many times a frame for potentially many on-screen items and can see the calculations really bog down the cpu (the algorithm doesn't seem very cache friendly - valid assumption?). Since my x values are relatively sequential, I may do as the book advises and optimize as such (i.e. coherency caching), but I'd hate to tie myself to that assumption and would rather just have a more optimal algorithm, even if it's not as effective (i.e. curves not as smooth). Any constructive thoughts are greatly appreciated.

Share this post


Link to post
Share on other sites
I'm not surprised that you don't see any tools. This is a very simple thing to put into tools, and the results will be custom to your own app. I've a few just like it over the years.



I can't imagine what you're doing with splines that is eating all your CPU. They shouldn't be that bad.



For your tool you've got two tasks: Control point manipulation and the rendering of your spline.

Control points are easy: Drop some boxes down at the appropriate places on your GUI. Then handle mouse down, move, and up, as appropriate to manipulate your control points. Boom, you're done.

Line segments for rendering the tools aren't bad. You can draw the splines by stepping between the control points. Ten line segments is normally plenty, and can be generated and rendered almost instantly. Feed it into the gui as a polyline with eleven points.

If you want to spend more time on the tool, you can make your artists more happy by a few improvements. Add tangent lines to your control points. It doesn't help too much, artists like it. Next, put in a 'spline preview quality' slider that adjusts the number of line segments between 5 and 50. Once those are in, add a feature that actually improves the art by snapping control points to adjacent points or that snaps adjacent tangent lines into straight lines.

That's 1-2 days of work for the basics, or a few more for inexperienced tool writers.





Spline interpolation should not be bogging down a CPU, even if you are processing hundreds of splines.

The math for the curves boils down to a simple polynomial function that is just two matrix multiplies. Fill up a vector with the knot distance to the 0,1,2,3 exponents, another with your four influencing control points, and finally the matrix containing the polynomial coefficients.

You can substitute whatever set of coefficients you want, Hermite spline, Bezier, Catmull-Rom, or a few others. The work for any of them is identical, just two matrix multiplies. Ten seconds on Google yields this page which shows the code required for splines.

Share this post


Link to post
Share on other sites
Yeah I already had something similar to what you described working in about two hours (biggest stumbling block was finding out .acv's are big-endian so need byte-swaps). I just wanted to know if anyone else has solved this problem with a free app.

Also, I should have been more clear but I'm talking about cubic splines here, not bezier curves. I'd rather not have to define control point tangents. You're right though, it probably won't be too bad computationally.

Thanks for the help.

Share this post


Link to post
Share on other sites

This topic is 3316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this