Scripting - New Wiki entry: Splines, Catmull-Rom algorithm

Funkas
Non-Commercial Pro Edition
Joined 28 February 2008
15 May 2008 21:11:36
Hi All,

I've dropped a new article to the Wiki about smooth movement with splines, using Catmull-Rom algorithm. Here it is:
http://www.dxstudio.com/wiki.aspx?n=Splines,%20Catmull-Rom%20algorithm%20for%20smooth%20movement
This entry contains also a small demo which shows an example of coding. Have fun!
BUnzaga
Commercial Pro Edition
Joined 07 June 2006
15 May 2008 21:57:54
That is very cool Funkas. I was just thinking about pathfinding while I was driving home. I was trying to think of the best way to make/break paths durring runtime. Such as if a building was created or destroyed how would you re-build the path to either go around the object or NOT go around an empty spot.

I was thinking you could dynamically create the waypoint and then shoot a ray to the position of the next waypoint to see if the path is blocked or not. If it is blocked, rotate the ray until it is no longer blocked, and then that x,z becomes the new spot for the waypoint chain.

I thought you could build waypoints dynamically based on distance... So something like:

distanceBetween point1 and point2 = 100units.

100/10=10, so you would start at poin1 and create a waypoint. Next go out 10 units from point1 and build your second waypoint. Test to see if it is blocked. If it is not blocked, go out 10 more units from the second waypoit and make a third waypoint, repeat this until you get to the destination point.

If the path happened to be blocked, then rotate 5 degrees and see if the path is no longer blocked, repeat until the path is not blocked, and then create the next waypoint.

I guess something like this isn't very effecient though.

Anyway, that is very cool, and I hope we can get some more people interested in dynamic pathfinding.
Funkas
Non-Commercial Pro Edition
Joined 28 February 2008
15 May 2008 22:33:48
I've never used the event function onPathBlocked().
may be it is something, which has to handle the cases you have described?
Honestly, I've also never achieved any satisfying results wit the built in waypoins system. May be I'm wrong about it, but i.e object.path.currentTargetNode doesn't work at all, (not for me by all means).
Therefore I prefere to code things anew. You have surely noticed the Catmull demo produces casual about 1000 waypoints at run time, (subdivision) and none of them is the native one from our API.
You are right, it's very interesting thing, I will in the future make som search on A* algorithm.
BUnzaga
Commercial Pro Edition
Joined 07 June 2006
16 May 2008 00:51:53
Yea I haven't had much success with the internal waypoint system either, but they are saying it is one of the improvments in the up and coming versions.

I've tried a couple times to make some different A* pathfinding systems, one even used two separate node systems, a major node system and a minor node system. Sort of like highways and streets...
StereoMike
Non-Commercial Pro Edition
Joined 09 June 2007
16 May 2008 09:19:02
Funkas, this is frigging awesome! I'm flabbergasted, gobsmacked or whatever you call it. Thanks for that!
I'd give you more bonus points, but you already got mine!

mike
BUnzaga
Commercial Pro Edition
Joined 07 June 2006
16 May 2008 10:01:41
Same here, you already have my +1
Funkas
Non-Commercial Pro Edition
Joined 28 February 2008
16 May 2008 10:18:58
Thanks Mike,
nice to hear it
I would give You my points too. And someone whose name is Edwin Catmull. See photo:


Both is impossible.
Carl
Non-Commercial Pro Edition
Joined 26 July 2007
16 May 2008 10:20:21
Very nice Funkas!!, +1 from me
Myrkling
Non-Commercial Std Edition
Joined 28 February 2008
16 May 2008 10:21:57
Well done, your article is a good read!
Cardek
Commercial Pro Edition
Joined 01 June 2008
13 April 2009 23:58:44
Great work Funkas.
There's only one detail I don't understand and it's probably a bit off-topic:
the lookAtRot function. Normally you look from the object.pos at the node and here it's the contrary.
Why?
Edit:I've searched the forum and seen that it's not so rare. Is it a bug of the engine or just that the mesh is facing the wrong way?
ucm
Commercial Pro Edition
Joined 17 October 2007
16 April 2009 07:48:36
Whoa!! Funkas You did it again! Something spactacular for us

If you'd like to post to this forum, just create an account on the website, or login with your existing details.

When posting to a forum, you can use limited HTML tags:- 'a' for links, 'b' for bold, 'i' for italic and 'script' to encase a block of DX Studio script.  All tags must be properly closed. e.g. <script>var i=1;</script>

Note: If there are any offensive comments in this topic, please let us know straight away at . Always follow the forum rules.