BOD file specifications for use with conversion script

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

General Vash
Posts: 24
Joined: Thu, 30. Jan 20, 05:13
x4

BOD file specifications for use with conversion script

Post by General Vash »

Hello! I am absolutely loving X4 but the one thing that keeps bothering me is the lack of battleship class ships. VRO adds battleships to each faction, but they are based off the resupply ship model. That is great, but I wanted to make it a bit more distinct.

First I thought I'd just grab the Taranis out of XR Ship Pack and use that model for Argon, the Red Knight for Split, and the Kraken for Teladi, replacing the battleships added by VRO. That wasn't too difficult! However, I don't like the models from XR that exist for the Paranid because the artistic flavor is very different than X4's Paranid. So, I thought I'd port the Odysseus from X3, maybe make it a bit bigger to match the Zeus. How hard could it be? :gruebel:

I followed this post, but lacking the license for 3dsmax I tried using gmax instead, since I know DBOX2 is compatible with it. I got the ship imported to gmax, and used a Wavefront OBJ exporter script to make a .obj file, which I happily imported to Blender, since Blender can export as .dae and then XRConverter can make the XML from there.

The problem is that the script doesn't make the accompanying .mtl file, so the materials information is lost during export from gmax. As a result I end up with an object that has no textures in Blender. I am hoping someone can help me either figure out how to make the accompanying .mtl file from the .bod file, which I noticed has all the materials information at the top, or to write a .bod to .obj and .mtl converter. The main thing I need is documentation about what the BOD specifications are, so I know how to write a script to read the file. I already have sufficient info about .mtl and .obj. Can anyone direct me to a resource/thread/manual that explains how a BOD file is structured?

As an aside, I could also attempt to make a .bod to .dae converter, but COLLADA has a much larger feature set and is therefore more complex, so that might be a lot harder.

Many thanks!

TL;DR I'd like to know the specifications for BOD files so I can write a script to parse them and create an MTL file for the OBJ.
User avatar
Killjaeden
Posts: 5366
Joined: Sun, 3. Sep 06, 18:19
x3tc

Re: BOD file specifications for use with conversion script

Post by Killjaeden »

