Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Page 3 of 3 1 2 3
Joined: Apr 2013
N
addict
Offline
addict
N
Joined: Apr 2013
Doesn't the game store terrain data in chunks if it's over a certain size (usually something like 256x256)?
Most game engines do this to avoid rendering the whole terrain when you're only seeing a part of it.

Joined: Jul 2014
C
member
Offline
member
C
Joined: Jul 2014
Well we believe it's a multiple of 32*32 tiles for bigger terrains. But I'm having a hard time figuring out the calculation of the multiples.

edit:

Bah forget everything I typed before in this post seems irrelevant after all.

I need some kind of reading strategy after the "TerrainPatchData" string.

Read layerheader
Calculate triangles
Read triangles
here it gets confusing do I Read another layerheader, or do I start reading the intensities, or do I read a set of triangles again ...

Last edited by Celludriel; 27/07/14 05:21 PM.
Joined: Jul 2014
C
member
Offline
member
C
Joined: Jul 2014
Figured some more stuff out, I just wrote all data to a text file and tried to see some patterns. I believe the order is like this

- read heightmap size
- read heigtmap data
- read padding string

repeat
- read triangle size
- read triangle data
end repeat
- read intensity size
- read intensities

- read extra texture layers

repeat
- read layer index
- read an int that seems to be an increasing number (paging number)
- read an int that seems to be always a 1
- read traingle size
- read triangles
- read intensity size
- read intensities
end repeat

This seems to be the algorithm, but I have no idea about that int that is always a 1

Last edited by Celludriel; 28/07/14 07:55 AM.
Joined: Jul 2014
C
member
Offline
member
C
Joined: Jul 2014
Aaargh I feel like strangling the guy that created that map format.

I'm now perfectly able to read 64*64, 128*128, 192*192, 256*256 and 320*320 maps. Yet when I try to read a 1000*1000 one I crash out with an end of stream. So AGAIN something special is going on when the size of the maps increase !!!!!!!!!!!

Joined: Jul 2014
C
member
Offline
member
C
Joined: Jul 2014
I managed to finish the parser and writer. I have a few unit tests to go, but after that I'm going to try the following

- Import an L3DT project by using the L3DT project file
--> Set height as in the L3DT project
--> For each climate in the L3DT project add a texture layer to the terrain
--> Write a tutorial how to make a fun playable map in L3DT and import it

My biggest challenge will be finding the right x,y coordinate in the ocean of texture tiles. Maybe it won't be that easy to just add a new texture layer as well but I'll cross that bridge when I get there.

Joined: Jul 2014
C
member
Offline
member
C
Joined: Jul 2014
I think I finally GOT IT !

Code
        private static uint CalculateBigTiles(uint x, uint y)
        {
            if (x % 2 != 0)
            {
                ++x;
            }
            uint xFactor = (UInt32)x / 32;

            if (y % 2 != 0)
            {
                ++y;
            }
            uint yFactor = (UInt32)y / 32;

            uint amountOfBigTiles = xFactor * yFactor;
            if (amountOfBigTiles == 0)
            {
                amountOfBigTiles = 1;
            }
            return amountOfBigTiles;
        }


I tested sizes:

1000*1000
127*127
128*128
192*192
21*21
254*254
256*256
320*320
63*63
64*64

So if any of you can think of sizes that would blow the entire thing up please tell me so I can write unit test for them !

Joined: Jul 2014
C
member
Offline
member
C
Joined: Jul 2014
I improved on the Terrain Importer. It now makes use of my library to read data files and it has progressbars when you click on the generate button. Enjoy !

http://users.telenet.be/sunspot/dos/DosTerrainImporter_v1.7z

or source at

https://github.com/Celludriel/DOS_Terrain_Importer

Last edited by Celludriel; 01/08/14 08:31 PM.
Joined: Jul 2014
C
member
Offline
member
C
Joined: Jul 2014
I improved on the heightmap tool it is still WIP so no release yet but I wanted to share a result. I now can import the heightmap of L3DT but also the attribute map. This map is then used to texture the terrain. I made a simple example with only 5 attributes so only 5 textures. but it looks ok

[Linked Image]

The idea is not to have a one button import and you have an expert playable map, but this will give a nice baseline to start adding features and spruce up the texturing. I'll soon bring out a first release, but for this one I had to do some things still manually in the larian editor (add the texture layers). I like to automate that as well.

Page 3 of 3 1 2 3

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5