Page 1 of 1

Elevation in a BAM File

Posted: Mon Jan 19, 2015 8:24 pm
by parmenio
So.... the last bit to get working on map reversal is how elevation is stored.

I can see it's in this section:

[FPHEIGHT]
HEIGHTDUO 00100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000000000000000000000000000
HEIGHTDUO 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

I've raised the tile at 0,0, by 1 but I can't figure out what I'm looking at here.

Any help would be appreciated.

Re: Elevation in a BAM File

Posted: Mon Jan 19, 2015 8:54 pm
by pipfromslitherine
Urgh. That is going to be nasty. That is a binary chunk that we store. It is made up of 2-byte height elements (signed), encoded as chars (2 chars per byte, starting at character value 48 (the zero character). There is one value per vertex on the map (so widthInTiles+1 * heightInTiles+1).

Cheers

Pip

Re: Elevation in a BAM File

Posted: Tue Jan 20, 2015 7:20 am
by parmenio
pipfromslitherine wrote:Urgh. That is going to be nasty. That is a binary chunk that we store. It is made up of 2-byte height elements (signed), encoded as chars (2 chars per byte, starting at character value 48 (the zero character). There is one value per vertex on the map (so widthInTiles+1 * heightInTiles+1).

Cheers

Pip
It's certainly going to be the worst section to worth with! My initial reaction was ¿Que?
However, now I've played around changing things in the editor and see what's stored as a result, I can see what I need to do.

Thanks for the info.

(this has been more of a challenge than I expected but at least once done I can get back to what I should have been doing in the first place which was AI scripting)

Re: Elevation in a BAM File

Posted: Wed Jan 21, 2015 7:32 am
by parmenio
Ok - I'm obviously missing something here. I have a test map of 48 x 48 which equates to 2401 vertices ( (48+1) x (48+1) ).
I've presumed 4 characters in the FPHEIGHT section per vertex (2 byte elements 2 characters per byte) which gives me a string length of 9604 (2401 x 4).
However, when I read the data in from the file, concatenate all the HEIGHTDUO elements I end up with a string length of 19208 - precisely double.

??!!??!!! Not sure what's going on.

Re: Elevation in a BAM File

Posted: Wed Jan 21, 2015 4:31 pm
by pipfromslitherine
Ah - you are correct. There are actually 2 heights - one is the variable height which can change based on objects on the tile, and the other is the base height of the terrain. So yes, 2 2 byte elements per vertex. Sorry - been a while since I looked at it!

Cheers

Pip

Re: Elevation in a BAM File

Posted: Wed Jan 21, 2015 8:18 pm
by parmenio
Thanks for the reply. I'd got as far as working out I seemed to have a duplicate copy - with no idea why.

Re: Elevation in a BAM File

Posted: Thu Jan 22, 2015 8:48 pm
by parmenio
Pip - thanks for information provided. I now have a working application. Not sure I'd have got there on my own without your help.

Re: Elevation in a BAM File

Posted: Fri Jan 23, 2015 4:31 pm
by pipfromslitherine
Glad to help!

Cheers

Pip