Project Blender 2.63 + to Orbiter import/export addon

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
Hi everybody,

I've written an add-on for Blender 2.5 that imports / exports .msh files to / from Blender 2.5.
1 May, 2012. UPDATE! The current version of the add-on works only with Blender 2.63 or later with Bmesh (new powerful mesh system with Ngons).

Feel free to test and use this add-on, especially if you like Blender.
Bug reports are welcome.


The addon exports and imports geometry, UVs, materials and textures from/into Blender scene.



Import example: Atlantis from Orbiter in Blender.
picture.php



Export example: Sintel near a DGIV:
picture.php




Installation:
1. Download the latest Blender build
2. Download the archive from links below:
Old version for Blender 2.7x (Github) (.zip), or
Latest version (Blender 2.8, not done yet!) (.zip)
Latest version (Blender 2.8, not done yet , new link!) (.zip)



or you can download Git repository from git://github.com/vlad32768/blender-orbiter-io.git
3. Place io_orbiter_msh.py into Blender's addons directory
4. Enable module in File->User Preferences->Add-Ons dialog


Notes on .msh import:

1. You should import meshes from Orbiter installation. The module will autodedect Orbiter directory and load textures from Orbiter installation.
2. The script doesn't import vertex normals. It seems that Blender often recalculates vertex normals, so it's useless to import them.
3. If there is one material with different textures in .msh file, the script will create a copy of this material for every texture.
4. There are no ambient and emissive colors in Blender, so the script doesn't import ambient colors, but calculates emit component
5. Some models (for example DGIV and DG-XR) have got materials with shiny specular and zero hardness. That doesn't look good in blender.
You can use "Raise small hardness" parameter in file import dialog to set minimal hardness manually


Notes on .msh export

1. The script exports selected objects. To export the whole scene, select all objects by pressing "a".
1a. Blender has to be in object mode before exporting ( to avoid some Python API issues and, of course, to select mesh objects for export). If not, object mode will be set automatically during export.
2. Coordinate system: The script does conversion to left handed coordinate system, so there is the proper way to place your model in Blender when you start modeling:
-- Y axis is the direction of the main thruster's exhaust; -Y is the main thrust direction;
-- Z axis points UP;
-- X axis points LEFT.
3. Materials:
-- You should use Blender Internal renderer; don't use Cycles if you want to export your model to Blender;
-- The script exports only the first material of a mesh object;
-- The script makes Ambient color equal to Diffuse;
-- Emissive color is equal to Diffuse*emit
4. Textures
-- The script exports only the first texture of a material; this texture's type must be "IMAGE".
-- If you export your model to "file.msh", textures will be saved in "filetex" directory near the .msh file.
"file.msh" should be copied to Orbiter's "Meshes" directory, "filetex" directory -- to "Textures" (see TEXTURES section of .msh file)
-- Blender does not support writing .DDS files. In most cases the script will save .png files (check it).
So you have to convert textures to .dds manually. However, the script writes names with .dds extension in .msh TEXTURES section
 
Last edited:

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
I've just finished the export section of my script. Check the first message for information.

I haven't tested export thoroughly, just made a fast and simple Sintel export for demo screenshot. So bug reports are welcome.
 

statickid

CatDog from Deimos
Donator
Joined
Nov 23, 2008
Messages
1,683
Reaction score
4
Points
38
WOW this looks really cool! I've been trying to get a handle on the blender interface, it looks way better than anim8or. I'll have to try this out when I'm feeling more brave... :salute:
 

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
WOW this looks really cool! I've been trying to get a handle on the blender interface, it looks way better than anim8or. I'll have to try this out when I'm feeling more brave... :salute:

Yes, you should try. Blender 2.5 is much more user friendly than 2.4
 

Kendo

New member
Joined
Oct 16, 2007
Messages
589
Reaction score
1
Points
0
vlad32768, Well done on a very very useful script. Please bear in mind that 2.5 is Beta, so its very possible this script won,t work later on. This exports and imports which is brilliant. Also great to look at Orbiter msh and do some renders. I,m curious to what extent we can edit Orbiter meshes as we have never been able to before, could find some useful surprises. Once again a brilliant script.
 

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
vlad32768, Well done on a very very useful script. Please bear in mind that 2.5 is Beta, so its very possible this script won,t work later on. This exports and imports which is brilliant. Also great to look at Orbiter msh and do some renders. I,m curious to what extent we can edit Orbiter meshes as we have never been able to before, could find some useful surprises. Once again a brilliant script.
Thanks, Kendo.
I think that the API won't be changed dramatically: it's too difficult and unnecessary.
It took about a week to write this add-on (and learn python and Blender PyAPI, of course), so I suppose it will be easy for me or anyone else to fix the script, even if bmesh will be merged into trunk.
 
Last edited:

Kendo

New member
Joined
Oct 16, 2007
Messages
589
Reaction score
1
Points
0
One thing I have noticed is the difference in import/export MSH size. I imported a MSH file which is 8.8mb, then a straight export back again to MSH, and it is now 12.6mb. A sizable difference indeed. Can,t see any other problems yet though. I though I would point this out. Regards, Ken.
 

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
One thing I have noticed is the difference in import/export MSH size. I imported a MSH file which is 8.8mb, then a straight export back again to MSH, and it is now 12.6mb.
It's OK. The exporter just uses more digits in floating point numbers. You can see it in .msh file. As Orbiter reads these files well, I decided not to decrease number of digits. Also, the importer can create additional materials, this increases export file size a little.

