Yet another update so soon? Well I think this one is important. It involves the creation of a regeneratable fractal set for game geometry. I have been, as some people who I have been idea swapping with know, been contemplating putting a few different styles of curves into CI. Some people say "So what? Q3:A and others will have them. CS already has them." I say to them, yes but they are just an extension on polygons, they may be more natural, but a true polynomial curve in nature is rare. Nature doesn't follow normal equations, it is based on fractals, which is to say, that nature is in fact random, but the thresh-hold of randomness actually gets smaller between each other random iteration. To explain it better than I ever could, go to: http://www.gameprogrammer.com/fractal/fractal.html which explains fractals rather well, and puts them in the context of the old diamond square landscape routine. Now, once you have an understanding of fractals you can read on... Okay, now comes the fractal curve bit. Imagine you have a triangle. You take each line segment used to make the triangle, generate your random value and off set in the direction of the triangle normal. Now connect these 3 points up and guess what? You have split your triangle into 4 triangles. And you can repeat this over, but be aware, after the first loop, triangles share line segments, and each midpoint you generate for a line must be used on both triangles. Also, if you use multiple interlinked fractal curves, you must make sure the edges share values. I assume also,that you know to use the roughness to reduce each pass? If you don't go read the listed above doc. This will get you a simle fractal curve. Importantly, you may wish to "seed" iterations of the fractal, by predefining values. You may want to do this if you want your fractal curve to link up with non fractal polygons, or you may want something that resembles a polynomial or sinus curve. Seeding can be done rather easily. For polynomials or sinus curves, you would have to seed probably 3 iterations. LOD comes in two variaties. You can precalculate the whole fractal, up to a certain number of iterations and then remove later iterations from drawing as you need more detail, or such. This takes a lot of memory, especially for large fractals, and it doesn't offer infinate LOD. I use a different method. It solves the problems of BOTH the a forementioned problems. What I do is make a re-creatable fractal. I do this by using a look up table array of arround 64 random numbers per curve. Then, when doing your fractal iterations, always make sure you do them in the same order. That way you can just loop through the 64 random numbers, and multiply them by the iterations roughness. That way, no matter what the random numbers will be the same. If 64 random numbers per curve is too much for you, as you inteand to have many curves, You can use say 4 look up tables for the entire engine, of say 255 in size, and then for each curve save two variables. One is the randomly selected table number, the other is the offset to start on in the table. That way, you pretty much get a random result ;-). Seeding in most circumstances is saved, unless of course you predefine the iterations algorithmically for pass. One thing I can not emphasise enough though is... CACHE THE FRACTAL!. When you deterimine one is visibile, and you process it, store it in a structure like the texture cache. It means simply that you can store it and keep it until it is overwritten by the next LOD. This saves you valuable time and memory. Conor Stokes PS Congrats To Henry Robinson, and welcome to ranks!
|