Page 2 of 3

Posted: Sat Jun 24, 2006 4:18 pm
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.

Posted: Sat Jun 24, 2006 4:23 pm
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.

Posted: Sat Jun 24, 2006 6:56 pm
by gfxstyler
i already told him that :P

Posted: Sun Jun 25, 2006 12:50 pm
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?

Posted: Mon Jun 26, 2006 2:59 am
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.

Posted: Mon Jun 26, 2006 4:37 pm
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

Posted: Wed Jun 28, 2006 1:56 am
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?

Posted: Tue Jul 11, 2006 1:21 am
by Human Shield
Any hints on creating "virtual tiles"?

Posted: Tue Jul 11, 2006 1:43 am
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.

Posted: Sun Oct 08, 2006 7:01 am
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

Posted: Sun Oct 08, 2006 8:25 am
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.

Posted: Mon Oct 09, 2006 5:47 pm
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 :(

Posted: Mon Oct 09, 2006 8:46 pm
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

Posted: Mon Oct 09, 2006 11:25 pm
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

Posted: Tue Oct 10, 2006 12:09 pm
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.