a tilebased terrain manager

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Filopher
Greenskin
Posts: 131
Joined: Sun Dec 05, 2004 11:57 am
Location: Germany, Greifswald
Contact:

a tilebased terrain manager

Post by Filopher »

As promised we will release the first version of our source code of a tilebased terrain manager for ogre today. We, that is polyveg and me, have spent the last months developing a terrain manager that can be used in turnbased or realtime strategy games. Of course you can also use it in any application you like.

There is still much work to do. You can use the terrain manager to study the code and add your own stuff. At the moment you won't be able to use it in your projects without coding important features on your own. If you do so, please tell us here and send us your changes and addons. We appreciate every help we can get - cause we both have also other projects to attend to. If you feel up to it join us in our developer team, get the latest changes and help us to finish the terrain manager sooner.

What features are implemented at the moment?
  • load a heightmap to calculate the geometry for a 256x256 tile world
  • give every tile its own texture independent from height or position
  • easily use up to 49 different 128x128 textures (can be increased manually to 784)
  • use a filter to blend texture borders
  • use the manager to automatically decrease pixel resolution of tile textures on slower computers (up to 8x8)
  • deactivate filtering on slower computers
  • press a key to activate a grid
  • change the geometry of the map while the terrain manager is running
  • use an evironment manager to place 3d objects in the world
  • makes for linux code::blocks, windows code::blocks and windows VS 7.1 included
  • ... and a few other things which I can't remember now ;)
Screenshots can be seen here: http://www.ogre3d.org/phpBB2/viewtopic.php?t=12952

Download here (11,0 MB): http://www.code-black.org/Programmversi ... Engine.rar

(yet to come: todo list)
Last edited by Filopher on Sat Aug 20, 2005 10:09 pm, edited 3 times in total.
User avatar
Marc
Gremlin
Posts: 182
Joined: Tue Jan 25, 2005 7:56 am
Location: Germany
Contact:

Re: a tilebased terrain manager

Post by Marc »

The screenshots (in the showcase thread) look quite nice. :)

How many triangles per tile do you use? Is it just 2 or configurable, e.g. use more than 1 pixel of the heightmap for a tile? That'ld be necessary for smoother steep areas.

Do you use some lodding technique for tiles further away? You mention the terrainmanager in the features list. Do you use/modified the default Ogre manager or maybe PLSM or do you just mean the part of your own code that handles displaying the heightmap as geometry?

I'm looking forward to try/see your code. :)
Filopher wrote:As promised we will release the first version of our source code of a tilebased terrain manager for ogre today.
:
(yet to come: todo list, source link)
Isn't that contradictory?
Filopher
Greenskin
Posts: 131
Joined: Sun Dec 05, 2004 11:57 am
Location: Germany, Greifswald
Contact:

Re: a tilebased terrain manager

Post by Filopher »

Marc wrote: Isn't that contradictory?
No, but my upload takes a while. :D

I edited the first post and added the download link
hangchon18
Halfling
Posts: 80
Joined: Sun Jul 24, 2005 9:03 am

Post by hangchon18 »

Whe I try this, realse mode is good, but debug mode is Error.
10:11:07: Creating resource group General
10:11:07: Registering ResourceManager for type Material
10:11:07: Registering ResourceManager for type Mesh
10:11:07: Registering ResourceManager for type Skeleton
10:11:07: Loading library OgrePlatform_d.dll
10:11:07: An exception has been thrown!

-----------------------------------
Details:
-----------------------------------
Error #: 9
Function: DynLib::load
Description: Could not load dynamic library OgrePlatform_d.dll. System Error: 找不到指定的模块。

.
File: h:\ogre 1.0.3\ogremain\src\ogredynlib.cpp
Line: 82
Stack unwinding: DynLib::load(..) <- <<beginning of stack>>

When Add OgrePlatform_d.dll, yet has mistaken.
Hope to get your help.
However this work is great!!
polyveg
Halfling
Posts: 78
Joined: Fri Mar 04, 2005 7:08 am
Location: Germany

Post by polyveg »

if you are using vc7 just copy all dll's from ogresdk\bin\debug to the main folder. and the ogresdk\lib to the tilemanager ...\make\win32\vc71\ogre_lib

if you are using code::blocks you must compile the stuff on your own.
Filopher
Greenskin
Posts: 131
Joined: Sun Dec 05, 2004 11:57 am
Location: Germany, Greifswald
Contact:

Re: a tilebased terrain manager

Post by Filopher »

Marc wrote:How many triangles per tile do you use? Is it just 2 or configurable, e.g. use more than 1 pixel of the heightmap for a tile? That'ld be necessary for smoother steep areas.
At the moment a tile uses 4 triangles and 5 vertices. This is necessary for our filtering technique that only uses 2 textures and linear growth of texture space per tile texture. If we used 2 triangles we would have to use 3 textures per pass or have a worrying texture space growth to achive the same filtering effects.

A tile uses 4 pixels of the heightmap to calculate the four corner vertices. So Neighbour tiles share one or two vertices. A fifth vertex is calculated for the centre of the tile and uses the aritmethic mean.