Really interesting is if anyone can animate exported model properly in Orbiter.
For example, the re-exported DeltaGlider mesh animates badly, beacuse its source mesh has no labels, and the exporter writes the mesh groups in different order.
If a developer uses labels to access mesh groups, everything should be OK. It's interesting to test this.
 
Last edited:

Hielor

Defender of Truth
Donator
Beta Tester
Joined
May 30, 2008
Messages
5,580
Reaction score
2
Points
0
Really interesting is if anyone can animate exported model properly in Orbiter. The re-exported DeltaGlider mesh animates badly, beacuse its source mesh has no labels, and the exporter writes the mesh groups in different order. If a developer uses labels to access mesh groups, everything should be OK. It's interesting to test this.
I'm pretty sure the labels in the mesh group are just comments and don't show up to code--you need to make a header file that maps the names to the mesh group numbers so you can access them by number.
 

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
I'm pretty sure the labels in the mesh group are just comments and don't show up to code--you need to make a header file that maps the names to the mesh group numbers so you can access them by number.
So, the LABEL tag is only for meshc.exe which creates a header, and an addon developer should re-compile his addon with the new header if he adds some new objects into his model?
If that's true, everything should be ok with exported models' animation.
 

Hielor

Defender of Truth
Donator
Beta Tester
Joined
May 30, 2008
Messages
5,580
Reaction score
2
Points
0
So, the LABEL tag is only for meshc.exe which creates a header, and an addon developer should re-compile his addon with the new header if he adds some new objects into his model?
If that's true, everything should be ok with exported models' animation.
Only if the addon developer recompiles their addon with the new header. The situation you described (import a mesh, then re-export it and attempt to use it with the same vessel dll) requires mesh groups to be in the same order for it to work.
 

zipybug14

New member
Joined
Sep 25, 2010
Messages
6
Reaction score
0
Points
0
I have a problem

Whenever I try to import a mesh, I don't get any textures.
Blender 2.54.0
error messages:
TypeError: bpy_struct: item.attr = val: Material.specular_hardness expected an int type

Hope this helps out.
 

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
Whenever I try to import a mesh, I don't get any textures.
Blender 2.54.0
I' ve just tested some standard Orbiter meshes import (DG, Atlantis, Project Alpha ISS) and everything is OK with textures.

I started developing the plugin after 2.54 has been released, so the developers could make some changes in Blender API. I always compile&use the latest version of Blender (today version is 2.55.0 r32761)

You should download the latest builds from graphicall.org. Do it if you didn't.


TypeError: bpy_struct: item.attr = val: Material.specular_hardness expected an int type
Hm... Specular hardness is integer in all standard Orbiter meshes and in Blender. Maybe some exporter writes a float value, and the importer fails.

What mesh did you try to import? Is it some special mesh? I need this mesh with textures to debug.
 
Last edited:

zipybug14

New member
Joined
Sep 25, 2010
Messages
6
Reaction score
0
Points
0
What mesh did you try to import? Is it some special mesh? I need this mesh with textures to debug.

Several, atlantis, DGIV, DGXR-1, XR-2 payload objects, and SSBB41 parts. All same error. I will try reinstalling blender/plugin using latest version, will have results soon.

Edit:
I got it to work.
 
Last edited:

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
Some updates:

added "Apply Modifiers" feature. You can use "Apply Modifiers" checkbox to export meshes with applied modifiers; this checkbox is off by default

Fixed a matrix multiplication bug in export_msh
 

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
I made a small update due to API change in Blender 2.56.

The script works now in recent Blender 2.5 builds. Functionality is the same.
 

marooder86

Donator
Donator
Joined
Dec 1, 2010
Messages
188
Reaction score
3
Points
33
Location
London
You've just made my day (or night) mister:cheers:. I'm gonna try it right now:yes:.

Heh, looks like my excitation was premature cause I'm having a bit of a problem here. I've instaled the script but it doesn't show in add on window. I' ve checked if the python script is really placed in proper folder and it's there. Does anyone encounter simillar problem or it's just on my computer.
I'm using Blender 2.56a beta-windows32.
 
Last edited:

vlad32768

Member
Joined
Oct 11, 2010
Messages
78
Reaction score
0
Points
6
Heh, looks like my excitation was premature cause I'm having a bit of a problem here. I've instaled the script but it doesn't show in add on window. I' ve checked if the python script is really placed in proper folder and it's there. Does anyone encounter simillar problem or it's just on my computer.
I'm using Blender 2.56a beta-windows32.

You must download the latest build from graphicall.org.
2.56a beta release from Blender.org uses old API, so don't use it.

Later please write Blender revision number when you report a bug.
 
Last edited:

marooder86

Donator
Donator
Joined
Dec 1, 2010
Messages
188
Reaction score
3
Points
33
Location
London
You must download the latest build from graphicall.org.
2.56a beta release from Blender.org uses old API, so don't use it.
That helped thanks:thumbup:
But not every meshes load properly, there are some problems with XR2 and XR5 vessels, well at least a have them.
Here are pictures:
On this you can see error pop up window. I don't know but maybe this is because I loaded it not directly from Orbiter's directory.

And thats how it looks from the bottom. Seems like not entire mesh has been loaded

The Ravenstar is a complete mess

There were no problems with XR1 and other add ons meshes.

Revision number of Blender is: r43338
 
Last edited:

TSPenguin

The Seeker
Joined
Jan 27, 2008
Messages
4,075
Reaction score
4
Points
63
The XR2 mesh is encrypted. You can not modify it.
 
Top