Dynamic loading of 3D world

Started by
16 comments, last by pym 22 years, 1 month ago
what do you mean no swapping? so your saying you cant stream off the cd/dvd/gd? this is how its done in most modern games. the trick is to make the sections overlap enough so that while your loading the new data, the player can still see stuff. just look at shenmue2, they had TONS of npcs most with different textures and models (yes even the generic ppl). shenmue''s engine handled this by fading them in. distracting yes, but effective. the world data on the other hand (also quite detailed) never had the fading problem, but you knew the dc was always loading stuff due to the drive noise. though at many points shenmue required load screens (which were not too long). this was acceptable because the chunks were large and the next area ussually used an entirly different texture set and npcs. though i am ranting abit (shenmue2 is such a grand view of the power of the dc).

now on to things to consider. in a racing game, you can do this (gta3 does it) as well, just a bit more complex. in gta3, you will notice the change form high detail from lower detail when you transition through certain blocks. its very difficult to make it completly transparant. you have to deal with the dirve seek time and read speed. also you will have to stream the data while you render. the best way would be to break up the sections by visiblity. try to have obsticales that will hide some of the next section so that while your loading it, the player wont notice. also try to orgainze your sections so that they have the data close to a section transition at the begining. you may have to duplicate your data on the disc for optimal reading. which wont be much of a problem when dealing with dvds on ps2 or gamecube.

rolling yoru own level mangemnet system will probally be faster then relying on an os level one (mainly because you KNOW what data will be needed next and can premptivly start a load when the player gets close). i suggest testing these ideas on a pc with the data on a cdrom or with file functions that artifical mimick the read speed you will have (dont make it a perfect read speed either). this will help work out the bugs.

btw when you split the data you dont have to use seperate files. just ensure that things are ordered nicely. you could theorectically stream the level at all times, and only have some problems if the player does a quick 180 (like in gta3). basically you need some priority for the data. for instance npc models behind the player, that cant harm the player, should be unloaded if the player is moving forward for a certain amount of time. this will help keep down watsed ram on things that dont need to be kept track of. now in gta3, the level never faded in too much (ie from a 180) but at times it was noticable when turing at certain sections. lower quality textures and models may be used to reduce this. ie use the lower quality stuff when you begin caching the level so you progressivly load things like a progressive jpg. low->med->full detail.
Advertisement
When I said "swaping" I meant extension of the memory on a disk... just like the swaping system on the PC... What is impossible on PS2 for exemple because there is no diskdrive.

I just tried GTA3... yes it seems to work just as I''d need ! If evezr you have any link about how the load/unload is managed exactly in this game it could help...

I will start to test some few things using that idea !

Thanks for your help



PYM
:):):)PYM:):):)
One way to stream the data is to define a system of a world, section, and block locations making up the game world. Your world is an array of the sections, your sections are an array of the blocks, and the blocks contain a reference of the data to be used. The position in the world you are currently occuping determains the sections to load, for example if you''re in section x,y you will load at least the sections which could be directly moved to from your location for 9 sections total if you have full x & y freedom (includes the one you occupy). You set up the engine to load the blocks of each section into memory, swap the memory for the sections and respective blocks as you move across into other sections. The engine takes the blocks located in memory and from them generates a virtual map for the portion of the world that could be visible (ignoring the viewing fustrum for now) based on your location. Now do your T&L, collision detection, etc on the virtual map.

Now one of the prime advantages of this method is you can scale up or down how many vertices you allow to reside in the blocks and how many blocks reside in the sections based on data transfer rates, memory, and anything else you need to account for. Also this system can do many things in abstract to reduce memory overhead, such as collision basic collision detection for things not visible using the blocks occupied to make the determaination and only loading data for NPC that is within x number of blocks from player position and/or visable.

For a more complex engine and even more flexablity you can add progressive loading as suggested by "a person". One way to do that is by having a priority assigned to vertices and textures of the blocks, your engine can fetch the high priority data first to define the basic object and increase the detail as more of the vertices and textures load.

For a basic example; You have a pillar of marble in the distance you are moving toward. As it moves into the barely becoming visable range you load vertices for 2 triangles that define the basic shape, shade them to color as the object is still only between 0.5-8 pixels max on screen (if you need less draw distance I would suggest a slow fade-in). Now once you push past a few pixles into something where texture becomes noticable, you can add simple texture to your triangles. You where loading while the basic shape was on screen right?!?! Now would be the time to flesh-out the object by adding vertices that will sub-divide your polygons for an object with depth, you need only add the ones visable from your direction and I recommend leaving vertices less importain to the look of the object until a little later. We have had time to load the detailed texture so slap it on and load any remaining vertices, as our object passes further in the opposite direction of our travel we can unload data almost in opposite order of what we loaded.

Hope that helps.
"Who are you, and how did you get in here?""I''m the locksmith, and I''m the locksmith."
Yes !!!!!! That exactly the loading management system I was looking for ! I just have now to integrate a dynamic way of managing the memory...

It's cool to know what and when to load something (here sections of map) but do I have enought free mem to store it ? And if I have not what should I unload ? Here is the way I see it :

look at the picture here :
the picture

I want to use a priority map : for each section around the player (here the player is the small arrow) and accordind to his direction (thats why I use an arrow ) I assign a priority for loading stuff...

Of course I have to discreetise the direction of the player (4 main directions) but I think it could be quite nice to do my memory management like that...

what do you think of that ?
Do you see any problem/improvement ?




PYM

Edited by - pym on February 12, 2002 8:50:19 AM
:):):)PYM:):):)
I think I have a quite good thing now... in fact I explain it on the LionHead forum... here :
my post in LionHead forum
if you have any suggestions... or remark...

Oh I have a question did anyone before use such quide of "loading priority" tech ? I never read anything about it... I had the idea while reading a book about C++ STL... when I read "priority_queue" I immediatly thought to that algo... It's a kind of magic... but of course the real magicians all the people that accept to read all the looooooooong things I wrote in my 2 posts

PYM

Edited by - pym on February 19, 2002 4:58:15 AM
:):):)PYM:):):)
Just one comment, if you are going to be streaming stuff in and out, you need to consider dynamic objects in your world that get initialised before they are actually visible, or if your game is such that you will be leaving locations and returning to them, objects that need to correctly react with the world in the interem.

Gibberish explained by example: Say you have an object that does collision detection with the world, and you go and (literally) stream the world out from under it''s feet, is it gonna get stuck somewhere rediculous when the geometry gets streamed back in, or maybe fall through the world while it''s geometry is unavailable for collsion tests?

Not a problem if your game world consists purely of static physical objects, but if you are trying to simulate a slightly more lively world it may be.
Yes your right... it is a problem... I (the rest of the team) have some solutions : when a mobile&interacting object is in a unloaded part of the world it switch to a different way of interacting (more simple because we don''t see it )... it is the main idea...

For the moment I just focalise on static&graphic things... but I keep in mind that I will have to integrate mecanics and IA stuff...

But that''s right that I have to think of it now (to avoid doing thing that will block me then). Thanks for reminding it to me !
:):):)PYM:):):)
Well, we had the problem that objects just ''disappeared'' out of the world, and we realised that this was the problem.. solution, make them inactive while their block is not streamed into mem.

This topic is closed to new replies.

Advertisement