Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Making smooth curve movements
2010-10-21 19:50
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Making smooth curve movements

K, so i want to make some kinda smooth curves to move sprites along.

I know I could use specially tailored sinus data, but then i still have to code something to do the movement exactly as i want it.

So i consider to make a small movement recorder, where i move a sprite with a joystick, and record the path.

So, now comes the hard part: if i record some (as perfect as can be) movement (a path), then how could i flatten out the recorded data afterwards, so my imprefect drawn move, becomes super smooth ?

This is some math i know nothing about, anyone ?
 
... 18 posts hidden. Click here to view all posts....
 
2010-10-24 05:32
Martin Piper

Registered: Nov 2007
Posts: 722
The method I described would fit what you need.
2010-10-24 08:27
Hein

Registered: Apr 2004
Posts: 954
Quote: all i really want is, that when i move a sprite to record the path, the outcome becomes smooth. nomatter what kind amove i do.


if you have knowledge to code that on c64, then do.

f.ex i move diagonal up right, then hard down right, a triangle. then the tip of the triangle shouldnt be hard, it should become a small smooth curve.

get it ?


erm, first you say thanks, now you say fuck you.. wassup?

You can't expect people to do the code for you, else there's nothing to explore. I think there's enough options in this thread to choose from.
2010-10-24 19:32
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
get it ? = fuck you ?


if i hadnt complained before why csdb forums are utter shit, i do now, but it will be the last time.
2010-10-24 19:43
Hein

Registered: Apr 2004
Posts: 954
Quote: get it ? = fuck you ?


if i hadnt complained before why csdb forums are utter shit, i do now, but it will be the last time.


No help is good enough for you, is it?
2010-10-25 07:34
Frantic

Registered: Mar 2003
Posts: 1648
@Rambones:

You move your sprite, and you record a series of coordinates. You can make this curve smoother by averaging values. For each value N, you add it together with the value before, and the value after and then you divide the sum you get with 3, and store the result into a new table. Now each adjacent value will "influence" the other adjacent values in a way that makes the overall curve smoother. In order to make the division simpler to implement (i.e. division with 4 instead of 3) then you could always add value N two times to the sum, which would also give a weighting in favor of the actual value obtained at each point.

In case this will turn out too rough (depends on how rough your input data is), you can add the current value + two previous and two subsequent values. If this is too rough, then add values further back/ahead into each sum. A good idea is to always add the values together like a "pyramid". For example, for value 5 in the series (N5) and a "scope" of two values ahead/behind, you could add values like this:

        N5
     N4 N5 N6
  N3 N4 N5 N6 N7


This table means nothing else than N3+N4+N4+N5+N5+N5+N6+N6+N7 = X

Then you divide X with the number of values, X/9, to get the "smoothed" value for N5. Let's say you prefer to divide with 8 instead (if you do this on the C64 instead of pre-calcing it). Just remove one of these values and divide with 8 instead. It might very well look alright.

An alternative, in case your new table is still too rough, is to just run the same sort of calculation again in a second pass, to smooth the curve further.

A special case is when you deal with values in the beginning/end of the table, where you can't pick values ahead/behind because the table stops there.... You can figure out yourself how to deal with that in some way that looks alright.

Note that this approach will reduce all "peaks" in the data, so it will result in a path of movement which is more straight than the actual input. That is, it will not actually result in a curve which is "fitted" to the data as good as possible. For that you would have to do some curve fitting the way RadiantX suggested for example. Nevertheless, I suspect that you will find the approach I described here easier to understand/implement.

Note that most of the posts above were actually good and relevant answers to your question. What I suggest here is a worse approach than many of them, in terms of accuracy, but I guess it may work for your purposes.
2010-12-08 12:45
Partz
Account closed

Registered: Jun 2008
Posts: 17
I've been toying with the idea of writing an editor to do just this. The idea is that you will initially click on a canvas representing a visible screen space (say 320*200). Each click will add a vertex and between each vertex ALL points will be stored as calculated by a simple line drawing DDA. An option will then exist to smooth the points. There seem to be a fair few algorithms out there for this that don't call for the polynomial curves - much like the sliding window averaging approach mentioned above which looks like a simplified McMasters routine. The intention would be that vertex data could be saved off as either a dc.b text file for 64 usage or a static c# class/seriazable binary file for use in XNA.

I quite like the ideas regarding velocity discussed above - multiple objects look more natural bunching up and decelerating around a tight curve. Maybe if each vertex a target velocity for the end point so data is stored in x,y,v?. Might be a Christmas project.

Have you tried getting any of these ideas into a simple basic program yet, Rambones?
2010-12-08 12:53
Mace

Registered: May 2002
Posts: 1799
This tool you are talking about... will it be some 'other platform tool' or something that will actually run on a C64?
I prefer (by far) the second option :-)
2010-12-08 12:53
chatGPZ

Registered: Dec 2001
Posts: 11386
Quote:
if you have knowledge to code that on c64, then do.

so you don't actually want to know how this works, but you want someone to code it for you?

Quote:
f.ex i move diagonal up right, then hard down right, a triangle. then the tip of the triangle shouldnt be hard, it should become a small smooth curve.

and thats a typical usecase for splines, as various people told you already.
2010-12-08 20:24
Mace

Registered: May 2002
Posts: 1799
I think you should give Rambones a break, you are seeing things that aren't there...
2010-12-14 12:22
Partz
Account closed

Registered: Jun 2008
Posts: 17
Quote: This tool you are talking about... will it be some 'other platform tool' or something that will actually run on a C64?
I prefer (by far) the second option :-)


It will be "other platform". The intent is to do it in C# under windows. The output won't be C64 specific, it will provide output thats useable in my XNA too.
Previous - 1 | 2 | 3 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Bieno/Commodore Plus
XmikeX
ΛΛdZ
Dymo/G★P
Acidchild/Padua
Guests online: 85
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.7)
2 Fungus  (9.3)
3 Black Beard  (9.2)
4 Baracuda  (9.2)
5 hedning  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.048 sec.