Jump to content
Official BF Editor Forums
[BG2]Panzaman

Heightmap Utility

Recommended Posts

[Edit: Since this post a new version has been released with more features - see further in this thread]

By way of a late Christmas present, at Battlegroup Frontlines we are releasing a heightmap program which we hope will be useful to fellow modders and mappers. It is a fast and easy utility for viewing and resizing heightmap (.RAW) files. It is primarily intended to make it easy to convert maps from Battlefield 1942 or Battlefield Vietnam to Battlefield 2, but it can also be used to change a BF2 map to a different size.

Long-term Battlegroup42 fans will recall that we converted many classic BF42 and BG42 maps to the Battlefield Vietnam engine, including Midway, Guadalcanal, Coral Sea, Gavutu Islands, Angaur and others. Since moving to the BF2 engine we have been developing software that can automatically convert BF42 and BFV maps to BGF. This conversion involves first converting the heightmap using a heightmap utility, then converting the map objects with a map converter program. We are pleased to release the heightmap utility today, and may release the map converter program at a later date (after the release of BGF). We have successfully converted a number of BF42 and BG42 maps to BGF, and today we have pleasure in showing work-in-progress screenshots of some of them. These include the classic open-steppes Operation Citadel map, and the Dnieper River map, from BG42, plus the original DICE Kursk map. Note that these are shown as they were originally converted; apart from the addition of basic vegetation they have not yet been manually improved. Citadel and Dnieper will be worked on by our mappers to bring them up to the BGF standard, while there are no plans to release Kursk or any of the other DICE maps.

NEW LINK... SEPT 2, 09

http://www.filefront.com/6471119/Battlegro...ghtmap-Utility/

HeightmapUtility.jpg

Citadel_Pz3a.jpg

Citadel_T34b.jpg

DnieperRiver_RussianBase2.jpg

DnieperRiver_CentralBase2.jpg

Kursk_RussianBase2.jpg

Kursk_GermanBase2.jpg

Kursk_CentralBase2.jpg

Edited by Catbox

Share this post


Link to post
Share on other sites

:o Awsome, ive never actually played BF42 and BFV (Bf2 is my first and hopefully last).

I will search the web near and far for some great city maps then convert em, navemesh em and blow up the AI....

Fun for all!

just a quick q : does that PPSH have 75+ rounds ? cause it has em on CoD2 and its ridicilous!

Edited by DarthSkyline

Share this post


Link to post
Share on other sites
Cool tool man , makes it very easy to do ;)

Can you confirm it works for you? And can you show any screenshots of your results? I'd really appreciate it to get some feedback.

Edited by [BG2]Panzaman

Share this post


Link to post
Share on other sites

all i did was convert a few of bf1942 heightmaps, and get them in editor... havent painted them, or anything so they wount be very good screenshots... but i can show if you like?

Also i had a old map with a messed up heightmap, couldnt even open the heightmap in PS kept saying unexpected file size or somthing, but a quick convert with your tool fixed it :P

Share this post


Link to post
Share on other sites
all i did was convert a few of bf1942 heightmaps, and get them in editor... havent painted them, or anything so they wount be very good screenshots... but i can show if you like?

Also i had a old map with a messed up heightmap, couldnt even open the heightmap in PS kept saying unexpected file size or somthing, but a quick convert with your tool fixed it :P

Thanks for the feedback, glad it was useful!

If you have bf1942 maps that you created yourself, you can reuse the textures as well if you want. Basically create a new BF2 map of the right size, use this utility to convert the heightmap, then copy across the textures to the Editor/Colormaps folder. If you go in to the Editor and just change slightly (touch) the heightmap and textures (e.g. in a hidden corner) then save it will convert everything correctly for you.

Share this post


Link to post
Share on other sites

Latest news - a new version is now available. It allows flipping and mirroring of the primary heightmap, plus it can automatically create the secondary heightmaps from the primary one. I'll post it here, as soon as I can get it hosted.

Share this post


Link to post
Share on other sites

What would be good to have now would be a program that flipped or enlarged the skins B) . Just in case a mapper makes a major booboo. :P

Share this post


Link to post
Share on other sites

