Sign in to follow this  

Splines and implementation in engine

This topic is 1985 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

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
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
[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
[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

This topic is 1985 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