Board index FlightGear Development Aircraft

YASim Importer for Blender 2.6 - Reboot, released

Questions and discussion about creating aircraft. Flight dynamics, 3d models, cockpits, systems, animation, textures.

YASim Importer for Blender 2.6 - Reboot, released

Postby rebootl » Mon Aug 13, 2012 7:46 pm

Hello

To further improve my programming skills and because I think it's very useful, I've decided to try to port the YASim import script (by mfranz) to blender 2.6 ! (And because I wasn't able to get the old blender version working here...)

This is only an informative post, I haven't anything finished yet. I guess nobody is working on this at the moment ?

Due to the major overhaul in blender mostly everything needs to be rewritten. But I'm keeping the structure. Probably I will simplify some things cause they seem too complicated for me, especially some calculations.

Regards

Edit: Title added blender version number 2.6 + released
Last edited by rebootl on Fri Aug 31, 2012 7:58 pm, edited 2 times in total.
rebootl
 
Posts: 111
Joined: Tue May 03, 2011 2:55 pm
Location: Switzerland
OS: Arch Linux

Re: YASim Importer for Blender - Reboot

Postby mr_no » Mon Aug 13, 2012 8:23 pm

I guess nobody is working on this at the moment ?

No.
You'll need to parse xml files.
Mosquito-XE JT-5B-autogyro Extra-300s STOL-Ch701
User avatar
mr_no
 
Posts: 360
Joined: Thu Jan 19, 2012 2:20 pm

Re: YASim Importer for Blender - Reboot

Postby rebootl » Mon Aug 13, 2012 9:53 pm

Hello mr_no.
Thanks for your reply.

Yes, the parser is already working, I use the same as mfranz, it's sax. It's included in the blender python version.
Further I have the items cockpit, tanks, ballast and weight working. Of course these are the easy one's, their just primitive objects added at their location and then scaled down. The harder one's come now, gear, wing etc..

My idea is to use a "static" coordinate system, so it will simply create everything exactly as it's described in the xml. So an offset specification for the imorter is not possible. But therefor I could avoid those matrix transformations that get a little bit over my head. Otherwise the results should then be more or less the same as with the original script.

And blender just crashed.. :?
rebootl
 
Posts: 111
Joined: Tue May 03, 2011 2:55 pm
Location: Switzerland
OS: Arch Linux

Re: YASim Importer for Blender - Reboot

Postby jonbourg » Thu Aug 23, 2012 5:35 pm

Hey while you are at it how about doing something similar for JSBSIM?

I was working on a plane the other day and I thought to myself (it only hurt a little bit) "wouldn't it be nice if I could see some of this stuff superimposed on the model like what is done with YASIM"? It would be really cool to graphically verify some of the settings (eyepoint, fuel tank positions, structure points, tail arm length, CG) stuff like that. It wouldn't be so much to verify the structure like YASIM does but it would definitely be a good tool for JSBSIM FDM designers.

Maybe make it so you would have the same structure XML as YASIM (a separate file with just the required xml to "see" the plane) or use the 3D model itself and make it Transparent?

What do you think? :D
jonbourg
 
Posts: 328
Joined: Tue Mar 11, 2008 12:43 am
Location: Omaha, NE
Callsign: BU2B
OS: Windows8

Re: YASim Importer for Blender - Reboot

Postby rebootl » Mon Aug 27, 2012 7:01 pm

Hi jonbourg
Just saw your post by now. Generally, I think it's a good idea. As I haven't used JSBSim till now, I don't know what xml elements are used there. As for "simple" elements like eye point, fuel tanks etc. I think it would be easy to do, by adapting the parser section in the code (This is where the xml get's read.). Anyways I think it should be a separate script. This you ment by ?
Maybe make it so you would have the same structure XML as YASIM (a separate file with just the required xml to "see" the plane) or use the 3D model itself and make it Transparent?


To insert the "real" 3-D model of the aircraft, and, if neccessary, reorient it in a way that it can be compared to the FDM (imported model), is not done by the script. This has to be done manually.

I'll give an explanation when releasing the script.

As for now I think I'll finish this one first, cause it's almost done. I think I'll upload a first version within the next days!
Regards
rebootl
 
Posts: 111
Joined: Tue May 03, 2011 2:55 pm
Location: Switzerland
OS: Arch Linux

Re: YASim Importer for Blender - Reboot

Postby LesterBoffo » Tue Aug 28, 2012 4:23 pm

The problem with JSBsim, at least for now is that the flight model is nearly a complete abstract of the actual aircraft's shape and wing arrangement, so you will practically have to create some rather intelligent coding to take the .xml's and make even a simple shape conversion of their coding.