BGF is pleased to announce the release of the new version of the Battlegroup Frontlines Heightmap Utility. You can find it on our download page at www.bgfmod.com, plus the link at the start of this thread has been updated.

Version 2.0 New Features

1) Can automatically create secondary heightmaps (can even be used for maps you've already made, but not done the secondaries for)

2) Can flip a heightmap (both vertically or horizontally or both)

3) Allows the opening of raw files with the .MAT extension, such as the BF2 heightmapprimary.mat material map files.

I use these features to convert BF42 maps to BF2, but they have other uses too.

New Instructions

To flip the heightmap so it is changed in memory (and permanently on disk if saved) then use the Flip button, selecting the Horizontal option as required (if not selected then the heightmap is flipped vertically). To flip it both ways, do it once with the horizontal option on and once with it off.

Create surrounding terrain: these are areas of terrain around the central play area. They do not need to be as accurate or detailed as the primary heightmap as they cannot actually be played on, they are just to give the impression that the terrain goes on further. They can be a pain to make manually, particularly so they join up seamlessly with the primary heightmap, so this utility can create them automatically from the primary heightmap (use the ‘Also create BF2 secondary heightmaps’ option).

The idea for making secondary heightmaps is pretty simple - if you flip the primary heightmap vertically you can use it as the secondary heightmaps above and below the primary heightmap and it will join perfectly (virtually pixel perfect). Likewise if you flip it horizontally (mirror it) you can use it for the secondary heightmaps on either side of the primary heightmap. Finally, if you flip it both ways it can be used as the 'corner' secondary heightmaps, and in all cases it will join seamlessly.

