Oolite Bulletins

For information and discussion about Oolite.
It is currently Mon Dec 11, 2017 9:43 am

All times are UTC




Post new topic  Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Tue Jul 17, 2012 1:47 pm 
Offline
Grand Admiral Emeritus
Grand Admiral Emeritus
User avatar

Joined: Sat Apr 02, 2005 2:43 pm
Posts: 6657
Location: Sweden
The original thread’s head is badly out of date. Rather than rewrite aegidian’s post, I’ve started a new thread.

We provide a set of Python scripts to convert models to and from Oolite’s DAT format. The latest versions can always be found in the repository and downloaded directly using this link. Updates will be announced in this thread.

The tools are:

Obj2DatTexNorm.py: convert a mesh in OBJ format to DAT, preserving texture coordinates and vertex normals. This is now the recommended conversion tool. The meshes it produces require Oolite test release 1.74 or later.

From a Wings3D modelling perspective, preserving vertex normals means that hard and soft edges in Wings3D are preserved, producing a result similar to Wings3D preview mode (Tab key) if all the faces in Wings3D are planar (ensure this by selecting Tesselate → Triangulate in face mode). The smooth key in shipdata.plist has no effect on models with vertex normals.

Usage: python Obj2DatTexNorm.py <filename> for default settings, python Obj2DatTexNorm.py --help for information about options.


Obj2DatTex.py: an older conversion tool which does not preserve normals but does support smooth groups. Models converted with this tool will have a faceted look by default, but can be smoothed using the smooth key in shipdata.plist.

From a Wings3D modelling perspective, complete loops of hard edges will be preserved when using smoothing (the enclosed faces form a smooth group), but lighting may behave differently than in Wings3D preview mode.

Usage: python Obj2DatTex.py <filename>


Dat2ObjTex.py and Dat2Obj.py: partially convert a DAT mesh to OBJ format. Dat2ObjTex.py can handle a single material, while Dat2Obj.py ignores all textures. These tools do not preserve normals, and Dat2ObjTex.py won’t do anything useful with materials from files converted with Obj2DatTexNorm.py unless --pretty-output was used.

Usage: python Dat2ObjTex.py <filename>, python Dat2Obj.py <filename>


DatScale.py: scale a DAT model uniformly on all axes.

Usage: python DatScale.py <filename> <scalefactor>, e.g. python DatScale.py myModel.dat 3. A new file is created, in the example case “myModel x 3.0.dat”.


Mesh2Dat.py, Mesh2DatTex.py, Dat2Mesh.py, Mesh2Obj.py: converters for the obsolete, Mac-specific Meshwork modeller.


The converters require Python (version 2.7 or later for Obj2DatTexNorm.py). Mac OS X and Linux systems generally have Python preinstalled. For Linux systems, check your package manager if necessary. For Windows, download it from python.org.


Bug reports: currently, Obj2DatTexNorm.py is the only one that can be considered actively maintained, and the others have known problems. Crash/exception reports for all tools are welcomed, as well as reports of bad conversions with Obj2DatTexNorm.py. In order for reports to be useful, please ensure that they apply to the latest version – the link at the top of this post is always up-to-date – and include, at minimum, a copy of the file you’re trying to convert (and its associated MTL file in the case of OBJ files).

_________________
E-mail: jens@oolite.org


Top
   
PostPosted: Sun May 12, 2013 12:24 pm 
Offline
Grand Admiral Emeritus
Grand Admiral Emeritus
User avatar

Joined: Sat Apr 02, 2005 2:43 pm
Posts: 6657
Location: Sweden
Please note that the download link has been changed.

_________________
E-mail: jens@oolite.org


Top
   
PostPosted: Sat Nov 26, 2016 8:25 pm 
Offline
Poor
Poor

Joined: Wed Nov 23, 2016 9:24 pm
Posts: 7
Hi, i'm trying to learn some of the designing habilities.

