Editable Terrain Manager [v2.2 released]

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Editable Terrain Manager [v2.2 released]

Post by CABAListic »

Release v2.2

The Editable Terrain Manager is an addon library for OGRE which manages and displays terrain based on heightmap data. It can be used as a replacement for the Terrain Scene Manager, but its main advantage is the edit possibility for the terrain: You can deform and set the terrain heights in real time, as you would need to if you are developing an editor application.
In addition, the library also has means to support editable splatting, probably the current standard for detailed terrain texturing.

All of the parts have been designed to be as flexible as possible and do not even depend upon each other. That means you don't need to use splatting if you don't want to - or you can use that part with a different terrain renderer. Unlike OGRE's TSM, it's not a scene manager, either, so you could (in theory) choose whatever scene manager you like. All its headers are light-weight, using the PIMPL idiom to hide costly implementation details.


This is what it offers:
  • Terrain deforming - Just like the PLSM you can deform terrain as well as retrieve and set height values at arbitrary positions. You can save your work at any time, the ETM provides convenience functions to save and load terrain in raw file format as well as any image format provided by Ogre using 1 to 4 bytes per pixel. But you can just as well write your own load/save code, it's not much of a challenge :)
  • Terrain texturing - The terrain material is completely your responsibility, so you can do whatever you want. The ETM provides a SplattingManager class which you can use to do editable texture splatting, but it's really up to you.
  • More flexible terrain sizes - ETM does not provide paging, but its restraints on valid terrain sizes are a lot less restrictive than those of the TSM. Rectangular terrain is just fine. The tile size must still be 2^n+1, but the terrain size can be anything that fits A * (tilesize-1) + 1 x B * (tilesize-1) + 1.
  • Lightmap calculation - You can tell the ETM to calculate a lightmap including terrain shadows. The lightmaps may not be the prettiest ever to have been generated, but the algorithm is pretty fast. In my map editor which uses terrain sizes of up to 256x256 I do a recalculation of the lightmap after every completed editing step with no noticable time cost.
    The size of the lightmap is completely up to you, although the larger the lightmap, the longer the calculation will need.
  • Base texture generation - You can "bake" your splatting layout into a single texture. This texture could be used as an alternative to dynamic splatting on older hardware or as a base texture at distance, so that splatting only takes place close to the camera.
  • Minimaps - A simple helper function can combine a lightmap and a base texture to a new image which can be used as a minimap of the terrain.

The current version can be found and downloaded at our website: http://www.oddbeat.de/wiki/etm
The source code is released under the terms of the GPLv2 with runtime exception, i. e. you can use it for whatever you like, only if you change the library itself, then you must release those changes.

Wiki page: http://www.ogre3d.org/wiki/index.php/ETM
Fourm: http://www.ogre3d.org/phpBB2addons/viewforum.php?f=16


Image
Image
Last edited by CABAListic on Mon Jan 21, 2008 7:44 pm, edited 6 times in total.
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16

Post by KungFooMasta »

CABAListic... you are the man. I've seriously been needing something like TSM but with texturing/deforming functionalities, and this is exactly that!

I am EXTREMELY interested in your scene manager. Not to add any pressure or added work, but I hope the code is somewhat easy to follow. I'm not sure if you will be releasing your editor, but I have my own scene creator application and would like to make my own interface for your SM. The editor would provide an excellent example for doing this, of course. :twisted:

If there is any help you need please let me know. I'm seriously excited for your scene manager! I hope there are not conflicts with OgreOpcode, as I am able to use OgreOpcode with TSM, but had issues with PLSM2. (was unable to find root cause, and nobody else seems to be using OgreOpcode + PLSM2).

Keep up the good work, the screenshots are amazing!

[Edit]What is the license for this?[\Edit]

KungFooMasta
kneeride
Bugbear
Posts: 807
Joined: Sun May 14, 2006 2:24 pm
Location: Melbourne, Australia

Post by kneeride »

very cool!! i am very interested.

i've had trouble with terrain. a powerful editor is something i've been looking for (instead of using many tools and hacking up a pipeline).
User avatar
ahmedismaiel
OGRE Contributor
OGRE Contributor
Posts: 217
Joined: Wed Jan 25, 2006 11:16 pm
Location: Redmond,WA

Post by ahmedismaiel »

this is seriously awesome ,i would love to integrate this in my editor right away ,i hope it will be out soon.
I'm volunteering for beta testing too
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Be happy to test it out as well.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
Aiursrage2k
Greenskin
Posts: 120
Joined: Wed May 18, 2005 6:40 pm

