Hi vlad32768,
I downloaded your addon some weeks ago and I must say it's great, it's fast and it works in blender 2.63, which gave me the push to migrate to the new blender. I feared the trouble of converting the old orbiter-mesh import/export addon, but then stumbled upon this one. You have done all the hard work. Thanks.
I've done some modifications and resolved some issues, but first one question. Why don't you publish your addon in Orbit Hangar Mods under Utilities, Dev tools? It's a must have for everyone using Blender to model for Orbiter.
In this mail are 2 zip files, one for the io_orbiter_msh.py and one for exporting images as DDS. Try them out. The last one is adapted by me to export texture images of selected objects which solves the problem of saving images as .png files, which is not very satisfactory for people who don't want to bother. And it's convenient for making a publishable addon fast. Though I prefer to work with a photo editor like the Gimp or Photoshop (no advertising, sorry) making textures and export from there as .dds. But as this dds plugin uses nvidia_dds.exe whith lots of options, I gave up my restraints.
The changes, lot's of them, not ment as criticism, some important, some nice to have, some just a matter of taste. Just tested it with blender 2.63a, rel.46487M in Windows 7 64 bit.
1. Images in import: in your addon I had to link them by hand to the objects, edit mode, in the UV editor. I don't know if this is just some weird windows behaviour. Anyway I linked the image in the py script to the objects. It means first loading all the textures in .msh file before creating the mesh. Major change, separated the create_texture from create_material. Images are save in tximg list, then create_mesh with image linked for all groups, then create_materials.
2. Orphans, i.e. loose vertices in export: solved, but it is not necessary to delete them, because,
3. Generating the vertices from the faces there are no orphans in the export. This approach is used for using face normals in case of exporting objects as flatshaded. Once in a while, very rarely, f.i. exporting bolts and screws, used, but Orbiter is capable of showing flat shading.
So I made an option Smooth all, default True, your solution, using vertex normals for exporting all objects set smooth and False for only set smooth selected faces or objects. It creates more double vertices, (vertex, normal pairs for every face an vertex belongs to). See commentary in script. Major change.
4.Labels in import: some old orbiter .msh files have the names as commentary in GEOM section after emicolon. for compatibility reasons changed.
5. Texture names in import, changed to image filenames without extension. Mini change.
6. Missing textures at end of .msh file in import trying to read past end of file. Solution break in for, stop appending textures.
7. Added timer in import, export. Nice to have. Fast, fast fast. If not, maybe forgotten to delete mesh before importing a new one and exporting all of them at once.
8. Formatted the output, Blender rounds off after 4 decimals, material colors 3. Imperceptible. Smaller .msh files, easier to check. Taste, I think.
9. In export: extension must be .msh. Users do the most crazy things, or when you are in a hurry. Could even say, no dots except before the extension, but let it be, this is adequate enough.
10. In export: now that the dds problem is solved changed the save_images as .png to: copy them from source to filetex directory, except the one's not on disk, save those as .png's'.
11. Last one, definitely of taste and maybe inconvenient for those accustomed to work with your addon.
Coordinate sytems. Lot's of confusion on the internet. Even Martin is not clear about it: Quote from OrbiterConfig.pdf, pg 29, 4 Mesh files:
"Orbiter meshes are defined in a left-handed coordinate system. Vessel meshes should be oriented such that the vessel’s nose (or more precisely, its main thrust direction) points in the positive z-direction, the positive x-axis points right, and the positive y-axis points up."
And the pos. z-direction?. In lhc-system it points away from the user. Ok.
For your addon it means only swapping the y, z axes. Rotating 180 degr's the new x, y round the new z-axis is not necessary. In blender (rhc-system) the rocket stands up in the xy plane. Simply use numpad 7 and what you see in Blender is what you see in Orbiter (using convert_coords).
I could say something more about the qoute and coordinate systems in general but it has nothing to do with your addon. maybe in another thread.
So, this is it. A long story, but I liked working on this addon, and in the meantime learned python 3.2 and found my way in blender python api.
I hope you can use some of thes suggestions.