Sign in to follow this  
phayer

Splines and implementation in engine

Recommended Posts

phayer    150
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.

Share this post


Link to post
Share on other sites
Acotoz    73
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.

Share this post


Link to post
Share on other sites
h4tt3n    1974
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.

Share this post


Link to post
Share on other sites
Hodgman    51223
[quote name='phayer' timestamp='1341677621' post='4956661']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?[/quote]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.

Share this post


Link to post
Share on other sites
phayer    150
[quote name='Acotoz' timestamp='1341720978' post='4956819']
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.
[/quote]

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.

Share this post


Link to post
Share on other sites

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