Basic thoughts about a tile based map used with Irrlicht

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
gfxstyler
Posts: 222
Joined: Tue Apr 18, 2006 11:47 pm

Post by gfxstyler »

what driver do you use? opengl or directx?

if you use opengl, i have to disappoint you, because irrlichts opengl implementation is kinda slow.
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

First possible improvement is to use better culling. For meshes roughly aligned on a plane, quadtree is good.

For instance you could create a QuadTreeSceneNode, which manages its childs in a quadtree and only calls the prerender-function for unculled nodes.

This should work much better than individual view-frustum test for each single mesh.

Second problem is batching. With all nodes being drawn you end up with 1024 individual draw calls. Too many. Combine multiple of your meshes into a single mesh with a single meshbuffer per material. There is always a tradeoff between culling and batching. You have to experiment here.
No offense :)
gfxstyler
Posts: 222
Joined: Tue Apr 18, 2006 11:47 pm

Post by gfxstyler »

i already told him that :P
Human Shield
Posts: 6
Joined: Fri Jun 23, 2006 10:48 pm

Post by Human Shield »

I don't know much about the engine but is it possible to use the coorididate system for a grid? Have objects move to evenly spaced cooridates for a grid.

Can mouse hover recieve map cooridates? Cause then you could round on the nearest whole one and display a 2D image for tile select highlight, right?
rooly
Posts: 224
Joined: Tue Oct 25, 2005 4:32 pm
Location: Louisiana, USA, backwater country
Contact:

Post by rooly »

why would you wanna use cubes anyway? wouldn't it be much simpler to use planes? i mean, isn't that literally half as many vertices?

next: the simplest thing to do is just draw an image to the background (more than 1 way to do this) and just have invisible planes/cubes act as your tile system. if you keep all your characters on the same plane(it seems likely, being a simple rts) then this should work no problem. it would also drasticly reduce cpu time, being as the vertices aren't rendered at all.

also, i'd say, have 2 grid systems, a virtual one and a real one, the virtual is nothing more than a double array supporting your entire map. the real would be a dynamically alocated array based on camera position.

lastly, unless you plan to make a map editor for your game, i highly discourage making 1000+ nodes and rendering seperate textures to them. the easiest thing to do is have, say, your art program, and just have a few pre-drawn tiles to place here and there inside your art program. save the new file, and load that to your background.
When banks compete, you win.
When ISPs compete, you win.
When electronics retailers compete, you win.
When governments compete...you get drafted.
jrm
Posts: 111
Joined: Tue Dec 13, 2005 8:57 pm

Post by jrm »

I am doing a tile based game currently, and I am just doing a draw2DImage(...) Seems to work ok for me. I am using a tile map editor called Tiled. save everything in XML.

JRM
michael520
Posts: 230
Joined: Mon Oct 10, 2005 2:24 am

Post by michael520 »

This is really the current problem of my project.
I use A* path finding and have to divide the plane into tiles(virtual of course).

But I don't think it's a big problem! Maybe after two or three days, it would be solved.

My solution:
1. model the 3d terrain with some buildings or other obstacles on the ground
2. according to the terrain, divide the plane into virtual tiles, maybe 32X32, and use a data structure to hold the coordinates informations.
3. run the A* algorithm on the virtual tiles plane, and get the path!
4. let the charactor go along the path :)

but the step 2 may have some tricks, you may have to use a tiles-defining tool to editing the virtual tiles plane, and mark the obstacle tiles.

by the way, I wonder if anyone knows if there's any tiles-editing tools?
Human Shield
Posts: 6
Joined: Fri Jun 23, 2006 10:48 pm

Post by Human Shield »

Any hints on creating "virtual tiles"?
SiriusCG
Posts: 58
Joined: Tue Feb 14, 2006 1:05 am

Post by SiriusCG »

Maybe you could look at this: http://www.tilemap.co.uk/mappy.php

They list a number of "playback libraries" for rendering, animating, etc the tiles. I did not see a Irrlicht specific library but they do have source included in the downloads. I'm sure there is someting useful in there... perhaps the Allegro library might yield something.

I'd hate to see you give up as tile-based games are still cool IMO.

Cheers.
AmigaIrr
Posts: 94
Joined: Mon Jan 10, 2005 7:55 am
Location: France, Alsace

Post by AmigaIrr »

jrm wrote:I am doing a tile based game currently, and I am just doing a draw2DImage(...) Seems to work ok for me. I am using a tile map editor called Tiled. save everything in XML.

JRM

using 2d is easy but not fun and really limited

using 3d elements permit use of great effects (lights, shadows,....)
and this that the autor will.

