Splines and implementation in engine
#1 Members - Reputation: 141
Posted 07 July 2012 - 10:13 AM
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.
#2 Members - Reputation: 73
Posted 07 July 2012 - 10:16 PM
But that's just me.
#4 Moderators - Reputation: 13534
Posted 08 July 2012 - 12:23 AM
That entirely depends on the problem you're trying to solve.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?
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.
#5 Members - Reputation: 141
Posted 08 July 2012 - 06:04 AM
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.






