Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Addon Development
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Addon Development Developers post news, updates, & discussions here about your projects in development.

Reply
 
Thread Tools
  #1  
Old
vlad32768 vlad32768 is offline
Orbinaut
Post Blender 2.63 + to Orbiter import/export addon
by vlad32768 10-11-2010, 05:34 PM

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.



Export example: Sintel near a DGIV:




Installation:
1. Download the latest Blender build from Graphicall.org
2. Download the archive from links below
http://gitorious.org/blender-orbiter...tarball/master (.tar.gz), or
https://github.com/vlad32768/blender...zipball/master (.zip)
or you can download Git repository from git://gitorious.org/blender-orbiter-io/blender-orbiter-io.git , or 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 by vlad32768; 09-05-2013 at 06:17 PM.
Reply With Quote
Views 140551 Comments 218
Total Comments 218

Comments

Old 10-14-2010, 11:24 PM   #2
vlad32768
Orbinaut
Default

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.
vlad32768 is offline   Reply With Quote
Old 10-15-2010, 12:42 AM   #3
statickid
CatDog from Deimos
 
statickid's Avatar
Default

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...
statickid is offline   Reply With Quote
Old 10-15-2010, 07:04 PM   #4
vlad32768
Orbinaut
Default

Quote:
Originally Posted by statickid View Post
 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...
Yes, you should try. Blender 2.5 is much more user friendly than 2.4
vlad32768 is offline   Reply With Quote
Old 10-15-2010, 10:06 PM   #5
Kendo
Orbinaut
 
Kendo's Avatar
Default

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.
Kendo is offline   Reply With Quote
Old 10-17-2010, 03:16 PM   #6
vlad32768
Orbinaut
Default

Quote:
Originally Posted by Kendo View Post
 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 by vlad32768; 10-18-2010 at 08:41 AM.
vlad32768 is offline   Reply With Quote
Old 10-18-2010, 08:05 PM   #7
Kendo
Orbinaut
 
Kendo's Avatar
Default

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.
Kendo is offline   Reply With Quote
Old 10-19-2010, 06:49 PM   #8
vlad32768
Orbinaut
Default

Quote:
Originally Posted by Kendo View Post
 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 by vlad32768; 10-19-2010 at 07:02 PM.
vlad32768 is offline   Reply With Quote
Thanked by:
Old 10-19-2010, 06:56 PM   #9
Hielor
Defender of Truth

Default

Quote:
Originally Posted by vlad32768 View Post
 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.
Hielor is offline   Reply With Quote
Old 10-19-2010, 07:30 PM   #10
vlad32768
Orbinaut
Default

Quote:
Originally Posted by Hielor View Post
 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.
vlad32768 is offline   Reply With Quote
Old 10-19-2010, 08:53 PM   #11
Hielor
Defender of Truth

Default

Quote:
Originally Posted by vlad32768 View Post
 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.
Hielor is offline   Reply With Quote
Old 10-29-2010, 02:58 AM   #12
zipybug14
Orbinaut
Default 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.
zipybug14 is offline   Reply With Quote
Old 10-29-2010, 11:34 AM   #13
vlad32768
Orbinaut
Default

Quote:
Originally Posted by zipybug14 View Post
 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.


Quote:
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 by vlad32768; 10-29-2010 at 11:42 AM.
vlad32768 is offline   Reply With Quote
Old 10-29-2010, 02:26 PM   #14
zipybug14
Orbinaut
Default

Quote:
Originally Posted by vlad32768 View Post
 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 by zipybug14; 10-29-2010 at 02:45 PM.
zipybug14 is offline   Reply With Quote
Old 11-20-2010, 12:45 PM   #15
vlad32768
Orbinaut
Default

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 is offline   Reply With Quote
Thanked by:
Reply

  Orbiter-Forum > Orbiter Addons > Addon Development


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 08:50 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2007 - 2017, Orbiter-Forum.com. All rights reserved.