Flying Model Simulator, (an R/C model simulator.) back in 2003 had a neat little program called ParEditor that took the .par file, (the FDM in simplified .txt format..) and made a crude, flattish polygonal 3d shape out of the .par, and superimposed it onto the 3D file to check how close the FDM matched the real model's shape. As much as I'd like to see this done for JSBsim I think we're going to have to use what we have. JSBsim planes can be quite accurate about the flight-model, especially with the engine/propeller modelling, and airfoils, both of which need to be well done in a simulation. But getting there takes lots of research and flight model checking.
User avatar
LesterBoffo
 
Posts: 2129
Joined: Sun Oct 02, 2011 4:02 pm
Location: Oregon, USA
Callsign: LesBof
Version: 2018.3.2
OS: Win10 Pro

Re: YASim Importer for Blender - Reboot

Postby jonbourg » Wed Aug 29, 2012 8:56 pm

What I meant was take the xml tags from YASIM that define the structure of the plane putting them in their own xml file and just use them to display the plane as the YASIM script does, but do it with the other parts of JSBSIM superimposed on the plane.

I was thinking that may be easier then to use the actual 3D model, but I'm not a programmer so I don't know, I was just throwing the idea out there.

Of course a JSBSIM guy would have to learn a little YASIM if they had never used it before, but it's not that bad on defining the wing body shape, etc.
jonbourg
 
Posts: 328
Joined: Tue Mar 11, 2008 12:43 am
Location: Omaha, NE
Callsign: BU2B
OS: Windows8

Re: YASim Importer for Blender - Reboot

Postby F-JJTH » Wed Aug 29, 2012 9:19 pm

For information, PAF team work on a Blender plugin to allow to read/write XML animation + read/write JSBSim XML + read/write view XML.
For more information : http://gitorious.org/paf/fg2blender (press "f" in order to see the dedicated tools implemented in Blender for FlightGear)

@rebootl: If you are interested, I think that it will be really good to merge your YaSim reader in order to create only 1 python script. In this way we are able to provide a similar tools than x-plane (X-Plane provide a python script for X-Plane contributors)

The final goal is to provide a script who is able to create the 3D model + XML animation + basic FDM (contact point, Center of gravity...)

Cheers,
Clément
User avatar
F-JJTH
 
Posts: 696
Joined: Fri Sep 09, 2011 11:02 am

Re: YASim Importer for Blender - Reboot

Postby rebootl » Fri Aug 31, 2012 7:29 pm

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 ! :D 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.


Installation

Download: http://cem.square7.ch/simple_yasim_import.py

Install 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.)

Usage

An 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.

Image

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.
Image
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:
Image

But the tail rotor looks a bit strange:
Image

And for the vmx22 one vector points upwards, that seems to be wrong to me !
Image

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 :twisted: 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)
Last edited by rebootl on Fri Oct 11, 2013 5:48 pm, edited 2 times in total.
rebootl
 
Posts: 111
Joined: Tue May 03, 2011 2:55 pm
Location: Switzerland
OS: Arch Linux

Re: YASim Importer for Blender 2.6 - Reboot, released

Postby helijah » Fri Aug 31, 2012 10:25 pm

Hi reboot,

Only one word: FANTASTIC !

I use Blender 2.63.0 (with GNU/Linux, Kernel 3.5.3 64bit ) and I have just one problem with your script :

The X and Y axes are reversed. I tested with more than 10 aircraft of my shed and every time the same problem. As a reminder, the X and Y axes are reversed in YASim compared to the rest of FG.

2 examples:
Falcon 50
Image
Douglas Dc 3
Image

But despite this, still, it's a great job. And a thousand times thank you.

Regards Emmanuel
Some planes (and other) for FlightGear
http://helijah.free.fr
and
http://embaranger.free.fr
User avatar
helijah
 
Posts: 1126
Joined: Wed Dec 27, 2006 12:35 pm
Location: Chartres (France)
Callsign: helijah
IRC name: helijah
Version: GIT
OS: GNU/Linux

Re: YASim Importer for Blender 2.6 - Reboot, released

Postby rebootl » Sat Sep 01, 2012 11:48 am

Thanks !

Yes, this is correct. At the moment, what the script does is: Display everything exactly as it's defined in the XML. The YASim coordinate system is reversed, as you said, therefor it's displayed this way.

Reversing everything by default is something I don't want to do because IMHO it would just be incorrect.

When working with the original script, did you use the <!-- offset ... --> specification ? This is not implemented yet because when I started it was too complicated for me. I didn't think it's necessary because reorienting the "real" model is easy. Of course, I have only one aircraft I'm working on and I can understand that for someone who has a lot of aircrafts this might be annoying. :wink:

Possible solutions:
1.) One thing I could do relative quickly is add a checkbox for the locks, this way you could rotate the imported FDM easily.
2.) Another thing would be to add a Reverse button, to simply reverse the imported FDM (Rotate it 180° around the Z-Axis). Would this solve the issue for you ?
3.) Then, porting the <!-- offset ... --> method, from the original script, would be the last idea I have for now. But this one isn't so easy to do and would take a bit longer.