Post by Aiursrage2k »

Looks great.
I think I can use it for my project.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Post by jacmoe »

Decent terrain editing in Ogre is a very wanted feature! :)
There's been one in the making for PLSM2 - several in fact - but, as you say, they never evolved to a usable state.
Would be very cool to integrate this with Borundin's terrabuild and the beaugard overhang addition! :D

<edit spelling/>
Last edited by jacmoe on Mon Apr 16, 2007 8:15 am, edited 1 time in total.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
kneeride
Bugbear
Posts: 807
Joined: Sun May 14, 2006 2:24 pm
Location: Melbourne, Australia

Post by kneeride »

Any intention on adding paging and LOD for large maps?
jjp
Silver Sponsor
Silver Sponsor
Posts: 597
Joined: Sun Jan 07, 2007 11:55 pm
Location: Cologne, Germany

Post by jjp »

KungFooMasta wrote:[Edit]What is the license for this?[\Edit]
For now all our code and art gets released under the terms of LGPL :)
kneeride wrote:Any intention on adding paging and LOD for large maps?
Unless we find the need for more features unfortunatly I don't think so. While it is great that people have use for the scene manager, the primary reason for creating it is our own project. We've still got a game to make - there is plenty of work to be done :D
Enough is never enough.
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK

Post by SpannerMan »

jjp wrote: For now all our code and art gets released under the terms of LGPL :)
Yaay! :D
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Post by CABAListic »

Actually, since the scene manager is based on Ogre's terrain scene manager and directly uses the Octree scene manager, I would have little choice in licensing even if I wanted to (which I don't) ;)

Thanks for your comments so far. A few answers:
I hope there are not conflicts with OgreOpcode, as I am able to use OgreOpcode with TSM, but had issues with PLSM2. (was unable to find root cause, and nobody else seems to be using OgreOpcode + PLSM2).
I've never used OgreOpcode, so I don't know how it works. But if it doesn't cooperate out of the box, it's probably simple to fix because my code is still similar to TSM in large parts.

Any intention on adding paging and LOD for large maps?
No, definitely not. Paging is PLSM territory, I have no intention to rival that. I think PLSM3 should hopefully fill that need quite nicely. And should I ever have a need for paging, I'd probably rather contribute to the PLSM project than work on my own (if at all necessary).


I'm currently looking into the decals and also working a bit on the lightmap generation. While on detail level 1 the lightmap is ok, improving the detail level doesn't really help its resolution. The shadow parts get more detail, but the overall lighting does not. At first I thought it was a rounding error because technically the lightmap currently only uses 256 shades of colour, so I tested it with a 16bit grayscale image to no avail. And then it dawned to me that for the lighting calculation I'm using terrain normals, but due to the way terrain is represented there only ever two distinct normals for every group of 4 vertices, no matter how many "detail" steps I add in between. So I'm feeling a bit stupid right now :D
I'm instead now using interpolation to add the detail, which has helped a lot, but it currently generates a few artefacts which I'll still have to figure out how to get away :)


Anyway, I'll also begin to create some documentation on the basic usage. A first public release should really be any day this week :)
User avatar
luis
Greenskin
Posts: 122
Joined: Tue Mar 02, 2004 3:33 pm
Location: Spain / Argentina
x 7

Post by luis »

Great work CABAListic !
I'm very interested in this editor :)

I'm using the 'standard' TSM and i would use your editor to export the terrain texture and heightmap image.
some questions:
what GUI lib are you using ? wxWindows maybe?
does it run/compile under linux?

thanks for sharing ;)
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66

Post by sinbad »

Very good news, thanks for sharing this. Given that you're releasing it under an open source license we'd be happy to host the CVS in ogreaddons and downloads if you needed it, to save your bandwidth.
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Post by CABAListic »

