Jump to content

  • Log In with Google      Sign In   
  • Create Account

Create infinite curve


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 19 November 2013 - 01:11 AM

So I basically start with a straight line from 0,0 to 0,10 (x,y space),and i need to add another line of that length,connected to the old one,but which slowly makes a curve,then another one....

 

The point is,I want the lines connected.

 

The bigger problem is doing this for infinite time.How would you go about it?



Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 13912

Like
1Likes
Like

Posted 19 November 2013 - 01:16 AM

We are going to need either a much better description of the situation (ideally including why you are trying to do this) or a picture of what you want this to look like: My mind-reading skills are not what they used to be. ;)

#3 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 19 November 2013 - 01:23 AM

I just need to code random generated curves forever. For example,you start with 100 floats,representing points. With those 100 floats you have to create a random curve.When you move forward,you delete the first float,and create a new one,but that new one IS based on the 99th one.Basically each new float is somehow linked to the float behind it.

 

or look at it from this point,you always have 100 points.You first create a curve.Whenever the player moves forward,you create a new point where the player WAS last time,and that new point is creating a new curve.

 

So,if player is is on point 1,but moves to point 2,point 1 will equal to a new point.You do that untill all points have been recreated to form a new curve.


Edited by noatom, 19 November 2013 - 01:31 AM.


#4 Álvaro   Crossbones+   -  Reputation: 13912

Like
0Likes
Like

Posted 19 November 2013 - 01:32 AM

Sorry, but you are still not making a lot of sense. I don't understand what you are trying to do, or the connection between the 100 floats and the random curve, or what you mean by a float being based on another, or the nature of the link between the new float and the float behind it.

You probably have a more natural problem in mind, and you convinced yourself that it could be reduced to something like what you are describing. If you explain the circumstances in which the need to solve this problem arose, we will be in a much better position to help you.

#5 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 19 November 2013 - 01:58 AM

ok,the real problem is: " implement a road ,that has curves,and that goes one forever". When it says goes on forever,it means that when the player goes forward,the road will become longer.

 

its in 2d space btw


Edited by noatom, 19 November 2013 - 02:06 AM.


#6 HappyCoder   Members   -  Reputation: 2879

Like
0Likes
Like

Posted 19 November 2013 - 02:11 AM

If I understand you correctly, you are wanting to create something similar to snake right? Meaning you have a path and you have a head of the path where it grows but as it grows at the head, the tail gets shorter so you always have the same number of points, right?

#7 apatriarca   Crossbones+   -  Reputation: 1774

Like
0Likes
Like

Posted 19 November 2013 - 03:20 AM

I am assuming only a quite small part of the curve is visible at any time. If the player can only move forward you can then simply store the visible portion of the curve and generate new parts as needed. The old parts can be easily discarded. If the player can also move backwards you probably need something more complicated (but it depends on your needs).

#8 LorenzoGatti   Crossbones+   -  Reputation: 2763

Like
1Likes
Like

Posted 19 November 2013 - 03:46 AM

I suggest starting with an actual implementation of driving along an arbitrary finite road. This way, apart from dealing with more difficult parts first, you are forced to develop a sufficiently general representation for arbitrary road sections (for example, a bunch of polygons or large tiles) and you only need to implement updates of the road representation and random generation of reasonable road sections to allow the player to drive forever. I suggest looking for inspiration in an old MS-DOS game, Stunts (aka 4D Sports Driving), which has 3D graphics but friendly tiles in the level editor: track pieces include for example 2x2 tiles large 90° curves, single tile tight 90° curves, 2x1 vertical or corkscrew loops, hills and ramps rising 1 level in 1 tile length, etc. Every tile consists of a few polygons, instanced in a simple 3D scene with an arbitrary camera, extremely aggressive culling of distant geometry, and a skybox. Your game could lay down this kind of road pieces in "unexplored" parts of the map, without replacing previously encountered road sections. Another reference: OutRun, where the fixed view allows the road to be a sequence of coarsely juxtaposed very short sections (you can go down to about 1 pixel) with a smoothly varying vertical and horizontal displacement from the previous section. Add random road width changes, objects (e.g. roadside boulders) and a little traffic, and you have specified everything.
Produci, consuma, crepa

#9 ferrous   Members   -  Reputation: 2146

Like
0Likes
Like

Posted 21 November 2013 - 08:04 PM

I may be misunderstanding, but you want a curve that you can add control points to?  That should be straightforward enough.  As long as you keep adding points to a spline, it will keep getting longer.  A catmull rom spline, my go-to spline, only looks at 4 control points at a time, so you can remove points that are already off-screen, and add more on as they approach on-screen.  (I also like catmull rom because all the control points are on the curve)






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS