3D tile engine

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.
Chris.Bailey
Posts: 9
Joined: Thu Aug 14, 2008 7:20 am

3D tile engine

Post by Chris.Bailey »

Hello everyone! I've got a project in mind but I am having a bit of difficulty getting started with it. I have been reading through the forum for several hours trying to find an example or any bit of information that would prove useful and I have been mostly unsuccessful. What I would like to do is create a simple way of displaying a small 3d map in the style of traditional "tactical" rpgs. More importantly than just displaying this map, each sector or "tile" needs to contain a large amount of information. In the languages I am used to I would probably just create a sector class that contained the texture information and whatever other variables I might find necessary along with a few methods for changing that information. Then I would populate a multidimensional array with instances of that class. Is that the kind of approach I should use for C++ and Irrlicht? Any help that could get me started would be much appreciated and I apologize for the newbiesh question.

PS: If I've missed something in the documentation and/or on the forums that would explain this to me feel free to flame me =)
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

What do your tiles represent? what's their purpose? Is it a gameplay mechanic or something to aid rendering performance?
Image Image Image
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Is that the kind of approach I should use for C++ and Irrlicht?
If you have to ask this question, then no, you obviously lack the creativity and open-mindedness. :P

That being said, create a hillplane scene node, and individually raise/lower the vertices to create a "tile" effect. I'm guessing you want something like this?:

Image

Also check out the game "Warchief's Warboard" in the project announcements forum.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Chris.Bailey
Posts: 9
Joined: Thu Aug 14, 2008 7:20 am

Post by Chris.Bailey »

JP - I was having a bit of a hard time explaining what I wanted, but if you have a peek at the image posted by Blindside you will get a general idea of what I meant. Thank you for the reply.

Blindside - I'm looking into it right now. Thank you.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

The reason i asked what the purpose of your tile idea was that you dont' really need it for building up your scene, you'd only need it for things like moving NPCs around or things like that, or if you've got a large world you can split it into tiles and hide ones that you don't want rendered to improve performance.
Image Image Image
Chris.Bailey
Posts: 9
Joined: Thu Aug 14, 2008 7:20 am

Post by Chris.Bailey »

Blindside - I'm looking through the API and I can't find the Hillplane scene node. I found hillplane mesh but I'm not sure if they are the same thing. If the mesh IS what you referenced then I have another question. I noticed that you could specify a tile size and the number of tiles when you initialize the mesh. How do you address an individual "tile" afterward, does it work like an array?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

the hillplane node is created through functions in ISceneManager, so check there.

it just makes a grid of vertices basically, so it's not individual tiles per se, it's basically just a height map.
Image Image Image
Chris.Bailey
Posts: 9
Joined: Thu Aug 14, 2008 7:20 am

Post by Chris.Bailey »

JP - The main reason I wanted to use "tiles" was that I thought it would simplify things like path finding, character movements etc. I am *very* new to 3d programming and not familiar with the terminology so you will have to excuse me if I am easily confused or if I don't make much sense.

1. I will need to store information relevant to each "tile" on the map. Things like the type of terrain, the texture that should be applied to it, characters that are currently on the tile etc. (I think this would be the best way at least).

2. The maps will be very small in size compared to most of what I have seen in 3d games. Each tile will be large enough for a single object or character and a map will be at most 40x40 tiles.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Maybe someone else can say whether a tile system is useful for map layouts but personally i think i'd just use IrrEdit to construct my scene and get a list of the relevant objects from that like things that can be picked up and then handle them in game based on proximity.

A tile approach could be good for simple AI, it's what i did in my dissertation for FPS AI, but it wasn't very realistic looking for that as the NPCs moved N,S,E,W in a grid based fashion, i guess you could do NE, SE, etc as well to improve the look of it though. Another approach for pathfinding is to use waypoints, check out my IrrAI project in the projects forum, might be of some use to you possibly.
Image Image Image
Chris.Bailey
Posts: 9
Joined: Thu Aug 14, 2008 7:20 am

Post by Chris.Bailey »

Thank you for the replies JP. Unfortunately I can't get IrrEdit working in Wine OR Caldega so I guess I'm out of luck. The only computer I have with windows is my wifes laptop. That sort of simple AI would be exactly what I need when it comes to movement. The whole thing would revolve around grid based movement. I am basically trying to reproduce a semi-popular form of 2d system with the power and flexibility of a 3d engine.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Ahh a linux user.. irredit is out the window then i suppose... shame.. i don't think there are any scene editors for linux really... not in a particularly usable state at the moment anyhow.
Image Image Image
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Thinking about it now, just make a 2d array arrangement of CubeSceneNodes, and scale them on the Y axis up/down to create a height field type thing.

I think a tile system would simplify path finding since you could use some grid based techniques such as wavelet etc, without having to manually place waypoints.

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Chris.Bailey
Posts: 9
Joined: Thu Aug 14, 2008 7:20 am

Post by Chris.Bailey »

That is the along the same line I was thinking Blindside. Thanks a lot for your help guys.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Simply using cube scene nodes could be rather expensive, i found that when trying to create a maze from cube scene nodes, though i used like 25 cubes for one small section of wall, lol, young and naive...

But it's a good idea and could be made more efficient by sticking the cube nodes into a single (or fewer) mesh buffer, based on the texture used on them of course.
Image Image Image
Chris.Bailey
Posts: 9
Joined: Thu Aug 14, 2008 7:20 am

Post by Chris.Bailey »

I think that it will be ok as far as resources are concerned since it will be a relatively small amount of cube nodes. I've run into a little bit of a problem though when it comes to address each cube node. Let's assume the following.

Code: Select all


struct sector
{
  int x;
  int y;
  int z;
};

sector map[10][10];

for (int x=0; x<10; x++)
   for (int y=0; y<10; y++)
      smgr->addCubeSceneNode()
      Now how do I reference that cube to change it's position and scale?

The problem I'm having is that I need a way to reference each individual cube node but I'm not sure how they are listed. Can you define an ID when it's initiated, are they all contained in a list somewhere? And most importantly how do I access them? :)
Post Reply