The heightmap loader is configurable if you change it. ;) It is just an example to show how the terrain manager works. You would have to code your own loader anyway because you would want to specify the textures used in each tile.
Marc wrote: Do you use some lodding technique for tiles further away? You mention the terrainmanager in the features list. Do you use/modified the default Ogre manager or maybe PLSM or do you just mean the part of your own code that handles displaying the heightmap as geometry?
This has to be a communication mistake. Our "tilebased terrain manager" has nothing in common with any other ogre terrain manager. It is an independent built but also a "terrain manager" in its abstract meaning.

At the moment we use a very simple LOD-technique that decreases the triangle count but actually doesn't look very nice. I think we will work on this.
Filopher
Greenskin
Posts: 131
Joined: Sun Dec 05, 2004 11:57 am
Location: Germany, Greifswald
Contact:

Post by Filopher »

Unfortunately our code was not compatible with the new ogre version 1.0.4 that was released only a few hours after I started this thread. :D

We corrected this mistake (and a few other things). The link in my first post links to the new .rar file.

So, if you downloaded the source code before now you should download it again if you want to use it with ogre 1.0.4. Sorry about that. :oops:
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

Filopher wrote:Sorry about that. :oops:
You shouldn't be sorry - patch numbers should be non-breaking - blaim it on the Ogre. :P
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
hike1
Greenskin
Posts: 118
Joined: Sun Mar 30, 2003 3:46 am
Contact:

Post by hike1 »

How 'bout a Windows .exe?
polyveg
Halfling
Posts: 78
Joined: Fri Mar 04, 2005 7:08 am
Location: Germany

Post by polyveg »

well, it isn't that hard to build the exe. there are project files for codeblocks and vc. its very simple - you don't even need to install ogre3d...
and actually it makes only sense to look at the demo, if you plan to use/extend the source code.
User avatar
snipexv
Halfling
Posts: 66
Joined: Thu Jan 27, 2005 3:20 pm

Post by snipexv »

Hey,
How's this coming? One thing I noticed(You may be aware of this), the filter textures aren't affected by ambient lighting. I tried to fix this, but my knowledge of low-level graphics programming is limited, so I was never able to do it. I would be interested in helping out with this project where I can though(as I would like to use it in a project I'm working on). So if you have a todo list for the project, I'll contribute where I can! I don't want to just start on something and then find out you already did it.

Regards,
snipexv
Filopher
Greenskin
Posts: 131
Joined: Sun Dec 05, 2004 11:57 am
Location: Germany, Greifswald
Contact:

Post by Filopher »

snipexv wrote:Hey,
How's this coming? One thing I noticed(You may be aware of this), the filter textures aren't affected by ambient lighting. I tried to fix this, but my knowledge of low-level graphics programming is limited, so I was never able to do it.
Yes, you are right. Lighting is not supported at the moment, although it shouldn't be too difficult to change. You would just have to manipulate the terrain material to support lighting. You could add a second lighting pass or use a pixel shader.
snipexv wrote: I would be interested in helping out with this project where I can though(as I would like to use it in a project I'm working on). So if you have a todo list for the project, I'll contribute where I can! I don't want to just start on something and then find out you already did it.
Yeah, well we are working on this. :D

Currently polyveg is creating an user interface and I'm trying to implement mouse picking. Anything else is free to work on at the moment.

There are many things that need to be added, for example a way to place entities on tiles by just telling the tile cordinates, or a way to create rivers, perhaps a nicer coast line or an animated sky.

Perhaps it would be best if you just mention what you'd like to add. ;)

Anyway, nice to have another person working on the tilemanager. You are more than welcome. :)
User avatar
snipexv
Halfling
Posts: 66
Joined: Thu Jan 27, 2005 3:20 pm

Post by snipexv »

I will work on a tile coordinate system then, as that is extremly relevant to what I'm working on in my other project right now.
Filopher
Greenskin
Posts: 131
Joined: Sun Dec 05, 2004 11:57 am
Location: Germany, Greifswald
Contact:

Post by Filopher »

snipexv wrote:I will work on a tile coordinate system then, as that is extremly relevant to what I'm working on in my other project right now.
Nice. If you do so you probably would want the new version with mouse picking. :D

Image

I'll release it within the next days.
User avatar
snipexv
Halfling
Posts: 66
Joined: Thu Jan 27, 2005 3:20 pm

Post by snipexv »

Alright, I have most of the code for the coordinate system complete. I added two methods to the tile manager class: one that you give the ogre world coordinates and get you the tile coordinates, and one that does the opposite.

One suggestion:
I'm using your WorldMap array for my coordinate system and, I wonder if it would be better to make WorldMap a class instead of a structure so that some methods can be added to it for attaching scene nodes and such. I plan to do this in my copy and I thought it might benefit the project as a whole. I'm not an expert coder though, so there may be problems with this I'm not aware of.

Also, is there any plan to make this into an actual SceneManager?
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: a tilebased terrain manager

Post by jacmoe »

It looks like a scene manager of it's own:
Filopher wrote:Our "tilebased terrain manager" has nothing in common with any other ogre terrain manager
:wink:

Looking forward to seeing the new release, Filopher!
The last screenshot really looks promising! 8)
User avatar
snipexv
Halfling
Posts: 66
Joined: Thu Jan 27, 2005 3:20 pm

