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.

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 12th Jun 2016 01:54 Edited at: 12th Jun 2016 01:56
Just a quick look at the Catmull-Rom editor I've knocked together for my next game.

Check the video for some nice looking real-time adjusted movement which would work nice for affected wave patterns, emitted and targeted enemies etc. if you happened to be making that sort of arcade game.

Just one more thing to add which is the limited node recalculation (currently the whole sequence is recalculated when adjusted).

george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 12th Jun 2016 08:37
It is very nice and useful.
Great work!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Jun 2016 05:12
Nice. Maybe you can help me out, I'm doing similar things but I am struggling with keeping a constant speed. I can see in your video that you have the same issue - the tighter the curve, the slower you travel. Do you have a way to solve this problem?

Something I have been tinkering with...
https://www.youtube.com/watch?v=F-qNFbfRoKc
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 13th Jun 2016 19:13
Funny that - I was talking to someone today about calculating a constant speed.

I'm thinking of some kind of method which either generates a different number of points depending on the distance or perhaps change the update (step) frequency accordingly.

I'm thinking that the speed (a speed multiplier) between nodes can be calculated during the curve generation and stored against each node for backwards and forwards.

There may be something already out there on the web, as all these curve functions are points over time. I've just been focusing on getting things as fast as possible and a speed controller would be very useful.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 13th Jun 2016 22:34 Edited at: 13th Jun 2016 22:38
This seems to crop up a fair bit it seems.
The most promising solution (which doesn't use approximation or very heavy computation) is this one:

http://forum.unity3d.com/threads/waypoints-and-constant-variable-speed-problems.32954/

I shall give it a go and see how it works out.

This guy also applied catmull rom to a moving track which might be useful (source code is on the link also)
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 14th Jun 2016 10:14
You just have to write a normalize function for you catmull rom and everything will be fine, it won't be 100% correctly, but it comes close to your wish.

[/url]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Jun 2016 12:13
I just read the thread. It looks like this is a simple solution...

Quote: "1. after setting up splines in my editor, I would generate a linear array of points.
2. to create the array you traverse the spline as you normally do, however you only add a point to the array when DISTANCE between the current position and the last sample point is greater than n."


Many years ago, this is how I managed my tracks in a very simple project.

I was interested in the theory that you could use the length of the curve handles to calculate the velocity. I use nodes and handles to create a c-spline. But it would need to be combined with the angle of the curve which makes it very complex.
For example, you could have handles close to zero from the node, but the angle could be anything from 0 to 180 degrees.

Quote: "You just have to write a normalize function for you catmull rom and everything will be fine"

For me, the word just is complicated.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jul 2016 21:20 Edited at: 22nd Jul 2016 21:26
I tackled the constant speed issue with beziers in the past and finally worked up a solution. Mathematically, my method wouldn't be useful. For games, it totally works. It's just a bit slow if you have dynamic splines shapes. Changing it is nothing, I'm referring to constantly moving the spline each clock cycle.

Since on the screen the spline curves are drawn with a series of straight lines you can run through the spline data once to calculate the overall length of the spline. Essentially, imagine taking a coiled up piece of yarn and laying it out in a straight line. You want to travel at X speed, add X to current distance on the spline. Divide that by the length you calculated and you have your time index, not for the line segment but the entire spline. You then figure out which line segment will correspond with that time. I have an example somewhere. Problem is, I don't remember what language I wrote it in so I forget where to look.


Found it! It was indeed with AppGameKit, though for beziers. Same concept should apply to catmull rom splines.
https://forum.thegamecreators.com/thread/210460

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Jul 2016 14:32
Thank you! Saved for later.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-11-21 23:53:03
Your offset time is: 2024-11-21 23:53:03