Dynamic 3D worlds with a 2D tile system

Blitz3D Forums/Blitz3D Programming/Dynamic 3D worlds with a 2D tile system

Strider Centaur(Posted 2004) [#1]
Hello all, I have an idea and I presently working on making it reality, but I thaught I would toss it in here to see what advice you might have and to spark some more ideas from inside the community.

This is not a new idea, but one that I think, at least in the BB3D community, one that holds alot of capability with very little overhead.

My idea is to make a 3D game in witch the entire world can be layed out using simple 2D tiles maps. The goal is to make a world that is dynamic, fast to render, and easy to build, while looking totally 3D from inside the game.

My present system uses 32x32 2D tiles, each tile represents a 3D mesh that is 32xNx32 units. The N in the Y coordinate simply means that height is unlimitted since the X and Z planes are what I use to define the tile map.

Building a world is as simple as going into Mappy, loading the tile block 2D top down images, placing them, using Mappies BLOCK data to store special information about each block as needed. Then using the MAPPY play back lib for BB load in the maps, read the data, drop in the propper 3D mesh for all tiles that are in view, render.

An alternate aproach, that greatly simplifies the generation of the 3D tile mesh is that for outdoor area's the 2D tile map is actually used to make a height map, 32x32 units wide each tile( I probably should consider making the scale bigger when outdoors.

The problems thus far are numerous, mainly, joining two meshs always seems to leave a seem where they conect, Im thinking this is more a texturing issue. Building the 3D tiles is a real pain, since you have to make sure all the walls, corners, stairs etc, line up properly with there legal ajoining meshs. Then there is the keeping track of what can attach to what, if not carful, you view looks like something out of a ecsher picture.

Handeling the Y axis is a bit more involved. While it is true the environment is rendered in total 3D and moving within the bounds of a tile is totally capable of being free flight. There is the issue that the 2D map is, well, 2D. So going below the map can create problems. Fortianatly they are minor, since the 2D map is always assumed to be based at 0,0,0 extending in the X and Z planes, we can creat tiles that use the Y plane as mutch as we want. So creating sharp drop offs is possibel. In the case of overlapping maps ( like in a dungeon or house, where each floor is a map ) you have to be very carefull to make shore the Y coordinate stays within the restrictions of that level. The only exception to that would be shafts, stairs, latters and wamps that could be used to move from level to level.

Ok so now we have levels of 2D maps. I already use this in some areas to produce really cool 3D environments, In one test area Im working on now, there are sections of the floor that are missing, you can look down and see the area beneith you on the next level. No big deal right, can do that in pure 3D maps easy. That is very true, but can you have a pure 3D map be generated randomly using a random hall generator, in real time? :)

This hole prject is going to be used in a Net based game very simular to net hack. This is where the tile maps have always been able to rock. I knom most MMORPGs are all prebuilt super detailed 3D environments. But they always seem to get old, I mean once youve seen a xone, it never really changes. With tile based systems, it is possible to sream the tile maps in realtime ( they are very small in size ) so changes to the environment, like altered terrain, buildings, vegitation, you name it, can be done, while the game is running, the changes show up instantly on the clients. The only restriction is the tiles 3D view need to be predone and loaded on the clients ahead of time. So you are limitted to the changes you can make, but, you can at least make them.


Handeling larger than 32xNx32 meshes is a must, and while at first a big pain in the arse to deal with, is now just a little pain. This comes into play mostly in outdoor locations where I have a few buildings tossed about for test. The solution I used was to make areas where the ground was flat( a few 3D meshes with very little to no Y variantion, tho the textures very ). Then on the tile map, where I place the buildings, I make sure that the entire are the building would cover is flat. I then use the BLOCK Data for the anker tile ( usually where the pivot for the building mesh is ) to tell the map that the building of INT_BUILD_ID is to be placed there. Orientation of the building is the only hickup at this point. As it is now, buldings are placed in what ever orientation they where in when saved in the 3D editor.


Also while on the subject of buildings, it is important to note that you can enter a building and move around, just like in a FPS, I do not use tile maps for small structures. Of course this means the inside of such a building and indeed the building itself is static. I have also used this in a dungeon test with a crypt in the middle of a cave.

It is very possible to mix the tile map and the static models as well. In the above mentioned crypt there is a stair way under a coffin, the stair are part of the tile map and coffin and crypt are static meshs, the coffin slides to expose the hole in the bottom of the crypt mesh witch is over the stairs for that tile.

Speed by massive pollygon reduction. Since I use a LOS test on the 2D map before even starting to place the 3D meshs, I eliminate HUGE amounts of polygons for all those tiles you could never see. Further more, I don't place meshs that have already been placed as long as they stay in view. This is just a small performace tweek, that dosn't really seem to cause any noticible speed improvments.

Fianlly, NPC path finding, well, I wish I could say that simple A* for a 2D map works, but since each tile is really 3D there are all the problems of pathing in 3D. The good news is A* does work to find the tiles that need to be handled for path finding. Im just guessing on the details, because Im a long way off from actually having and fore of AI in the game. But it seems to me that creating nodes on each 3D tile then using A* on the 2D map, then A* again on each of the tiles would be the answer. I can see some problems with this, for instance, you may not be able to get to point C from point A across tile B without flight or some such. I imagine creating some form of data structure for each tile denoting side to side accessability for each tile would solve that. Man that would be alot of data entry. Then again, I guess you could use A* inside A* for each 3D tile, just testing the nodes, but something tells me that would be way to much overhead.


Anyway, when I have a test map working ( as in I finally descide on what aproachs Im finally going to use ). I will post a concept demo. But be warned, Im the worlds second worst modeler, so don't expect EQ2 or even EQ quality. :)


aab(Posted 2004) [#2]
I was thinking about this a while back, after using the tile builder in Time splitters two (on the cube). It has a thing like this for building custom tiled levels, although its very simple and doesnt have that many tiles.
But i didnt do anything like it, as i make my areas in Anim8or, all i have to do is set snap to grid to the width of tiles, which can be made exact by opening and editing the .An8 file in notepad, and then copy and paste. then Merge the points together at the end, and the level is joined completely.
Doesnt do me good for loading times doing it this way though....

This would allow much faster loading times i guess, as you'd be copying the entities for each replica of a tile, rather than loading them each time again
Would the Tile_Ed be made in B+ then?


WolRon(Posted 2004) [#3]
I posted in your other thread.


Gabor(Posted 2004) [#4]
Certainly a good idea.

When I played City of Heroes I noticed they use something like this for their mission maps. Prebuilt level blocks put together in always different combinations.
Plus hand-placed enemies and mission specific items.

They don't seem to stick to a rigid grid though, the tiles have different sizes and are placed at different heights too.

Their pathfinding handles it flawlessly most of the time, but they do have one of the best pathfinding systems I have seen. (I have had mobs run around 2 buildings, up a winded staircase, jump across the roofs and onto a monorail track to follow the track all the way to me while I was sniping from up there. :) )


Strider Centaur(Posted 2004) [#5]
Aye, CoH is a awsome game in many respects, but pathing is probably the best, Im fairly sure they use a pure node based systems, you can see this when enemies move toward a point near you then to you. Even when a strieght line is possible and shorter. Still given the variations in terrain and the amount of free movement they support, its a miracle of a job they did.