The only complications are that the secondary heightmaps have to be a different size to the primary heightmap (typically 257x257) and they need to be converted from 16bit to 8bit, so the utility does these conversions too. It then saves them off with the correct names so they can just be dropped into a map - but backup first (if they aren't currently activated, they need to be activated in the Editor, then Render/surrounding heightmaps to see them).

Full List of Features

- Loads 16bit or 8bit heightmaps in the RAW format (as used for terrain heights, material maps, shadow maps and vegetation maps); they must be square

- As well as files with the .RAW extension it is possible to load files with the .MAT extension (e.g. BF2 material maps).

- Loaded heightmaps are drawn graphically (with a High Brightness option to show dark materialmaps more clearly)

- Heightmaps can be resized

- Heightmaps can be flipped vertically

- Heightmaps can be flipped horizontally (mirrored)

- Multiple operations can be conducted on a heightmap in memory before saving to disk (e.g. flip horizontally, resize, flip vertically, save, etc.) and the results are shown at each stage.

- On saving, there is an option to create secondary heightmaps from the primary heightmap in memory. This is done automatically by resizing it to 257x257, converting it from 16bit to 8bit, and flipping it vertically and horizontally as necessary to create the secondary heightmaps so they join up seamlessly. All 9 files are then saved to disk.

Here's an example of its use, where a BF42 map has been converted to BF2 - the utility automatically converted the primary heightmap and created the secondary heightmaps. The primary textures have been converted into a single texture and used to texture the secondary heightmaps - this part is currently a manual process.

SecondHeightmapsTextures.jpg

Edited by [BG2]Panzaman

Share this post


Link to post
Share on other sites

This is a great tool used by me A LOT. Everybody should try it out and I dont say this only because I am a member of BGF. It is really useful and saves time.

Share this post


Link to post
Share on other sites

excellent...ive been having some whacky surrounding terrain problems so im hoping regenning the surrounding terrain will help...

Me adn Rhino at Project reality have been over this surrounding terrain bug a few time with no solution... :(

Share this post


Link to post
Share on other sites
excellent...ive been having some whacky surrounding terrain problems so im hoping regenning the surrounding terrain will help...

Me adn Rhino at Project reality have been over this surrounding terrain bug a few time with no solution... :(

Sure, shout if you hit a problem.

Share this post


Link to post
Share on other sites

I've been playing around with the tool to convert one of our BF1942 maps with it and the tool itself works great. My trouble is about re-using the old map textures. For some reason i cannot fit them on the terrain anymore. The orginal map was a 'small' map with a 512 * 512 heightmap. How does that correspond to the BF2 sizes ? According to Tomcrafts ED42 tutorial, the textures should fit as they are, but they don't. Any ideas ? where is my basic error ?

For the small bf1942 map , i created a new 512 scale 1 map (then put in the converted heightmap and the original textures into /colormaps) and that didn't work. I then created a 512 scale 2 map with the same misalignment of the textures :(

Edit: Solved my problem :D The maps i wanted to convert where 'medium' maps , but the mappers left out most of the textures for the surrounding areas. So i was fooled into thinking that they were small maps.

There are a few questions left: Is there a way to re-use the materialmaps from BF1942 ? It would be great to have them as a basic layout for generating the detailmaps. I converted them with the tool to BF2 but the layer setup is not as easy as i expected....

Edited by mschoeldgen[Xww2]

Share this post


Link to post
Share on other sites

Glad you sorted your main problem.

There are a few questions left: Is there a way to re-use the materialmaps from BF1942 ? It would be great to have them as a basic layout for generating the detailmaps. I converted them with the tool to BF2 but the layer setup is not as easy as i expected....

I have not yet investigated reusing the BF42 material map for BF2 directly, that's on my todo list. However, I have very successfully used it as the basis for autogenerating undergrowth for the BF2 map. Basically, the BF42 materialmap.raw is 8bit with 16 colours, 0-15, that represent the materials in the original map (dry grass, wet grass, mud, roads, etc.). The BF2 undergrowth.raw is 8bit with 16 colours, 0-15, that represent the undergrowth in a BF2 map (grass, gravel, mud, roads, etc.) so you can probably get the idea. I have ~16 undergrowth types defined, these map 1:1 to the BF42 numbers, and - hey presto - resizing my BF42 materialmap with my Heightmap Utility and renaming it gives me automatic undergrowth in the BF2 map. Then you just need to edit it a bit by hand as BF42 mappers tended to be a bit lazy with some of their material placement (e.g. sometimes putting a village house down on grass, so in BF2 there's grass growing inside the house).

This is the method I used on Kursk, for example:

Kursk_RussianBase2.jpg

Edited by [BG2]Panzaman

Share this post


Link to post
Share on other sites

Hey, now thats smart ! :D

I'll try that with my testmap asap. However, the heightscale of the original map was way different from the converted result, so i need to fiddle with the scale a bit more. It seems while the BF1942 maps all had a fixed scale for height, the BF2 maps have a variable for that. Need to find the right value for it :P

Share this post


Link to post
Share on other sites
Hey, now thats smart ! :D

I'll try that with my testmap asap. However, the heightscale of the original map was way different from the converted result, so i need to fiddle with the scale a bit more. It seems while the BF1942 maps all had a fixed scale for height, the BF2 maps have a variable for that. Need to find the right value for it :P

Actually, for the BF42 map you need to find:

geometrytemplate.yscale X

Then in your BF2 map terrain.con you need:

terrain.primaryWorldScale 2/[X divided by 256]/2

terrain.secondaryWorldScale 4/[X]/4

and in your heightdata.con:

heightmap.setScale 2/[X divided by 256]/2

- this is reading through the code I have written to convert maps automatically.

Actually, if you wanted to do it manually, you could probably just load the BF2 map into the editor and set the terrain height to be 256*X and it will probably write out the terrain.con and heightdata.con correctly for you.

Edited by [BG2]Panzaman

Share this post


Link to post
Share on other sites

Yeah, i could fix the heightscale and it looks good now :D Thanks for the numbers, hehehe. I think i found a way to convert the materialmaps . I have created a small table-driven application to map the BF1942 materials onto their counterparts in BF2 and writing out the new 'HeightPrimary.mat file' after resizing it with the BGFHeightmap Tool. Unfortunately, not all materials in BF2 have BF1942 conterparts, like wood and and plastic, but it gives you a basic material layout.

I'll test it a bit further and will then release the program. It uses an external table, so you could edit that for different mappings.

The undergrowth trick works marvellous once i retrieved the 'materialmanagerdefine.con' from game.rfa :P

Great stuff !

For your convenience here's the table for terrain materials from BF1942 and the BF2 mappings:

   BF1942				BF2
0 Default					Default
1 Water						Water Deep
2 DryGrass					Sand
3 JuicyGrass					Gravel
4 Dry Dirt					Tarmac
5 Wet Dirt					Grass
6 Mud						Grass_Tall
7 Reserved(forbidden)			Reserved
8 Gravel					Dirt
9 Frozen					Water_puddle
10 Dry Sand					Cloth_carpet
11 Wet Sand					 Plastic
12 Rock (Omaha)				Rock
13 Sand Road					Trash_light_object
14 Dirt Road					 wood_thin
15 Paved Road					wood_solid

Edited by mschoeldgen[Xww2]

Share this post


Link to post
Share on other sites

So you're reading each byte from the heightmapprimary.mat file and replacing it from the table (e.g. reading Drygrass/2 and replacing it with Grass/5, or Drysand/10 and replacing it with Sand/2)? I haven't got around to trying that yet myself so thanks for the table, it'll save me some time.

Edited by [BG2]Panzaman

Share this post


Link to post
Share on other sites
So you're reading each byte from the heightmapprimary.mat file and replacing it from the table (e.g. reading Drygrass/2 and replacing it with Grass/5, or Drysand/10 and replacing it with Sand/2)? I haven't got around to trying that yet myself so thanks for the table, it'll save me some time.

First i resize the materialmap.raw from the '42 map with your tool, then i run my program to read in this materialmap.raw and write out a HeightmapPrimary.mat with the appropriate BF2 materials.

I'll write a small readme for the tool and give out the link to it laters. Depending on the external table file, it can map anything, so it might be useful for other stuff :D . As there's still some code for BMP's in it, it can also read in a BMP and write out the RAW , so maybe its useful for other purposes.

Edit: O.k., here's the link to the Material Converter:

http://www.schoeldgen.de/bf1942/MaterialmapConverter.zip

I have included a sample table and a bf1942 materialmap.raw. C source is included, too. 77 kByte download :D

The BMP conversion is only roughly tested and only supports uncompressed 8/24 bit BMP's . Make sure to have a look at the txt file for usage.

Edited by mschoeldgen[Xww2]

Share this post


Link to post
Share on other sites

Cheers - I'll take a look soon (when I get back to mapping - currently I'm exporting our Kubelwagen). So maybe you have an idea for another issue I was working on. My Map Converter program includes the heightmap utility code to resize a bf42 heightmap and generate all the surrounding heightmaps. It also does all the other stuff, like copying across the textures, creating the undergrowth, replacing and repositioning statics/spawns/control points, etc. However, to texture the surrounding heightmaps I need to combine the multiple terrain textures into a single one (using the BF2 Mod Toolkit or TPaint or similar) then manually flip and rename as necessary to make the secondary textures. Do you know a way of doing that programmatically?

Edited by [BG2]Panzaman

Share this post


Link to post
Share on other sites

Hmm, sounds like a job for the DXTLib... I didn't examine nvdxt's abilities to flip a texture yet, but its good at CLI driven resizing. The task of converting the DDS to a bitmap , flipping it line by line and converting it back to DDS would be more complicated, but necessary if nvdxt doesn't have a flip command.

Sorry , i'm on a Mac atm, so i can't check the command set of nvdxt.

Share this post


Link to post
Share on other sites
Hmm, sounds like a job for the DXTLib... I didn't examine nvdxt's abilities to flip a texture yet, but its good at CLI driven resizing. The task of converting the DDS to a bitmap , flipping it line by line and converting it back to DDS would be more complicated, but necessary if nvdxt doesn't have a flip command.

Sorry , i'm on a Mac atm, so i can't check the command set of nvdxt.

Ta - I've looked at nvdxt a few times but all the help for it seems to be about how to convert between formats, etc. Line by line doesn't seem the way to go.

Share this post


Link to post
Share on other sites

Just wanted to draw the attention of mappers - especially beginners - to this great tool. It not only converts heightmaps and resizes them at will but also creates the surrounding terrain tiles in a manner that they are matching the existing borders of your primary terrain. This will save you a lot of work.

After the creation of the surr. terrain tiles you could simply run bf2_tpaint to texture them. Voila, surrounding terrain with zero-effort !

Thanks to Panzaman !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×