Well, for now, I'm very happy to present to you what I've done so far:
A first working version of the YASim import script, ported for Blender 2.63 ! Of course you are free to use the code (with respect to the GPL) for your projects. I'm not a professional programmer, so it might be somehow unprofessional... (The code is heavily commented.)
Edit: See http://wiki.flightgear.org/Blender_YASim_import for an up to date reference.InstallationDownload:
http://cem.square7.ch/simple_yasim_import.pyInstall it as blender addon:Download the script from the above link and save it under ~/.blender/2.63/scripts/addons/ (for linux).
Start blender and go to File > User Preferences... > Addons.
Type in "yasim" in the search box or go to Import-Export. Click the checkbox right to the YASim addon, to enable it.
(To make it persistent you have to click "Save As Default". Take care that you have a clean startup file opened, when doing this, or you might mess up your default start file !)
Script usage:Alternatively you can load the script in the Blender text editor and click "Run Script". (An advantage of this method is that you can easily rerun the script if you experience problems.)
UsageAn instance called "YASim XML Importer" should appear at the bottom of the User Interface Panel. This is the panel that get's called by pressing "n" in the viewport. (See image below.)
Usage is pretty much self-explanatory. However some words:
When
loading the "Pivot center for rotation/scaling" should
not be set to "3D Cursor", or your cockpit, tanks, ballasts will get messed up. I'd suggest "Median Point" but I think any other works. (Sadly this is hardly controllable by a script, AFAIK.)
The
mirror setting is intended to be used when the XML is already loaded.
When loading or reloading, it is resetted to One-sided, at the moment. When enabling the mirror, the object centers of the affected items are set to the blender origin. This is the same as in the original script and is necessary to use the mirror modifier. However, when disabling the mirror the object centers are restored !
The
clear button simply deletes all items named YASim_* in the current context ! When
reloading the clear function get's executed first, then the last opened file is reimported !
Generally, I did not take any measures to keep the importer settings when saving a .blend file or over multiple blender sessions. This may cause problems like crashes or other unexpected behaviour. I don't think that it's necessary, cause you can simply reload the xml very quickly/easily.
Example workflow:I'd suggest using different layers. The script does not make use of layers, so this is up to you.
0.) Delete the default cube, lamp and camera.
1.) Open your "real" aircraft model and save it as a "compare" model. Move the aircraft to layer two. Remove unneccessary objects. Reorient it that it matches the FDM coordinate system. Make it transparent or display it as wireframe, for example.
2.) Go to layer one and load the YASim FDM XML.
3.) Now you can enable both layers and comfortably compare them.
Testing:Tested with and made for Blender 2.63 r49356 on linux.
(The Blender API is still in development so maybe other versions are not compatible. I'll try to keep up with the changes.)
FDM's used for testing:
ask13.xml
bo105.xml
dhc6.xml
f-14b-yasim.xml
Mirage_F1-yasim.xml
U-2S-yasim-test.xml
vmx22.xml
Most important changes / know issues / questions / discussion:Interaction:- There is no menu entry under Import-Export for now. Instead an instance with control elements is created in the User Interface Panel. (This is the panel that get's called by pressing "n" in the viewport.)
- Imported items are locked by default, to prevent accidental transformations (location, rotation, scale).
- There is no elaborate error checking or logging by now. The built-in python/blender error system is used.
Coordinate System:- Introducing a custom coordinate system, in the form of <!-- offsets: x=3.45 z=-0.4 p=5 --> is no longer supported. The script will simply display everything exactly as it's defined in the XML, using the blender internal coordinate system ! If your "real" aircraft model uses a different coordinate system, and you want to compare it to the imported YASim FDM model, you'll have to reorient your aircraft model, so that it correctly matches the FDM coordinate system !
(I didn't implement this because, when I started it seemed to complicated to me. I think it's not hard to reorient the "real" model in blender, once done it can be saved and reused as a "compare model" for example.)
Display:- YASim item names are shown by default in the viewport. (Controllable by a checkbox.)
- Every item get's a material assigned. Materials are reused !
XML Elements:- The <dir> element is not supported for now.
- Propeller: The propeller is always vertical and it's thrust vector always points along the x-Axis.
If someone thinks this should be somehow different, please tell !
- Rotor: With the rotor element I have some problems. Especially with the vectors that are created. As I'm not a helicopter designer, I never used this yet. I tried to do exactly the same thing that the original script does, but I'm not 100% sure about it. And I noticed some inconsistencies. For example: The bo105 main rotor looks ok to me:
But the tail rotor looks a bit strange:
And for the vmx22 one vector points upwards, that seems to be wrong to me !
Maybe if the heli designers could tell me what vectors would be useful to display and how they are defined in the xml file, I could rework that ! That would be great, also because I didn't find a docu about it. Anyways I think I'll rework it...
The other elements should be the same as with the original script !
Nice to have / ToDo- A good error checking would be nice. Maybe even one that checks if the XML is correct.
- Displaying more info's of the elements like ballast/tank masses, geometry info etc.
Just had the ambitioned idea to: Even make these interactive/editable, make it exportable (!) Even an FDM creation suite could be created this way... that might not even be too hard
Hehe, I'll do that... That goes into the direction of what the PAF team is doing for JSBSim I think.
- Suggestions ?
Last but not least: Don't rely blindly on this script. It can contain errors. If you think you found one please report it here !
Feedback, experiences, comments and suggestions are welcome.
Puh, that was a huge post, sorry bout that. I did it that way, to, hopefully, use it for the wiki after some time.
Regards
rebootl
Edit: Added: (with respect to the GPL)