Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] BareBone spline + getValue (for automations and interpolation)

Author
Message
Thc03
21
Years of Service
User Offline
Joined: 19th May 2004
Location: Pavia - Italy
Posted: 14th May 2007 20:00
Hi there.
As I'm still working on my 3D engine, this is an example I just made to draw the simplest interpolation ever possible and find the y value for an x one.
I know it's confusing stated like this, but just try the snippet and see for yourself:
Using this, you can now draw arc-based splines (no control points yet) and get the Y value along the curve by an X offset.
The code illustrates a simple animation, the got point moves a step at a time.
It's made out in 10 minutes and it's really poor, but an interesting start point.


Share comments (suggestions _highly_ welcome)
.

Bye, Berserk.
.
Omen
18
Years of Service
User Offline
Joined: 7th Nov 2006
Location: Maple Grove, MN US
Posted: 18th May 2007 00:45
Maybe I'm missing something here, but DBPro already does this natively using the HERMITE and CATMULROM functions - which gives you the control points you need to make any spline... you can even do it using a 4-dimension vector using VECTOR4 instead of VECTOR3.

For both, the SValue is the percent along the spline curve from which you want the VectorResult coordinates. I've used both of these in my own code for movement prediction and they are very fast and accurate.

HERMITE VECTOR3 VectorResult, VectorA, VectorB, VectorC, VectorD, SValue

CATMULLROM VECTOR3 VectorResult, VectorA, VectorB, VectorC, VectorD, SValue

...but like I said, maybe I'm missing something
Thc03
21
Years of Service
User Offline
Joined: 19th May 2004
Location: Pavia - Italy
Posted: 18th May 2007 02:44
No, you're missing nothing
My problem is those functions don't tell me how do they behave, so I'm trying to figure out.
I also have difficults with "ordinary" tutorials as are plenty of C/C++ with mixed maths, while a code line should stay the same regardless of the language it's being written for.
Unfortunately, C/C++ rules like a lobby and Pascal resources are somewhat fragmented and hard to find.
So, all I have left to do is patiently discover things
While we're here discussing this, can you suggest me good sites with tutorials wich don't require C/C++ knowledge?
And, where can I ask the same question in order to be assured for lots of visibility?
.

Bye, Berserk.
.

Login to post a reply

Server time is: 2025-08-09 01:38:58
Your offset time is: 2025-08-09 01:38:58