I try to use the ...Norm.py and i get this:
Code:
$ python Obj2DatTexNorm.py mamba_redux.dat 
  File "Obj2DatTexNorm.py", line 232
    want this.'''
                ^
SyntaxError: invalid syntax
I try to open models from the game to see how they look in the wings3d.

_________________
bit coder :o
bit gamer :o

Thou shall not pass.


Top
   
PostPosted: Sat Nov 26, 2016 8:57 pm 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral

Joined: Wed Feb 28, 2007 7:54 am
Posts: 5023
Obj2DatTexNorm.py takes a model .obj file as input, but you seem to be giving it a .dat file. This will not work. You will need the mamba obj file (as well as its associated .mtl file) in the folder where Obj2DatTexNorm.py is run from, then you can run the utility to convert the .obj file to the .dat format that the game uses.


Top
   
PostPosted: Sun Nov 27, 2016 1:01 am 
Offline
Poor
Poor

Joined: Wed Nov 23, 2016 9:24 pm
Posts: 7
Oh, I see, :oops: how embarassing.

I think there is some syntax problem due to diferences between python 2.6 and 3.

_________________
bit coder :o
bit gamer :o

Thou shall not pass.


Top
   
PostPosted: Sun Nov 27, 2016 12:47 pm 
Offline
Poor
Poor

Joined: Wed Nov 23, 2016 9:24 pm
Posts: 7
Well,
I've been researching the issues with this tools,
May I volunteer myself to fix the python compatibility.

I wish to play with the models and I don't see other converters (and in the future python 2.6 would be a bit problematic).

I'm not an expert but I make my own little python scripts for personal purposes.

I'm starting on my own but I would apreciate some advice.

_________________
bit coder :o
bit gamer :o

Thou shall not pass.


Top
   
PostPosted: Sun Nov 27, 2016 3:03 pm 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral

Joined: Wed Feb 28, 2007 7:54 am
Posts: 5023
Feel free to experiment with it, although I'd prefer if we also keep the compatibility with Python 2.7 (2.7 is the minimum requirement as per the readme of the oolite-mesh-converters repo and not 2.6).

If you do go ahead and hack it, be aware that I've just pushed a new version of the converter on github:
https://github.com/OoliteProject/oolite ... TexNorm.py. This one contains some tangent space fixes commited by kanthoney prior to 1.84 and is considered the most up to date version of Obj2DatTexNorm.py.


Top
   
PostPosted: Sun Nov 27, 2016 5:10 pm 
Offline
Poor
Poor

Joined: Wed Nov 23, 2016 9:24 pm
Posts: 7
It's nice,

I'm learning how the dats and objs formats stores the positions and information.

Languaje needed only to make some print correction, also the string.split usage and also one collection check ( thing in collection.keys() instead of collection.has_key().

I'll check the 2.7 compatibility.

I have an error in how var vt1 is defined. It happens to not define it.
Code:
$ python prueba.py mamba_redux.obj
mamba_redux.obj -> mamba_redux.dat
  Material library file: mamba_redux.mtl
  Material mamba_redux_auv -> mamba_redux.png
Traceback (most recent call last):
  File "prueba.py", line 496, in <module>
    rv1 = resolve_vertex(vertex[v1], normal[vn1], tc1, index_for_vert_norm_and_tex, vertex_lines_out, normals_lines_out)
NameError: name 'vn1' is not defined
# UPDATED with an ingame model.
# Transformed the dat to obj with my corrected version of Dat2ObjTex.py and then tried to convert it back.

_________________
bit coder :o
bit gamer :o

Thou shall not pass.


Top
   
PostPosted: Sun Jan 29, 2017 3:31 pm 
Offline
Competent
Competent

Joined: Wed Jan 18, 2017 2:01 pm
Posts: 60
May i ask if there are any py scripts that work in the current version of Blender? or how exactly you can use these conversion scripts? What directory structure is recommended? should they be installed in the Python folder? or should they be installed in the same directory as say an existing Oolite model? The instructions are rather vague and imply that the user already knows how to use them, and what directory they need to be in.

I use blender exclusively since 3ds max is not an option in Linux. I would like to be able to import some existing older models and possibly update some of the ships to Griff's standards. I am also working on a test ship (new design) that i would like to add to the game at some point.


Top
   
PostPosted: Sun Jan 29, 2017 7:29 pm 
Offline
Deadly
Deadly

Joined: Sat Aug 09, 2014 4:16 pm
Posts: 176
As I've been mentioning somewhere else in the forum, I had some work done on Dat2Obj.py and Dat2ObjTex.py. These are two of the conversion scripts provided by the dev team here, but updated for cooperating with the newer .dat files.
The resulted .obj files can be used with Blender, but some minor manual material/UV tweaking needs to be done for the textures (the scripts don't support multitexturing, mainly).
They are not supposed to be used from within Blender, but at the command line, as they require Python v2.x (they don't work with Python v3.x bundled with Blender _and_ they are not Blender add-ons).
Hope this helps.


Top
   
PostPosted: Sun Jan 29, 2017 7:52 pm 
Offline
Deadly
Deadly
User avatar

Joined: Sat Jan 25, 2014 2:35 am
Posts: 189
Location: floating the Blackfoot
Quote:
May i ask if there are any py scripts that work in the current version of Blender? or how exactly you can use these conversion scripts? What directory structure is recommended? should they be installed in the Python folder? or should they be installed in the same directory as say an existing Oolite model?
You may want to check out this thread for Blender tips: http://aegidian.org/bb/viewtopic.php?f= ... 45#p152965

Export your model as a Wavefront .obj into the same directory that the conversion script is in then navigate to that directory in a terminal and enter: python Obj2DatTexNorm.py yourexample.obj

In my experience the only thing that matters with regard to directory structure is that both the obj and associated .mtl file are in the same directory as the conversion script. I just leave the scripts in the oolite-mesh-converters-master dir that they come in and export my .obj files there. Once converted I move the .dat file to the Model directory in the oxp directory it belongs to and move the .obj and .mtl files to a subdirectory that I created within the oolite-mesh-converters-master for backups.
Quote:
I am also working on a test ship (new design) that i would like to add to the game at some point.
I saw your pic in the other thread, looks very nice.

_________________
Realize collective conscious creation


Top
   
PostPosted: Mon Jan 30, 2017 12:33 am 
Offline
Competent
Competent

Joined: Wed Jan 18, 2017 2:01 pm
Posts: 60
Thanks for the tips, and thanks for the compliment. I will give that method a try and see what i can do.

From what I understand about python, i do have 2.7 and 3.x in my OS natively, but have to research more so I can refresh on how to use older python versions. I think that a simple command using pip or another package can allow switching temporarily to a different python environment so that should not be too difficult once I get the other python versions I use installed, the hard part is getting them to behave correctly and making sure all the directory structures are in the right places to make that possible. Since I already have older versions installed on my old partition, I may be able to just cut and paste those into the correct locations to install them, but I'm not sure.


Top
   
PostPosted: Mon Jan 30, 2017 6:23 am 
Offline
Deadly
Deadly

Joined: Sat Aug 09, 2014 4:16 pm
Posts: 176
Quote:
From what I understand about python, i do have 2.7 and 3.x in my OS natively, but have to research more so I can refresh on how to use older python versions.
No pip needed. Usually your "default" python would be either 2x or 3x, you can quickly find it out by typing
Code:
python --version
in a terminal. The nice part is that each version will also have an executable named python2 for 2x or python3 for 3x (the default python is just a symbolic link to one of these).
Thus, if you wanted to use python version 2.x for the python scripts provided by Oolite, you can just keep using python2 when running them, e.g.
Code:
python2 Dat2Obj.py cobra3_redux.dat
Of course you can always modify the "#!" line in your python scripts to call either python2 or python3 -- but that's more intrusive than just calling the needed interpreter when you want to run a script.


Top
   
PostPosted: Tue Jan 31, 2017 4:07 pm 
Offline
Competent
Competent

Joined: Wed Jan 18, 2017 2:01 pm
Posts: 60
Scripts work ok, i downloaded another version of them as well for stubborn ship models that do not want to convert (error out) but so far they seem to work ok for the most part.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited