Larian Banner
Previous Thread
Next Thread
Print Thread
Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
I'm wondering if the file formats have changed much between games. Has anyone examined the file structures yet ? Is the terrain format still accurate ?

https://divinity.gamepedia.com/Terrain_format

If someone knows a good work method in deciphering the new file types I would be very interested as well. Here is a plea to Larian as well ... please give us all this information, ... PLEASE ?

Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
I just digged into it myself and it is not the same anymore. This time a terrain is divided in four files

- 27787528-c1c0-83ab-3b64-ff0a1193f86e.data
- 27787528-c1c0-83ab-3b64-ff0a1193f86e.lsf
- 27787528-c1c0-83ab-3b64-ff0a1193f86e_0.bullet
- 27787528-c1c0-83ab-3b64-ff0a1193f86e_0_0.patch

I took a flat terrain and then just updated a small patch in height and saved the entire thing. The only two files that got updated where .bullet and .patch. My first guess is that heightdata is saved in the patch file since that file seems to have changed the most.

From what I can tell the first 9 bytes are the string PVersion4. The rest of the file is probably the height data. Although I can't tell if it actually starts straight after or there is something else. I think it does cause the first byte is 00 and I'm working with a mostly flat terrain. It's not until far later in the file the data starts changing.

I tried creating a simple 1 on 1 terrain and it seems starting from offset 00001110 there starts to be other kind of data. I just put one point in the terrain to an insane height, and I see the expected bytes change after the Pversion4 but then all the bytes after 00001110 start to explode as well. So there must be more meaning to them for the heightmap frown

Again I would be very very very grateful if Larian would explain these four files to us. I think I can update my height map importer for D:OS2 but I need some more information first.

Last edited by Celludriel; 18/09/17 03:20 PM.
Joined: Sep 2017
member
Offline
member
Joined: Sep 2017
after the "Pversion4" (8 bytes) comes the patch data version (4 bytes)

followed by the heightmap, vertex count, vertex data (int2), index count, index data, patch index, and layer data (layer count, layer index, layer index buffer size, layer index buffer, layer alpha map size, layer alpha map)

you can leave out the layer data by replacing it with a UINT32_MAX instead

the .bullet files contain physics data, I am not sure how well the terrain will load without it

Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
Thanks JB !!!

I wonder technically if I would edit the heightmap in the patch file, then load it in the editor and save it again would it recalculate the .bullet files ? This is something I can experiment with. I got a weeks vacation coming up and I can go deeper into this.

Thanks for explaining the format sofar. The layers I could use if I would also want to include auto texturing from a heat map bitmap or something but that will probably take me weeks to develop. I remember last time I did this for the L3DT importer I almost went beserk from frustration smile

Joined: Sep 2017
member
Offline
member
Joined: Sep 2017
To clarify the layer data, the layer count is always there and the rest of the layer data is replaced by a UINT32_MAX if the layer is empty.

so the end of the patch file goes: patch index > layer count > layer data (for each layer, UINT32_MAX if empty)

good luck!

Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
Thanks JB I'm going to need it , you guys made it really challenging this time around smile The previous format was so much easier smile

Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
Well I started my work on the importer, you can follow my progress on

https://github.com/Celludriel/DOS_T...porter/Importer/Dos2GrayScaleImporter.cs

However I believe I'm going to be stuck on the vertex issue for sure, I have no idea what that data serves for nor how it's calculated from the heightmap data. So not sure this will amount to something. The file data is to different from the original one.

update
=====

So I'm stuck but learning a bit more along the way. I can't take my old assumption that terrain data is just one file. As been proven before. The data is fragmented a bit, it used to have the size of the heightmap in amount of bytes as the first part of the heightmap data. This is no longer the case, it seems the bytesize to read is determined by reading the width and height from the lsf file.

So I need another way to determine the bytesize of the heightmap. There has to be some kind of formula to determine this meter x meter = bytesize or patch size * patch size = bytesize.

Can anyone help me with this ?

Last edited by Celludriel; 25/09/17 12:21 PM.
Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
I started trying to find out the dimension of the heightmap

I believe on a 1x1 patch the total size of the heightmap = 4356 bytes. Taking in account that one heightmap entry is a float of 4 bytes we can conclude that to get the total amount of points in the heightmap is (heightmap bytes / 4). So now we know the total amount of points in the heightmap. Taking a heightmap is width * height, this means that if our patch is 1 x 1 we should get the width and height of the heightmap by taking the square root.

total_heightmap = 4356
amount_heightmap_points = total_heightmap / 4 = 1089
width_height_size = SQRT(amount_heightmap_points) = 33

so I think our heightmap for a 1x1 patch is

33px x 33px bitmap file


update:

I was able to write a heightmap file to a patch file without breaking the file size. So my old import is working on this new file.

code:
https://github.com/Celludriel/DOS_T...porter/Importer/Dos2GrayScaleImporter.cs

However the height in the editor is not changing which is what I was afraid of. Those vertex things have something to do with the whole affair and I have no idea how to handle that.