General Vash wrote: Thu, 24. Dec 20, 06:47 I'd like to know the specifications for BOD files so I can write a script to parse them and create an MTL file for the OBJ.
What do you want to know specifically? The material entries in the bod are what they are, there are no guides/documents describing what every value does. Thankfully most are self-descriptive. The texture paths are plain text, and the most relevant if you just want to see the texture in 3d editor. Since the textures are not PBR you cant just plug them into X4 anyway, therefore the other values are somewhat meaningless. Except maybe animated stuff.
The model faces have material ID - which corresponds to the number / order of the materials. In max you have one multimaterial and every entry is a submaterial. The models use the material-ID to set whatever the mat it is.
MATERIAL6: 40; 0x2000000; 1; argon.fx; 57; diffcompression;SPTYPE_BOOL;0; bumpcompression;SPTYPE_BOOL;0;
speccompression;SPTYPE_BOOL;0; lightcompression;SPTYPE_BOOL;0; nofiltering;SPTYPE_BOOL;0; autofree;SPTYPE_BOOL;0;
Tex2;SPTYPE_BOOL;0; TexAnimStartU;SPTYPE_FLOAT;0.000000;TexAnimStartV;SPTYPE_FLOAT;0.000000;TexAnimEndU;SPTYPE_FLOAT;0.000000;TexAnimEndV;SPTYPE_FLOAT;0.000000;TexAnimDuration;SPTYPE_FLOAT;9.000000;TexAnimRotation;SPTYPE_FLOAT;9.000000;TexAnimOriginU;SPTYPE_FLOAT;0.500000;TexAnimOriginV;SPTYPE_FLOAT;0.500000;
Brightness;SPTYPE_FLOAT;1.000000; contrast;SPTYPE_FLOAT;1.000000; saturation;SPTYPE_FLOAT;1.000000; hue;SPTYPE_FLOAT;0.000000; colormatrix;SPTYPE_BOOL;0; g_ColorWriteEnable;SPTYPE_LONG;15; g_Wrap;SPTYPE_LONG;0; g_CullMode;SPTYPE_LONG;2; g_AlphaBlendEnable;SPTYPE_LONG;0; g_BlendOp;SPTYPE_LONG;1; g_SrcBlend;SPTYPE_LONG;2; g_DestBlend;SPTYPE_LONG;1; g_ZEnable;SPTYPE_LONG;1; g_ZWriteEnable;SPTYPE_LONG;1; g_ALPHATESTENABLE;SPTYPE_LONG;0; g_LightAmbientIntensity;SPTYPE_FLOAT4;0.000000;0.000000;0.000000;0.000000; LightDir_Dir0;SPTYPE_LONG;0; LightDir_Color0;SPTYPE_FLOAT4;1.000000;1.000000;1.000000;0.000000; LightDir_Dir1;SPTYPE_LONG;0; LightDir_Color1;SPTYPE_FLOAT4;0.000000;0.000000;0.000000;0.000000; g_MatSpecularStrength;SPTYPE_FLOAT;1.000000; g_MatSpecularPower;SPTYPE_FLOAT;10.000000; g_MatReflectionStrength;SPTYPE_FLOAT;1.000000; g_MatReflectionBias;SPTYPE_FLOAT;1.000000; g_MatReflectionBlur;SPTYPE_FLOAT;0.000000;g_AlphaValue;SPTYPE_FLOAT;1.000000; g_MatEmissiveColor;SPTYPE_FLOAT4;0.000000;0.000000;0.000000;0.000000; t_FilterTypeDiffuse;SPTYPE_LONG;2; t_SamplerAddressMode;SPTYPE_LONG;1; t_SamplerMaxAnisotropy;SPTYPE_LONG;4; t_MipMapLODBias;SPTYPE_FLOAT;0.000000; t_DiffuseTexture;SPTYPE_STRING;dds\metal_argon_exhaust_trims_02_diff.dds; t_MinFilterTypeDiffuse;SPTYPE_LONG;3; g_MatDiffuseStrength;SPTYPE_FLOAT;1.000000; t_AlphaTexture;SPTYPE_STRING;NULL; t_BumpTexture;SPTYPE_STRING;dds\metal_argon_exhaust_trims_02_bump.dds; t_MinFilterTypeBump;SPTYPE_LONG;3; t_BumpMipMapLODBias;SPTYPE_FLOAT;0.000000; t_FilterTypeBump;SPTYPE_LONG;2; t_SpecularTexture;SPTYPE_STRING;dds\metal_argon_exhaust_trims_02_spec.dds; t_LightMapTexture;SPTYPE_STRING;dds\metal_argon_exhaust_trims_02_light.dds; t_CubeMapTexture;SPTYPE_STRING;DDS\envmap_test.dds;
[ external image ]
X-Tended TC Mod Team Veteran.
Modeller of X3AP Split Acinonyx, Split Drake, Argon Lotan, Teladi Tern. My current work:
Image
aurumgallente
Posts: 124
Joined: Sun, 14. Jun 20, 14:45
x4

Re: BOD file specifications for use with conversion script

Post by aurumgallente »

If you need only 1 model, I think you can use trial period of 3D Max to export whatever you need. DBOX2 works with latest versions of 3D Max but you need to resolve a couple of issues because .ini files of "new" generation of 3D Max products have different locations.
General Vash
Posts: 24
Joined: Thu, 30. Jan 20, 05:13
x4

Re: BOD file specifications for use with conversion script

Post by General Vash »

Well, the .mtl needs information about color + illumination, texture mapping, and reflection mapping. The example material line from a .bod that you gave me doesn't use labels for each field, so although I assume that the beginning:

"MATERIAL6: 40; 0x2000000; 1; argon.fx; 57; diffcompression;SPTYPE_BOOL;0; bumpcompression;SPTYPE_BOOL;0;
speccompression;SPTYPE_BOOL;0; lightcompression;SPTYPE_BOOL;0; nofiltering;SPTYPE_BOOL;0; autofree;SPTYPE_BOOL;0;" contains the info I need to know apart from filenames I can't grok it's meaning.

More technical details:
.mtl uses tags to specify info, and not all of them are required. The options are:

Color and Illumination
ka: ambient reflectivity
kd; diffuse reflectivity
ks: specular reflectivity
tf: transmission filter
illum: illumination model
d: specifies dissolve
Ns: specular exponent
sharpness: specifies sharpness value
ni: optical density

