textures in .dat-files / blender

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

Post Reply
User avatar
tsoj
Deadly
Deadly
Posts: 199
Joined: Wed May 18, 2016 8:19 pm
Location: Berlin
Contact:

textures in .dat-files / blender

Post by tsoj »

Hello,
im still working on my first oxp-ship. I want to add lights and i made a texture for this but i dont know, how to save multiple textures in one .dat-model. Im using blender and i tried to open additional to the normal texture the light-texture or to create a new picture but when i try to convert the .obj+.mtl-files with "Obj2DatTex.py" to a .dat-file it shows me only the message:

Code: Select all

['tsoj_Boomslang-mkIII.obj']
tsoj_Boomslang-mkIII.obj->tsoj_boomslang-mkiii.dat
going to open material library file: tsoj_Boomslang-mkIII.mtl
[b]Material Material -> C:\Users\tsoj\Documents\Ships\tsoj_Boomslang-mkIII.png[/b]
done

In my shipdata.plist file i have:

Code: Select all

materials =
		{
			"Hull" =
			{
				diffuse_map = "tsoj_Boomslang-mkIII.png"; 
				specular_color = (0.2, 0.2, 0.2);
				shininess = 5;
				emission_map = "tsoj_Boomslang-mkIII-lights.png";
			};
		};
And in Oolite there is only shown the normal texture (tsoj_Boomslang-mkIII.png) and not for lights (tsoj_Boomslang-mkIII-lights.png).

Im thinking, that the problem is, that i dont know how to integrate multiple texures in one .dat-file. Who knows how to do this with blender?
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6547
Joined: Wed Feb 28, 2007 7:54 am

Re: textures in .dat-files / blender

Post by another_commander »

I am not sure that Obj2DatTex is supported anymore. Try this one instead: https://github.com/OoliteProject/oolite ... TexNorm.py

From the readme of the repository where this gets downloaded from:
Obj2DatTexNorm.py: convert a mesh in OBJ format to DAT, preserving texture coordinates and vertex normals. This is now the recommended conversion tool.
and
currently, Obj2DatTexNorm.py is the only one that can be considered actively maintained, and the others have known problems.
Not sure how much it will help with the specific issue you are dealing with, but it may be worth a try.
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: textures in .dat-files / blender

Post by Norby »

Which line is in the generated .dat file?
// materials used: ['Hull']
or
// textures used: ['tsoj_Boomslang-mkIII.png']
?
In the second case you should use "tsoj_Boomslang-mkIII.png" instead of "Hull" in shipdata.plist.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: textures in .dat-files / blender

Post by Smivs »

The .dat file contains the model, and the name of the texture to be applied to it, but not the actual textures themselves. You will need both textures in your 'Textures' folder, the 'main' texture (tsoj_Boomslang-mkIII.png) and the emission_map (tsoj_Boomslang-mkIII-lights.png). Then you should See the Light!
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
tsoj
Deadly
Deadly
Posts: 199
Joined: Wed May 18, 2016 8:19 pm
Location: Berlin
Contact:

Re: textures in .dat-files / blender

Post by tsoj »

Yes, now it works, but only if i write the whole address ( C:\\blabla\\...\\Addons\\...) instead of "Hull" or "tsoj_Boomslang-mkIII.pn" from the original textureimage, because for any reason blender saved that like this.:P
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: textures in .dat-files / blender

Post by Smivs »

Well, that's not right at all (and probably shouldn't even work!).
Just to check, you have a.dat file (named 'tsoj_Boomslang-mkIII.dat' I assume) in the OXP Models folder, and two images ('tsoj_Boomslang-mkIII.png' and tsoj_Boomslang-mkIII-lights.png) in the Textures folder.
The .dat file should look like this (shortened) example. Obviously the numbers will be different in yours.

Code: Select all

// output from Obj2DatTex.py Wavefront text file conversion script
// (c) 2005 By Giles Williams
<snip>
// textures used: ['tsoj_Boomslang-mkIII.png']
// 
NVERTS 39
NFACES 74

VERTEX
-15.00000, 7.35434, 1.53292
0.00000, -5.14569, 51.53292
15.00000, 7.35434, 1.53292

<snip> 

FACES
1,0,0,	-0.49348,0.81077,0.31485,	3,	0,13,8
1,0,0,	-0.84386,0.46557,-0.26674,	3,	0,32,5
1,0,0,	-0.16725,0.92393,0.34407,	3,	1,13,12

<snip>

TEXTURES
tsoj_Boomslang-mkIII.png	1.0 1.0	0.64775 0.28487	0.58938 0.34784	0.61620 0.43656
tsoj_Boomslang-mkIII.png	1.0 1.0	0.66175 0.72138	0.68103 0.76493	0.86708 0.73391
<snip>
tsoj_Boomslang-mkIII.png	1.0 1.0	0.53457 0.95724	0.53268 0.94591	0.44404 0.94096
tsoj_Boomslang-mkIII.png	1.0 1.0	0.53268 0.94591	0.50732 0.91571	0.44404 0.94096

END
and specifies the base texture, which is then applied from the .png image file in the Textures folder. This should work without a 'Materials' section in the shipdata.plist. The shipdata.plist 'materials' section then also adds the emission map etc.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: textures in .dat-files / blender

Post by Norby »

tsoj wrote:
Yes, now it works, but only if i write the whole address ( C:\\blabla\\...\\Addons\\...) instead of "Hull" or "tsoj_Boomslang-mkIII.pn" from the original textureimage, because for any reason blender saved that like this.:P
I usually replace the filename in .dat to something like oxpname-shipname.png, then I rename the image also and move into Textures subfolder. You also sould be able to remove the path and keep the file name only.
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: textures in .dat-files / blender

Post by Svengali »

another_commander wrote:
I am not sure that Obj2DatTex is supported anymore. Try this one instead: https://github.com/OoliteProject/oolite ... TexNorm.py
Is it possible to get a script to convert back too?
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 664
Joined: Sat Aug 09, 2014 4:16 pm

Re: textures in .dat-files / blender

Post by Commander_X »

Svengali wrote:
Is it possible to get a script to convert back too?
Sure, I used these (Dat2Obj_local.py and Dat2ObjTex_local.py) for a conversion of the 1.82 ships, that looks like this in Blender:Image
*Note that there are some extra artifacts on some of the ships due to the distance they are presented from in the viewport. Also, the changes in the scripts might not be the best suited for a software audit :oops:
Last edited by Commander_X on Sat Feb 25, 2017 1:55 am, edited 1 time in total.
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: textures in .dat-files / blender

Post by Svengali »

Commander_X wrote:
Svengali wrote:
Is it possible to get a script to convert back too?
Sure, I used these (Dat2Obj_local.py and Dat2ObjTex_local.py)
Pretty - muchas gracias. Time to update/add them on Github?
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 664
Joined: Sat Aug 09, 2014 4:16 pm

Re: textures in .dat-files / blender

Post by Commander_X »

Svengali wrote:
Pretty - muchas gracias. Time to update/add them on Github?
Por nada! I'd defer the Github suggestion to more active/involved developers.
Some facts. The changes in the scripts were some quick tweaks done around 1.82 release. The multi-texture "adaptation" involves some manual steps in the 3D software (quite trivial in Blender's case, considering the UV mappings are preserved). Plus I never tried the obvious simple tests of running the Obj2Dat*.py, followed by Dat2Obj*.py against the resulted .dat files, and see if the .obj files still map correctly.
Post Reply