Elevation in a BAM File

Download scenarios and talk about scenario design.

Moderators: Slitherine Core, BA Moderators

Post Reply
parmenio
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 105
Joined: Sun Jan 10, 2010 5:41 pm

Elevation in a BAM File

Post 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.
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: Elevation in a BAM File

Post 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
follow me on Twitter here
parmenio
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 105
Joined: Sun Jan 10, 2010 5:41 pm

Re: Elevation in a BAM File

Post 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)
parmenio
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 105
Joined: Sun Jan 10, 2010 5:41 pm

Re: Elevation in a BAM File

Post 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.
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: Elevation in a BAM File

Post 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
follow me on Twitter here
parmenio
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 105
Joined: Sun Jan 10, 2010 5:41 pm

Re: Elevation in a BAM File

Post 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.
parmenio
Senior Corporal - Destroyer
Senior Corporal - Destroyer
Posts: 105
Joined: Sun Jan 10, 2010 5:41 pm

Re: Elevation in a BAM File

Post 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.
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: Elevation in a BAM File

Post by pipfromslitherine »

Glad to help!

Cheers

Pip
follow me on Twitter here
Post Reply

Return to “Battle Academy : Scenario Design”