Post by snipexv »

I just meant if he intended to keep it as is, or if he planned to make it a scene manager plug-in. Either way works, I'm just curious.
Filopher
Greenskin
Posts: 131
Joined: Sun Dec 05, 2004 11:57 am
Location: Germany, Greifswald
Contact:

Post by Filopher »

Yes, well, at the moment it's not really a scene manager. It's a terrain manager, which means that it theoretically is possible to use it with every ogre scene manager, although not every one would make sense.

The manager only creates the terrain geometry, textures and filters in a given scene manager and calculates its own mouse picking and terrain LODs, places entities on tiles and organizes visibility. Perhaps there will be a time when the terrain manager has grown to a size where it could replace a complete scene manager, but not yet.

I have to admit that it's not my goal to create a fully usable scene manager. My first goal is to create a turnbased and tilebased game and I'll implement everything I'll need to finish it. If someone wants to create a RTS game and needs faster algorithms, he probably would want a few things to change.
One suggestion:
I'm using your WorldMap array for my coordinate system and, I wonder if it would be better to make WorldMap a class instead of a structure so that some methods can be added to it for attaching scene nodes and such. I plan to do this in my copy and I thought it might benefit the project as a whole. I'm not an expert coder though, so there may be problems with this I'm not aware of.
No, you are right. Most possibly the WorldMap will be a class of its own soon. There will be some additions to the struct like a lighting value for every tile. Actually, I'm trying to add lighting maps at the moment.

I think we should talk in IRC and organize our codings. You can find me in the #ogre3d channel. Perhaps not within the next hours (I'm ill and need sleep :( ), but surely within the next days. ;)
User avatar
snipexv
Halfling
Posts: 66
Joined: Thu Jan 27, 2005 3:20 pm

Post by snipexv »

Alright, sounds good. I will look for you there.
User avatar
Dark
Halfling
Posts: 63
Joined: Fri Jul 15, 2005 7:34 pm
Location: The Netherlands
Contact:

Post by Dark »

Filopher wrote:
snipexv wrote:I will work on a tile coordinate system then, as that is extremly relevant to what I'm working on in my other project right now.
Nice. If you do so you probably would want the new version with mouse picking. :D


I'll release it within the next days.
Yup we realy need that :)
Image
Domination Studios, making the sh*t you gonna play!
Filopher
Greenskin
Posts: 131
Joined: Sun Dec 05, 2004 11:57 am
Location: Germany, Greifswald
Contact:

Post by Filopher »

Note: There's a new screenshot in the screenshot thread.
User avatar
snipexv
Halfling
Posts: 66
Joined: Thu Jan 27, 2005 3:20 pm

Post by snipexv »

Awesome work! Did you get my email?
Filopher
Greenskin
Posts: 131
Joined: Sun Dec 05, 2004 11:57 am
Location: Germany, Greifswald
Contact:

Post by Filopher »

snipexv wrote:Awesome work! Did you get my email?
Yes, I got it. I'll add the changes you made within the next days ( I've got little time at the moment).

I uploaded a snapshot from the latest CVS version. Keep in mind that this is a CVS version and will probably not run stable (for all those who don't want to wait for the next release version).

Here's the link: http://www.code-black.org/Programmversi ... 7.2005.rar . (10 MB)
User avatar
snipexv
Halfling
Posts: 66
Joined: Thu Jan 27, 2005 3:20 pm

Post by snipexv »

alright, sounds good. I want be able to work on it much more for a little while. I've got to do some stuff to my other project. When I finish with that I'll check back in and see where I can help out!
madtulip
Halfling
Posts: 78
Joined: Thu Nov 18, 2004 6:35 pm
Contact:

Post by madtulip »

heya, first off : great project, exacly what i planed to do for my jagged alliance similar project.
i exspecily like the at runtime created meshes an grafics on it, a part that i whould have had may difficulties with. thx a lot for releasing this code.

so i decieded to use this for my project and did a few changes so far.

first off the camera movement relative to the camera, not the grid, scrolling in the direction you are looking in with the mousewheel and so on..
i wrote some functions that allow you to select not 1 but 3*3 or 5*5 or more tiles at once (grafical marker also) and manipulate them. for manipulation i wrote some funktions to raise,lower or bring the terrain to an even level (to the z_min , z_max hight in the current selection). im not sure if something like that is needed in your project, but i liked to use it because the world creation via an image editor is a bit .. well unprecise. maybe ill use that later on for shellhole and such also.

there are also some problems at the moment, i can´t figure out, how to write the m_map[x][y].heigh values back to the file once your methodes read them out, but moved that question here http://www.ogre3d.org/phpBB2/viewtopic. ... 863#103863, to not currupt the nice topic with heaps of code.

i would have send you the changes to your code by mail, but i coulnd find your email adress, would be nice if you send me a pm wih your email adress. speak german if you want to :) thx for your work.
Post Reply