Sign in to follow this  
web_scripter

Spline Movement Path

Recommended Posts

web_scripter    127
Hello How can i make a spline and get an object to move along the spline and also rotated correctly? I already have the objects all i need is way to make spline paths and move the object along it. I'm using Managed directX C# Thanks Web_scripter

Share this post


Link to post
Share on other sites
circlesoft    1178
(a) Search Google or something for 'spline'. There are *tons* of resources out there on it, as it is a very popular topic. The math behind it is pretty simple, as is the code.

(b) Pick a particular type of spline to work with (there are many types, including Natural Cubic, Bezeir, and Catmull-Rom). Bezeir is particularlly popular and also has many, many resources available.

Share this post


Link to post
Share on other sites
S1CA    1418
You'll find the most resources on the internet for Bézier*.

If you have a set of points that the spline must pass through, then I'd recommend Catmull-Rom. Technically, just joining a bunch of control points up with straight lines is a spline; just a linear one.

Moving an object along the spline is just a matter of specifying a 't' value between 0 and 1 to control how far along the current segment of the spline you want to be and computing the position in space for that value of 't'.

And as if by magic, fellow DirectX MVP, Robert Dunlop wrote the following article [smile]:

http://www.mvps.org/directx/articles/catmull/

It's aimed at C++ and DirectX 8, but the spline parts should port easily to managed languages and newer SDK versions.

A google for something like catmull+rom or spline+tutorial will get you some more.

[*Dustin, a rhyme I use to remember: "I before E, except after C" [wink]]

Share this post


Link to post
Share on other sites
circlesoft    1178
Quote:
Original post by S1CA
[*Dustin, a rhyme I use to remember: "I before E, except after C" [wink]]

D'oh! You gotta love the English language...for a deity as complex as any science, the rule just can't hold its own weight, my good neighbor. But yea, that generally works [lol]

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