Texture Map
These parameters can affect ka, kd, ks, ns, and d.
Basically you can link texture and color files in this section, and they can be image files, or texture/color files of a specific file extension.

Reflection Map
This section specifies the shape and the texture file which is used to cast reflections onto the material.

source: http://paulbourke.net/dataformats/mtl/

From the gmax materials window I can see that they are using spheres for the reflectivity, and much of the color information is available in the summary, but I don't know how DBOX2 is interpreting the information from the .bod because I am not very good at understanding what Maxscript files are trying to say. Also, the materials defined in gmax are using a bunch of informaton labeled X3 properties which I assume are used in the game engine but not in gmax.

Edit: I know you probably can't just plug the textures into x4 as they are, but I'd like to be able to see what faces are associated with each texture in Blender so I can re-texture it more quickly.
General Vash
Posts: 24
Joined: Thu, 30. Jan 20, 05:13
x4

Re: BOD file specifications for use with conversion script

Post by General Vash »

aurumgallente wrote: Thu, 24. Dec 20, 14:20 If you need only 1 model, I think you can use trial period of 3D Max to export whatever you need. DBOX2 works with latest versions of 3D Max but you need to resolve a couple of issues because .ini files of "new" generation of 3D Max products have different locations.
I did consider various approaches to obtain 3ds max; I only graduated recently so I thought I might be able to finagle a student's license, unfortunately they check the student ID to catch cheapskates like myself. But the free trial will charge me more money than I actually have if I don't pay attention, which I am notrious for doing with other subscription-type things, and I didn't want to risk my life savings on a hobby project :lol:
Furthermore, it would be nice for the modding community at large if there was more support for free alternatives like Blender, and since that's what I'd like to see I thought I'd try to make a contribution.
General Vash
Posts: 24
Joined: Thu, 30. Jan 20, 05:13
x4

Re: BOD file specifications for use with conversion script

Post by General Vash »

I did a bit more digging and it seems weird to me that the file paths in the .bod file are pointing to directories from the developer's computer. For example, from paranid_m2.bod in MATERIAL6: 0;

Code: Select all

t_BumpTexture
SPTYPE_STRING
I:\Exomod\dds\metal_paranid_platesI_bump.dds
But my system doesn't have an I: drive letter, so I'm confused about how DBOX2 is grabbing that texture. I can see the material in gmax.
User avatar
Killjaeden
Posts: 5366
Joined: Sun, 3. Sep 06, 18:19
x3tc

Re: BOD file specifications for use with conversion script

Post by Killjaeden »

General Vash wrote: Thu, 24. Dec 20, 16:29 Color and Illumination
ka: ambient reflectivity
kd; diffuse reflectivity
ks: specular reflectivity
tf: transmission filter
illum: illumination model
d: specifies dissolve
Ns: specular exponent
sharpness: specifies sharpness value
ni: optical density

Reflection Map
This section specifies the shape and the texture file which is used to cast reflections onto the material.
You just want to see what the texture looks like in blender, or not? Then none of that matters, just use default values for everything... I mean you could try, but you would have to figure it out yourself. There is no documentaion. If you still want to bother getting that right - just read all the property variables. Ignore the ones that dont make sense, use the ones that do ... Thats what i would advise.
e.g.
g_MatSpecularPower;SPTYPE_FLOAT;10.000000;
g_MatReflectionStrength;SPTYPE_FLOAT;1.000000;
g_MatReflectionBlur;SPTYPE_FLOAT;0.000000;
is pretty self explanatory...

Finding out if something has alpha or selfillumination is also easy due to the paths.

Since you have to use different textures in X4 anyway, why bother getting the reflectivity, sharpness, of X3 material etc right? The texture paths are what matters. Those you can read very easily.
General Vash wrote: Thu, 24. Dec 20, 16:29 I did a bit more digging and it seems weird to me that the file paths in the .bod file are pointing to directories from the developer's computer.
No, wrong - propably caused by a wrong setup by the creator. And the file pather may simply ignore everything higher up than the first folder (dds), and uses data root folder set in dbox settings for the rest. Check the file paths of the material entry i pasted -> it only has "dds\"
[ external image ]
X-Tended TC Mod Team Veteran.
Modeller of X3AP Split Acinonyx, Split Drake, Argon Lotan, Teladi Tern. My current work:
Image
General Vash
Posts: 24
Joined: Thu, 30. Jan 20, 05:13
x4