@luis: The editor seen in the screenshots is just a very early trial ground for our project's own map editor, and it will be tied closely to the needs we have. Being a revival project of the good old RTS classic Z (as some of you might have guessed by the screenshots), it'll of course offer basic terrain editing, but it will also concentrate on defining sectors and factories. I'll release the editor with the game, but that will not happen for quite some time, I'm afraid :)
That aside, yes, it's wxWidgets, and yes, it's compiling and running on Linux (although the window resizing does not yet work, haven't figured that one out).

@sinbad: Thanks for offering, I'll consider it. For the time being, though, I have quite a bit of bandwidth left with my hosting, I don't expect it to run short because of this project.
BSer
Halfling
Posts: 95
Joined: Fri Dec 23, 2005 8:46 pm
Location: Niskayuna, NY

Post by BSer »

Wow! This is adding a slew of things that I was going to do myself, and I was dreading the time I would've needed. Like you I would've given back to the community if I could pull it off. Awesome, you've saved me a lot of time!
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16

Post by KungFooMasta »

Hey CABAListic,

I know only 1 day has passed since you've posted, but I'm really excited! :D

Any updates on your scene manager? Is it a plugin?

KungFooMasta
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Post by CABAListic »

Yeah, actually I've just assembled a first public source release. You can grab it here: http://downloads.oddbeat.de/ETSM_public_v1.zip

It's by no means complete, decals are still missing (they are TROUBLE!), and I guess that a couple other things like shadow casting on the terrain won't work quite out of the box. The dynamic material used for editable splatting is still a bit too simple, and there's as of yet no way to plug in a custom material.

Also I haven't gotten to put some documentation together. In the package included is a simple editing demo that you can try out, it should explain the most basic things. With time I will put more documentation online as well as add the missing features :)
(for a shot of the demo see here: http://www.oddbeat.de/wiki/_media/etsm_ ... ache=cache)

But it won't quite happen too soon, because I'd also like to get along with the Z revival, and since I can't code full time on two things, I have to distribute my time a bit ;)
Still, let me know what you think, what you really need that's not there yet, what's just not working etc..
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16

Post by KungFooMasta »

Awesome!

Is this wiki page on TerrainMeshDecal irrelevant?

http://www.ogre3d.org/wiki/index.php/TerrainMeshDecal

Will definately provide feedback when I get my hands dirty with this. :)

KungFooMasta
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Post by CABAListic »

You can likely use it, but the result is probably only mediocre. To get it good, the decal needs to be fully aligned with the terrain, following LOD changes and LOD borders and what not. It's tricky...

Btw, I forgot to mention: In the demo, you can use the middle mouse button to rotate the camera, while left/right buttons will edit the terrain. Keys 1 to 4 will switch to texture painting and select one of the 4 available textures. Key E switches back to terrain deforming. Key O finally saves the terrain along with a light- and minimap (just as examples).
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Post by jacmoe »

Looks like it already does most of the things I ever wanted for a terrain editor! This is going to be awesome! :D
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16

Post by KungFooMasta »

Sorry for the noob questions..

How can we load a brush from an image?

Code: Select all

int brushSize = 13;
mEditBrush = new float[brushSize*brushSize];
. . .
Also, how does tiling come into play? Does this tie into painting the terrain?

Code: Select all

# How often should the splatting textures be tiled over the terrain?
TextureRepeatX=20
TextureRepeatZ=20
I read through the sample and it looks really easy to follow. :D You must have put in a lot of time to make the demo, thanks a lot!

CABAListic == 8)

KungFooMasta
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Post by CABAListic »

To load from image, you could do something like this:

Code: Select all

Image image;
image.load("brush.png", "General");

// TODO: Make sure that width and height are the same and that
// the image format is PF_L8 (you could use something else, but for
// this example I'm assuming it's an 8-bit greyscale image
int brushSize = image.getWidth();
float* brush = new float[brushSize*brushSize];

const uchar* imgData = image.getData();
for (int i = 0; i < brushSize; ++i)
{
  for (int j = 0; j < brushSize; ++j)
  {
     brush[j*brushSize+i] = imgData[j*brushSize+i] / 255.0f;
  }
}

As for the texture tiling: This simply means that your splatting textures will fit X times onto the map. If you use a high value, your terrain might look very tiled, just try it out, you'll see what it does :)
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Post by jacmoe »

CABAListic wrote:As for the texture tiling: This simply means that your splatting textures will fit X times onto the map. If you use a high value, your terrain might look very tiled, just try it out, you'll see what it does :)
I believe you can use vertical texture mapping to get rid of the banding artifacts. :)

http://www.quadsoftware.com/html/Editor ... ertmap.htm
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Would you like some help developing this?
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Post by CABAListic »

I believe you can use vertical texture mapping to get rid of the banding artifacts. Smile

http://www.quadsoftware.com/html/Editor ... ertmap.htm
Hm, that looks nice. I'll have to take a closer look at that when I find the time :)


@xavier: I'll happily accept contributions / patches / whatever (so long as it doesn't break what I need it for :D ). If someone wants to do decals, excellent. If you can contribute that kind of texture mapping and have the time, do it. :) Other than that, most tasks that come to my mind are no major work. But then again, I'm mainly thinking about what I'll need. :)