Last edited by Celludriel; 25/09/17 01:25 PM.
Joined: Sep 2017
member
Offline
member
Joined: Sep 2017
Hi Celludriel,

Are you parsing the patch files in "Data\Editor\Mods\{Project}\Levels\{Level}\Terrains\" or the ones in "Data\Mods\{Project}\Levels\{Level}\Terrains\"?

Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
Data\Mods\Godlings_7ffdb20a-bb9e-4ca6-a3d3-46a3d0c650d3\Levels\ImportTest100x100\Terrains

Is my current workspace directory. Am I using the wrong one ? I'll look at the other path as well.

Update
=====

I was using the wrong mod folder as you pointed out, trying the other one it worked ! I was able to import my heightmap into the patch file and the height changed into the editor.

Further testing is needed to see if the level works as it should but this is promising !

Last edited by Celludriel; 25/09/17 01:44 PM.
Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
Here is the result of my first test run

Size: 1x1

Heightmap:
[img:center]http://users.telenet.be/sunspot/dos/grayscaletest.bmp[/img]

Result:
[Linked Image]

I have added a water layer terrain so you can see the height differences better, notice the two top lakes coincide with the dark spots on the heightmap

Last edited by Celludriel; 25/09/17 02:28 PM.
Joined: Dec 2013
old hand
Offline
old hand
Joined: Dec 2013
celebrate

Great work!


DOS2 Mods: Happily Emmie After and The Noisy Crypt

Steam Workshop
Nexus Mods
Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
Thanks Windemere,

It was fun figuring it out and thanks to JB for his help. There are a few things that still feel weird though. So I figured out that a 1*1 patch is a 33px*33px heightmap. But that scales so funny, it might not be a coincidence that it's actually x+1 * y+1. So taking that in mind I think a 1*1 patch is actually (32px + 1px) * (32px + 1px).

I have to do some tests with different sizes now so I think the following is true a 2*1 patch is probably:

(64px + 1px) * (32px + 1px)

This has to be taken in account when creating a terrain and deciding the size of a heightmap. Also this has as consequence that you probably have to be careful when deciding the patch size. a 0.665 * 1 patch size could have unpredicted consequences if your heightmap px size end up in a float as well which is impossible. Can you imagine a 22.4px * 33px .... can't be done ... Do do we round up or round down ...

more testing is needed

Last edited by Celludriel; 25/09/17 03:00 PM.
Joined: Dec 2013
old hand
Offline
old hand
Joined: Dec 2013
I think if in order to make the scaling easier, you rounded down the imported heightmap and filled the outside border of the terrain to height 0 to fill out the chunk, it would be fine. You can easily cut terrain if need be from the editor.


DOS2 Mods: Happily Emmie After and The Noisy Crypt

Steam Workshop
Nexus Mods
Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
I guess it's better to have a left over edge then break the filesize, so yes probably rounding down should be the way to go. I'll try and make a binary release tomorrow, and write a little tutorial how to use it. I might recycle my old thread if it's still around smile

This title doesn't really fit a release

Joined: Dec 2013
old hand
Offline
old hand
Joined: Dec 2013
I'll be happy to test it out. Britannia awaits thee!


DOS2 Mods: Happily Emmie After and The Noisy Crypt

Steam Workshop
Nexus Mods
Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
Here is a fun test, something close to my heart was making an easy way to create a dungeon. It's not perfect cause the walls are slanted instead of vertical. Not sure yet how you fix that but this is another 1*1 test. The corridors are also way to small to be gameplay ready so there is that to deal with but still, not a bad result for a first try.

bitmap

[img:center]http://users.telenet.be/sunspot/dos/dungeon%20test.bmp[/img]

Result

[Linked Image]

Last edited by Celludriel; 25/09/17 11:12 PM.
Joined: Jul 2014
enthusiast
Offline
enthusiast
Joined: Jul 2014
Originally Posted by Celludriel
[...] but still, not a bad result for a first try.


wow that's absolutely amazing. Inwas really hoping for some heightmap terrain generator. Keep up the good work.

Joined: Dec 2013
old hand
Offline
old hand
Joined: Dec 2013
Hey, that may be easier than the wall editor in some cases. oops


DOS2 Mods: Happily Emmie After and The Noisy Crypt

Steam Workshop
Nexus Mods
Joined: Jul 2014
C
member
OP Offline
member
C
Joined: Jul 2014
Originally Posted by morez
Originally Posted by Celludriel
[...] but still, not a bad result for a first try.


wow that's absolutely amazing. Inwas really hoping for some heightmap terrain generator. Keep up the good work.


Thanks it was fun figuring it out

Originally Posted by Windemere
Hey, that may be easier than the wall editor in some cases. oops


Ideally I would write a tool that could create a dungeon with the wall editor, but since there is no plugin support and the API for the wall editor is non existent. I'm NOT going to figure out how to write it byte by byte to the file smile. This is the best I can do for now

I released my latest version btw


Moderated by  Larian_Koala, Larian_KVN 

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