Terrain Editor / Importer / Exporter

Moderators: GSH, VSMIT, Red Devil, Commando

Post Reply
Nitroxis
Scrap
Posts: 5
Joined: Sun Feb 05, 2012 2:28 pm

Terrain Editor / Importer / Exporter

Post by Nitroxis »

Hi all.
Quite some time ago I wrote a small tool that let's you import BZ2 terrain files, replace the different map-sections like the height map, color map, alpha maps, etc. with imported bitmaps, export it back into BZ2 terrains and even display it in a simple 3d preview. I hope it's useful for mappers.

Here's a screenshot of the main window:
Image

I tested the tool but I do not guarantee for anything. If you find bugs, please tell me, but be warned: Always make backups in case something goes wrong. This tool isn't able to generate whole maps itself. Just go into the BZ2 Editor, create a map there and then edit it with the tool afterwards.

It's open source (GPL) and uses the .net Framework.
Download: Executable files|Source Code
Last edited by Nitroxis on Fri Apr 13, 2012 11:41 am, edited 1 time in total.
User avatar
Ded10c
Recycler
Posts: 3815
Joined: Sun Feb 20, 2011 11:05 am
Location: Stoke-on-Trent
Contact:

Re: Terrain Editor / Importer / Exporter

Post by Ded10c »

Sounds like Winter with import. Could be really useful, I'll make sure to try it out next time I make a map. By the way, you might want to consider submission to BZScrap.
User avatar
Nielk1
Flying Mauler
Posts: 2991
Joined: Fri Feb 18, 2011 10:35 pm
Contact:

Re: Terrain Editor / Importer / Exporter

Post by Nielk1 »

Ah yes, Winter does all these things too. Last time I was helping OM with it he was adding a mapping of texture selection to color assuming a 16 color pallet.

EDIT:

I am glad to see that on your blog you post your source! I can try to implement some of the features OvermindDL1 and I were messing around with that were never completed.

EDIT2:

Hey, where do you get the OpenGLHelper library? I found the OpenTK stuff pretty easily. I just want to get it to compile here for now then get back to school work. Later I can try to figure out the CELL data that handles texture settings per tile and send you what I figure out.
Nitroxis
Scrap
Posts: 5
Joined: Sun Feb 05, 2012 2:28 pm

Re: Terrain Editor / Importer / Exporter

Post by Nitroxis »

Ummm... That's a library I made years ago, I'm not so sure if I still have the sourcecode for it. You should be able to just use the dll from the executables though.
But hey, if you're interested in developing it I could setup a git or svn repo. Are you interested? Or anyone else? Would be cool ^^

EDIT:
I added the source code here too for those that are interested. If anyone wishes to contribute something let me know.
User avatar
Clavin12
Bull Dog
Posts: 676
Joined: Fri Feb 25, 2011 4:50 pm
Location: The Deep(ish) South

Re: Terrain Editor / Importer / Exporter

Post by Clavin12 »

How might one get the .bzn file to point to the .ter file?

EDIT: Nevermind, I got it to work. It seems that when you save in the editor it doesn't just save a .bzn file.

P.S. This is awesome!
Nitroxis
Scrap
Posts: 5
Joined: Sun Feb 05, 2012 2:28 pm

Re: Terrain Editor / Importer / Exporter

Post by Nitroxis »

Yeah as I said, the editor can't create maps itself. It's only able to modify the terrain files. But, thanks :)
User avatar
Nielk1
Flying Mauler
Posts: 2991
Joined: Fri Feb 18, 2011 10:35 pm
Contact:

Re: Terrain Editor / Importer / Exporter

Post by Nielk1 »

OK, I'll just grab the OpenGLHelper from the compiled form then. (Don't know why I didn't think of that in the first place.)
User avatar
Nielk1
Flying Mauler
Posts: 2991
Joined: Fri Feb 18, 2011 10:35 pm
Contact:

Re: Terrain Editor / Importer / Exporter

Post by Nielk1 »

Nitroxis, I made a few small changes (renaming your Texture array into an Info array since that is what it is called in the actual BZ2 TER reading portion and so I can use the property name TextureMap for the actual texture map) and made a property to get the texture number (0 to 15) for a given X/Y for a given layer. That DWORD actually holds a bunch of data where only the first WORD of it is the textures. You will want to check what I did to be sure it still saves correctly as I have only tested reading.

I added the 4 new "images" to the 3D preview panel for now just for testing. You should be able to go from there.

It would be cool if we could down the road give the program a set of textures and have it render all 4 layers of them, using the alphas, onto the map in both 2D and 3D.

http://www.bzcomplex.com/myfiles/Terrai ... hanges.zip

This should give you a nice jump. :)

(I also found to my disdain that VB.net rounds a decimal to integer conversion rather than flooring it. I fixed in in the one case I ran into it but I don't know if that might have messed you up anywhere or if you were expecting it. Most programming languages 'floor' in that situation.)
Nitroxis
Scrap
Posts: 5
Joined: Sun Feb 05, 2012 2:28 pm

Re: Terrain Editor / Importer / Exporter

Post by Nitroxis »

Very cool! Thanks!
But I think you forgot to include the TerrainPreview.Designer.vb as that holds the controls, such as the menu items you added. The code doesn't work for me now because I don't have the new menu items and stuff.

Are you familiar with GIT or SVN? I could setup a repository as that would make cooperative development much easier.
And after I took a look at my code I think that it could be improved a LOT. I was a newbie when doing all that stuff ^^. As I said, I made that program one or two years ago. Maybe I should rework it if there are people actually interested in the project.

Edit:
We could even support textures and loading/saving BZN and TRN files. The textures defined in the TRN could then be shown in the 3D preview using the correct alpha maps. This would be awesome :D. It shouldn't be too hard to implement because BZN and TRN files are simple text files with a file format similar to INI files.
User avatar
Nielk1
Flying Mauler
Posts: 2991
Joined: Fri Feb 18, 2011 10:35 pm
Contact:

Re: Terrain Editor / Importer / Exporter

Post by Nielk1 »

Oh sorry, updated the zip with the missing file, and yes, I know SVN and GIT, I have AnkSVN in my VS2010 actually.

I was thinking about changing your code to use Clusters (those being 4 by 4 sections which you should have noticed matches how the file is saved) but it looked like a pretty big change to what you had, so I didn't Instead I just made sure the Info array was 1/4th the size in both dimensions.
Nitroxis
Scrap
Posts: 5
Joined: Sun Feb 05, 2012 2:28 pm

Re: Terrain Editor / Importer / Exporter

Post by Nitroxis »

Cool! Thanks for your help. I think I'll rework some stuff when I have some time. For now, the current version should do ;)
Post Reply