Splines and implementation in engine

Started by
3 comments, last by phayer 11 years, 9 months ago
Hi

So I'm making my own game engine for educational purpose mostly, but also for using to make games.
After reading a couple of books and looking on how to implement animation, networking, and path finding I decided that splines would be nice to have implemented before heading in.

So I've created a couple of examples of splines, but here is my show stopper. How should splines be implemented? Should there be a Spline-class and then have different types of splines inherit it? Should results be cached and re-cached every time a point or detail bias changes?

Generally asking for how other people have done it, and tips for how I can do it.
Advertisement
If I were you I would keep it simple. One class and that's it, specifying the type of spline on the constructor. As far as I know, splines are just a bunch of points, so it shouldn't be that complicated, I think you don't even need something such as "spline type"


But that's just me.
I agree, keep it simple and don't worry too much about wether one implemention might be better than another. Too much of this and you'll never get anything done.
So I've created a couple of examples of splines, but here is my show stopper. How should splines be implemented? Should there be a Spline-class and then have different types of splines inherit it? Should results be cached and re-cached every time a point or detail bias changes?
That entirely depends on the problem you're trying to solve.
A bunch of free-functions (not class members), which can evaluate different spline formulas, plus a Point structure to be used as inputs into those functions, is probably all you need.

If I were you I would keep it simple. One class and that's it, specifying the type of spline on the constructor. As far as I know, splines are just a bunch of points, so it shouldn't be that complicated, I think you don't even need something such as "spline type"


But that's just me.


Well, this lead to a switch(this->m_iType)... So I went with a namespace for splines inside my math namespace. Just a bunch of free functions.

This topic is closed to new replies.

Advertisement