At the moment I'm really attracted by the idea of making a Blender YASim FDM suite, with the possibilities to create a XML interactively. Therefor I tend to solution 1.) and 2.). What do you think ?

Regards
rebootl
rebootl
 
Posts: 111
Joined: Tue May 03, 2011 2:55 pm
Location: Switzerland
OS: Arch Linux

Re: YASim Importer for Blender 2.6 - Reboot, released

Postby i4dnf » Sat Sep 01, 2012 12:30 pm

Actualy, reversing the axes is corect and should be done by the script.
All aircraft 3d models have the nose pointing left, so you'd end up with having the "Reverse" selection always on.
And no, you can't reverse the model, or the coordinates in the FDM, since you'd end up either with a backwards flying 3d model, or an invalid FDM configuration.
(it's one of the many YASim quirks)
i4dnf
Retired
 
Posts: 743
Joined: Wed Sep 09, 2009 7:17 am
Location: LRBS
Callsign: YR-I4D
Version: GIT
OS: Gentoo Linux ~amd64

Re: YASim Importer for Blender 2.6 - Reboot, released

Postby Hooray » Sat Sep 01, 2012 1:18 pm

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..

I'd suggest to get in touch with people like HHS - for a very long time, most helicopter developers had to use YaSim, so they can certainly tell you what you need to know.


Puh, that was a huge post, sorry bout that. I did it that way, to, hopefully, use it for the wiki after some time.

Yes, exactly my thinking - very good idea.
You could probably start by uploading your images (screen shots) to the wiki, so that they can be directly used in future tutorials.
Your youtube videos can be directly embedded here and in wiki tutorials


@rebootl: If you are interested, I think that it will be really good to merge your YaSim reader in order to create only 1 python script. In this way we are able to provide a similar tools than x-plane (X-Plane provide a python script for X-Plane contributors)

The final goal is to provide a script who is able to create the 3D model + XML animation + basic FDM (contact point, Center of gravity...)

Joining forces would definitely be a good idea. While JSBSim and YaSim are obviously different, the blender side of things can probably be shared, and XML processing code can probbaly also be shared.

Maybe you could first of all create a new gitorious repository and then commit all related scripts (mfranz, PAF, thetom, rebootl) and then work out a way to share code and reuse already existing stuff?

At the moment I'm really attracted by the idea of making a Blender YASim FDM suite, with the possibilities to create a XML interactively. Therefor I tend to solution 1.) and 2.). What do you think ?


That sounds pretty cool, if you can make it work, it would definitely be a huge contribution!
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12262
Joined: Tue Mar 25, 2008 8:40 am

Re: YASim Importer for Blender 2.6 - Reboot, released

Postby rebootl » Sat Sep 01, 2012 2:27 pm

@i4dnf:

Hm. Yeah, I understand your point. And you might be right. I'll have to think about it. But, what I considered as correct, till now, is:

The imported YASim FDM (and the YASim coordinate system) matches the blender coordinate system.

I considered this as essential, because this way, if you read out a position value from blender it's "correct" in the meaning that you can put it in the YASim XML directly ! If the imported FDM would be reversed by default, this would confuse me, if I'm not that proficient, because the imported FDM geometry would then not even match the XML !

Having a reversed button always on is not that terrible. But that way it would be clear to the user, that the actually displayed FDM is... reversed.

No, don't reverse the coordinates in the FDM! And don't use your real animation model for comparing, make a copy!

As I stated in the release post above, under example workflow:
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.


Okay, so this is certainly something to point out in a future wiki ! :wink:
rebootl
 
Posts: 111
Joined: Tue May 03, 2011 2:55 pm
Location: Switzerland
OS: Arch Linux

Re: YASim Importer for Blender 2.6 - Reboot, released

Postby helijah » Sat Sep 01, 2012 3:27 pm

Hi reboot,

I think you confuse the Blender coordinate system with that of YASim.

Blender uses the same system as FG, which facilitates the modeling of aircraft and other elements in Blender (and with the chance to have 1 blender unit = 1 meter in FG) but YASim uses another system . the YASim orthonormal is reversed compared to FG and of course compared to Blender.

As stated above, the aircraft nose is at left in side view. The display of the FDM must be identical. Central rotation of 180 ° around Z seems to be a good compromise and gives a satisfactory result :)
Image
To do this I unlocked the objects in the script and rotated 180 ° around Z of on the center of Blender.

In all case, thank you very very much for your work on this script :)

Regards Emmanuel
Some planes (and other) for FlightGear
http://helijah.free.fr
and
http://embaranger.free.fr
User avatar
helijah
 
Posts: 1126
Joined: Wed Dec 27, 2006 12:35 pm
Location: Chartres (France)
Callsign: helijah
IRC name: helijah
Version: GIT
OS: GNU/Linux

Next

Return to Aircraft

Who is online

Users browsing this forum: No registered users and 4 guests