Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'd like to seed a void map with "branches" of sine waves or any other waveform. Something like:

enter image description here

Know of any algorithm? Has to be one to generate trees or something like that.

share|improve this question
    
If you're looking for an actual tree rather than a non-uniform branching structure then you might like to look at L-Systems. Otherwise, you'll need to consider whether or not your tree structure is balanced, its depth and breadth limits, and whether or not branches can overlap. Does your root have to be in the center or at the bottom? Do branches have to follow some direction relative to their parent (i.e. always ending above the parent, or can they go anywhere)? –  Martin Foot Dec 13 '11 at 20:44
    
Are you looking for a 2D or 3D algorithm? What do you mean by "small branches"? Why not just to use the approach you suggested with sinus functions spawned at certain random distances from each other? –  Alexander Galkin Dec 13 '11 at 21:30
add comment

2 Answers

up vote 4 down vote accepted

What is the ultimate purpose of this algorithm supposed to be? Do you want to generate random roads? Branches for a tree? In 2D or 3D space?

The best approach might be to put a bunch of random points on the map, then do a minimum spanning tree. You can then use quadratic or cubic interpolation to make the lines curve into eachother.

Alternately, if you want to generate a tree-like structure in 3-space, you should investigate quaternion rotations, and rotating points about an abitrary axis.

share|improve this answer
    
2D, seed a map to generate a continent with MPD algorithm. This "tree" would be a mountain/s range. –  Gabriel A. Zorrilla Dec 13 '11 at 22:57
    
By MPD you mean Mid Point Displacement? Is this for the purpose of constructing and efficient mesh? You might also want to look at: codeflow.org/entries/2011/nov/10/… - the source is on github –  Gavan Woolery Dec 15 '11 at 0:12
add comment

If the your usage is creating landscape (or trees themselves) you can also look into fractal generating algorithms for example:

http://en.wikipedia.org/wiki/Pythagoras_tree_(fractal)
en.wikipedia.org/wiki/Fractal

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.