yes ? :o
L'eternité c'est long, surtout vers la fin...

Q6600 triton 79, 4 GO, 2* RAPTOR 150GO of ARECA 256 RAID 0, 3870 Zalmann, P5K. 24" Samsung. Antec nine hundred
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

i have already did it with my magic library for Opengle(it has small bug that have been fixed by now) , but here is the idea for creating it with any driver.

first i assume that you already know how to draw 2d image by your driver

for the sake of speed , we will use a vrtual map, i.e we will only draw a part of map which is viewed in spcific time.

so when drawing it we must have the follwoing data.

1-strat coordinates in our map ,suppose our map is 512*512 elements , and say we want to draw starting from 100, 100.

2- till width, suppose our till element is 32X32 pixels ,so elements width is 32 , and ScreenSize is 640X480.

so till width = Screen width / element width

3- till height , the same as till width

now we have the needed data for drwing our till map

Code: Select all

 for y=0 to till width
    for x=0 to till height    
         draw element in location x , y
here is a real part of my code for set the Map from small one

Code: Select all

void TImageStrip::SetTileMap(s32* tileMap,int mpw,int mph,int srx,int sry)
             {
                 if(srx < mpw) srx = mpw;
                 if(sry < mph) sry = mph;
                 ScrnX =  srx;
                 ScrnY =  sry;
                 Map   = (s32*) new s32[ScrnX*ScrnY];
                 int Rx = ScrnX / mpw;
                 int Ry = ScrnY / mph;

                 for(int J=0;J<Ry;J++)
                   for(int I=0;I<Rx;I++)
                     for(int y=0;y<mph;y++)
                       for(int x=0;x<mpw;x++)
                         if( I*mpw+x<ScrnX && J*mph+y<ScrnY)
                            Map[J*mph*ScrnX+I*mpw+x+y*ScrnX] = tileMap[x+y*mpw];

             }

where
    srx , sry are our width and height of big Map
    mpw, mpy width and height of our small map that will repeated to create our big map

hope that will help you to start to do till map , for magic library users , there are one in the library ,i am improving it sill.
AmigaIrr
Posts: 94
Joined: Mon Jan 10, 2005 7:55 am
Location: France, Alsace

Post by AmigaIrr »

Map[J*mph*ScrnX+I*mpw+x+y*ScrnX] = tileMap[x+y*mpw];

wath is this function ?

are you the same but with 3d mapped tiles ?

Magic libary work only with opengl :(
L'eternité c'est long, surtout vers la fin...

Q6600 triton 79, 4 GO, 2* RAPTOR 150GO of ARECA 256 RAID 0, 3870 Zalmann, P5K. 24" Samsung. Antec nine hundred
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

suppose you have a map with 1000X1000 elements,it is defeculte to fill this map by declaring
static value.

so to fill this map we made small map , say 20X20 elements and this small map will repeated many times to fill the large map.

Map[J*mph*ScrnX+I*mpw+x+y*ScrnX] = tileMap[x+y*mpw];

this line will do it .

here is a snnipet of example of magic library

Code: Select all

    TImageStrip* tileTex = new TImageStrip(smgr);
    tileTex->LoadImageStrip("../../MagicLibrary/media/tilesMap.bmp",40,40);

    s32 Map[] =
      {
         1,1,1,2,2,2,3,3,3,4,4,4,0,0,0,0,
         1,1,1,2,2,2,3,3,3,4,4,4,0,0,0,0,
         1,1,1,2,2,2,3,3,3,4,4,4,0,0,0,0,
         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
      };

     tileTex->SetTileMap(Map,16,5,1000,1000); 
the first line create an instance of TImageStrip class.
the socend line load tilesMap.bmp and spcify the width and hieght of each elements.
the last one will create a big map 1000X1000 and fill it with small Map which is 16X5.
are you the same but with 3d mapped tiles ?
i realy do not got your question , so please nore explain
AmigaIrr
Posts: 94
Joined: Mon Jan 10, 2005 7:55 am
Location: France, Alsace

Post by AmigaIrr »

Quote:
are you the same but with 3d mapped tiles ?


i realy do not got your question , so please nore explain




Then same code, but only with pure irrlicht ?
not with magix library
L'eternité c'est long, surtout vers la fin...

Q6600 triton 79, 4 GO, 2* RAPTOR 150GO of ARECA 256 RAID 0, 3870 Zalmann, P5K. 24" Samsung. Antec nine hundred
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

i did not try to make it with pure irrlicht , but you could easily do it.

you have to learn how to draw a part of 2D image with pure irrlicht , then apply the concept of TileMap that we have discussed.
Post Reply