Best way to program a high-detailed, huge (infinite) world

Started by
27 comments, last by Subotron 21 years, 4 months ago
I don''t know anything about the 3D and mapping aspect of this questions, but i have some input on the infinite aspect ...

First, you can can use random generation of terrain and new areas, but not in the simple way described here .. because first of all, it wouldn''t let the player return to the areas they had been before ... So

IF you get any random generation engine created, it should A) be predictable, in that given the same input / seed, it generated the same data (this way you can store only the seed for each quadrant that has already been visited but is not in view) B) you need some way of making the 9 neigboring sqaures blend together smothly, and this algorithm must be deterministic as well ...

Second ... this is the internet age, and there are many amazing ways you can use this fact ... for one, let every client have the option of connecting to a central server, just to get map information, and possible even to SEND map information back to the server ... and THINK HARD about the doors this opens up ... first of all, it means a human being (you) can carefully create the terrain as needed, and make it available on your server ... and if you combine this with the random generator, then you get this amazing synergy ...

the human create an area, if a player exceeds its scope, he is invisibly feed randomly generated terrains, the terrain seeds are stored locally, until he next communicates with the server (which can be often while playing), then he sends the seeds he generated, and so on ... so the server generates this data, and makes it available to all ... so EVERYONE is in the same world, MM style, but anyone can upload data, an artist who renders it by hand, or the program, when it generates it algorithmically ...
Advertisement
I have 2 cents of info that may be of interest. When saving a "section" of a map, store its width and height in 4 bytes each. Then using that info, you can calculate where to begin displaying "Strips" using this info and a given position of camera.
To find the square''s index for any given position, use an equation like this:
column + (row * max_columns)

For example, a grid has 32767 columns * 32767 rows, and you want to get to start drawing at row 3, column 2) you''d first find the index like so:
2 + (3 * 32767)

If you''re using triangle strips or the like, you should be able to see how to modify it to accomodate. Right now I have a 1024*1024 grid (using triangle strips) that renders at about 90 fps on a Geforce2 @ 1280*1024 at 32bpp. Email me if you want more help :D
Joel Bruce, Founder of JAB IT and Yoale's Site
Vivid War Game Manual
You could use the same algoryth Soldier of Fortune 2 uses. You can write a seed and Sof2 generates a level out from the seed. The level is EXACTLY the same if you write the same thing even on different computers. A seed for sof 2 is only 6 characters long for a huge area. That could be used...
You''re all talking about this small seed to do the job... how does this exactly work? I have never heard of this before... :S
To everyone unfamiliar with random number generators and seeds:

A "random number generator" works something like this: It takes the previous random number, and does "something" to it. This becomes the new random number. When rand() (or whatever the function is) is again called, it does the same "something" to this new number, and so on.

As you can tell, your series depends on previous numbers. So what determines the first one? You do. This number is called the seed. Given the same seed, a random number generator will output the same series of numbers. That''s why they''re more accurately called pseudorandom number generators.

Very often, the seed used comes from the system clock. This makes the random number sequences more unpredictable, since the same seed won''t be used more than once unless the user sets the clock back (and even then it''s highly unlikely of seeding the generator when the clock reads the EXACT SAME time).

Seeds, however, don''t need to come from the clock. You could have a user enter a seed. That''s how this part of Soldier of Fortune''s random level generator works.

In the standard C library, the function srand(...) seeds the random number generator. I would guess that most professional games use their own random number generators, with seperate random number generator objects, so that re-seeding the generator doesn''t cause global changes.

There are many types of random number generators. IIRC, rand() is a linear congruential generator. Another well-respected generator is called the Mersenne(sp?) Twister. All simply use mathematical techniques, generally dependant on previous results, to create new numbers. The resulting sequence appears random, but isn''t.

There are a few ways to generate numbers that are, according to science''s current understanding of the way things work, truly random, using special hardware. Usually it outputs noise generated across a resistor. A TV antenna tuned to a station not used for broadcasting would also give a "truly random" signal. Whether or not it really is random (and if there is such a thing as randomness) gets into scientific philosophical questions to which there are currently no answers.

Anyway, now that I''ve rambled on about random number generators, I hope I''ve give you at least SOMETHING useful. Enjoy.
If the input used for calculating the number is from outside the system, then within the system the number is truly random.

That means that the static on a TV screen is random as far as you are concerned, because it really is truly random from within your house. But if you enlarge the scope to look at the universe then it is not at all random because every single black or white dot is caused by particles that you can predict.

I''ll use a better analogy. People used to pray to gods for good weather because, as far as they could see, weather was random. From the point of view of their settlement, it was. But from the point of view of the planet, it isn''t; it''s caused by a combination of many factors. But those factors are largely outside of the settlement so they have no way of knowing or predicting what they are.

~CGameProgrammer( );
~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
I''m not a 3D programmer, but playing Serious Sam I came out with an idea that could work for huge maps. I noted all 3D games makes their maps over a plane. Why not over a sphere? This way when you walk far away the polys which are distant will be hidden down de horizon and wont be drawn anymore.

What you think? could this be usefull?
[size="2"]I like the Walrus best.
quote:Original post by xaxa
I''m not a 3D programmer, but playing Serious Sam I came out with an idea that could work for huge maps. I noted all 3D games makes their maps over a plane. Why not over a sphere? This way when you walk far away the polys which are distant will be hidden down de horizon and wont be drawn anymore.

What you think? could this be usefull?


It is a good trick as something to speed up rendering of planetary bodies, but regarding this discussion it is not useful; the problems of trying to render very large worlds are memory-based primarily, not framerate-based.

It''s easy eliminating polygons that aren''t visible. With planetary bodies there''s a convenient horizon, but with flat areas you just set a maximum draw distance and it amounts to the same thing. You then either use fog, blend those polygons in to the scene, or you can even have them dip down simulating a horizon, so they rise up when they become visible.

~CGameProgrammer( );
~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
Seeded pseudorandom infinite world creation? WHY THE BUZZWORDS DAMMIT!

Plus, i think i have a feasable to do it the now and it involves a tree structure, and i dont know if it existed before i thought of it(prolly did). If you give me a few days, i''ll finish the code/tutorial and upload it here.
*st0ned*

This topic is closed to new replies.

Advertisement