Re: BOD file specifications for use with conversion script

Post by General Vash »

Okay, I can work with the file paths and use the same approach as DBOX2 then, ignoring everything before the 'dds' part of the path. Unfortunately that means the file structure has to be somewhat specific for the script to work, which always irritates me with other tools like the XRConverter that was giving me headaches yesterday.
I realized today that the obj generated by the Maxscript converter doesn't have any of the lines for the materials which should have been obvious now that I think about it. However, that means I'll probably have to cannibalize that script and make something that is independent from gmax.
In any case I'll write up a script as soon as I have the time and motivation, then link the github repository on the forums here when I have something to show.
aurumgallente
Posts: 124
Joined: Sun, 14. Jun 20, 14:45
x4

Re: BOD file specifications for use with conversion script

Post by aurumgallente »

If you can successfully import 3D model with textures to your software, you can export textures. When I load something from X2 to 3D max by using DBOX2, I get textured model. Then I export it as .dae file with "copy textures" option and max saves all used textures next to .dae file. And I don't use raw X2 textures, I have to edit them for proper looking in X4 - brightness, contrast, saturation, etc.
General Vash
Posts: 24
Joined: Thu, 30. Jan 20, 05:13
x4

Re: BOD file specifications for use with conversion script

Post by General Vash »

The problem with gmax is it has extremely limited import and export capabilities due to its intended usage with gamepacks that I don't have access to. So I can happily import the bod with its textures to gmax but I cannot export it except using a Maxscript script. And the OBJ export script was written years ago by someone that didn't include the associated MTL file for the textures. Unlike 3ds max, I cannot export in the COLLADA format, otherwise I could skip this entire process of writing a script to convert.
If someone knows of an export from gmax that includes textures, I would be eternally grateful if they could point me to a download for it; it would save me all this effort.
General Vash
Posts: 24
Joined: Thu, 30. Jan 20, 05:13
x4

Re: BOD file specifications for use with conversion script

Post by General Vash »

Okay, I want to thank everyone who has responded thus far. I have made some progress with the script: it writes an MTL file with default material definitions based on the BOD file. This should hopefully create and apply the materials to the faces in blender on import. It won't have the actual image files, but I can do all of that as long as I don't have to manually reapply the textures in paint mode, which I am trying to avoid because I am a terrible artist.

Now, the faces defined in the BOD file have the following form:
0; 126; 128; 127; -25; 1; -0.289200; 4.352310; -0.183258; 3.928345; -0.428162; 4.300888; /! N: { -0.224854; 0.964432; -0.138885; 0.573212; 0.765808; 0.291458; 0.314117; 0.945480; -0.085800; } !/ // 0

I am guessing the first value is the material ID, and I suppose N stands for normal, so it seems reasonable that there is a vertex, texture vertex, and a normal vector in this line somewhere. I am not expecting anyone to know since there is not any documentation but if there is any insight into what the values are for the faces that would be very helpful.
General Vash
Posts: 24
Joined: Thu, 30. Jan 20, 05:13
x4

Re: BOD file specifications for use with conversion script

Post by General Vash »

Okay, I decided not to reinvent the wheel and to let DBOX2 do the BOD stuff since I couldn't wrap my head around it. However, I still needed the material info, so I adapted the OBJ exporter for gmax to create a blank white material for each material in the scene, and I referenced those material numbers in the OBJ file so that when importing to Blender you end up with a number of different materials. Now they don't actually have the texture files, but I was already planning on applying new textures so that the appearance quality is closer to the ships of X4.
Here is the Maxscript that exports from gmax 12 to OBJ/MTL: https://drive.google.com/file/d/1PJemjs ... sp=sharing
To use just run script from the maxscript drop down in the utilities pane, the output will go to the listener window which can be grabbed using YAGG and saved to a file. I'll probably make a more in-depth tutorial thread once I have completed my work on the paranid m2 from x3.

Return to “X4: Foundations - Scripts and Modding”