Board index FlightGear Development

Blender 2.6 AC3D Importer & Exporter

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Re: Blender 2.6 AC3D importer

Postby majic79 » Sat Jan 28, 2012 6:36 pm

Thanks for the positive feedback JC_SV, there was a big API update with blender 2.6, this latest script will not work with pre 2.6, there's a tagged version of the scripts for 2.59, but doesn't include exports

One thing I haven't properly tested is exporting packed images. I think the readme needs an update though!
majic79
 
Posts: 106
Joined: Fri Dec 28, 2007 9:40 pm
Callsign: majic79
Version: 2_4_0
OS: GNU/Linux

Re: Blender 2.6 AC3D importer

Postby helijah » Sat Jan 28, 2012 10:20 pm

Hey majic79

I just updated your GIT repository on my hard disc and no change for export here :(
Image

I continue with the JC_SV export for the moment :)

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

Re: Blender 2.6 AC3D importer

Postby gooneybird » Sat Jan 28, 2012 11:33 pm

I have the same problem as heljah with 2.61 :(
My Github repository (mostly AI stuff) https://github.com/gooneybird47
User avatar
gooneybird
 
Posts: 3045
Joined: Sat May 31, 2008 2:57 pm

Re: Blender 2.6 AC3D importer

Postby majic79 » Sun Jan 29, 2012 12:27 am

Helijah/gooneybird - is there any chance I can get a copy of the files you're using to test the export from? Or if you can reproduce the error in a test .blend file or some such and email it to me?
majic79
 
Posts: 106
Joined: Fri Dec 28, 2007 9:40 pm
Callsign: majic79
Version: 2_4_0
OS: GNU/Linux

Re: Blender 2.6 AC3D importer

Postby gooneybird » Sun Jan 29, 2012 12:43 am

My Github repository (mostly AI stuff) https://github.com/gooneybird47
User avatar
gooneybird
 
Posts: 3045
Joined: Sat May 31, 2008 2:57 pm

Re: Blender 2.6 AC3D importer

Postby helijah » Sun Jan 29, 2012 4:06 am

simple, Everything files .blend, .ac imported etc..... :(

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

Re: Blender 2.6 AC3D importer

Postby TheTom » Sun Jan 29, 2012 3:13 pm

I've pushed an updated version which fixes some problems I had with scaling and rotation (espacially for hierarchically organized objects) and also applies modifiers before exporting. I also got the same error, which was caused by objects without a material. This should also be fixed in my version:

https://github.com/tomgey/Blender-AC3D
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D importer

Postby majic79 » Sun Jan 29, 2012 4:24 pm

Yep - figured out that null materials were the problem - I've updated mine so that there's a check for null materials - I've also updated the readme to reflect some of the updated changes.

There is another (potential) issue - currently the export exports every item (regardless of the layer that the item appears on) I'm just working on a method to only pull out those items that appear in the selected render layer

Tom - I like your code for the rotational translations, but your method of checking for a valid material doesn't work (I tried this first - the default is 0 and it's usually a valid index - you need to look at the size of the objects material slots collection and check that for a zero length) - Can you have a look at the latest mods I've just uploaded and merge them in, then I'll see about bringing your code into the main repo
majic79
 
Posts: 106
Joined: Fri Dec 28, 2007 9:40 pm
Callsign: majic79
Version: 2_4_0
OS: GNU/Linux

Re: Blender 2.6 AC3D Importer & Exporter

Postby majic79 » Sun Jan 29, 2012 4:48 pm

I've also updated the title of this thread to reflect the supported functionality :D
majic79
 
Posts: 106
Joined: Fri Dec 28, 2007 9:40 pm
Callsign: majic79
Version: 2_4_0
OS: GNU/Linux

Re: Blender 2.6 AC3D Importer & Exporter

Postby TheTom » Sun Jan 29, 2012 6:00 pm

I've updated my code with your latest commit. The rotation works currently only for the first level of children. But I won't have time to have a look at it this before next week. Also now before exporting meshes all modifiers get applied (I use the mirror modifier a lot).
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D Importer & Exporter

Postby majic79 » Sun Jan 29, 2012 7:37 pm

TheTom wrote in Sun Jan 29, 2012 6:00 pm:I've updated my code with your latest commit. The rotation works currently only for the first level of children. But I won't have time to have a look at it this before next week. Also now before exporting meshes all modifiers get applied (I use the mirror modifier a lot).


Brilliant, I'll review it - my only doubt is about the application of modifiers - do they get applied to the whole blend file? or is it a temporary thing? I don't like the idea of the exporter modifying the contents of the .blend file (if this is what everyone wants, then that's ok, perhaps I might modify it so it's an option at the time of export - apply modifiers)
majic79
 
Posts: 106
Joined: Fri Dec 28, 2007 9:40 pm
Callsign: majic79
Version: 2_4_0
OS: GNU/Linux

Re: Blender 2.6 AC3D Importer & Exporter

Postby TheTom » Sun Jan 29, 2012 7:41 pm

majic79 wrote in Sun Jan 29, 2012 7:37 pm:my only doubt is about the application of modifiers - do they get applied to the whole blend file? or is it a temporary thing? I don't like the idea of the exporter modifying the contents of the .blend file (if this is what everyone wants, then that's ok, perhaps I might modify it so it's an option at the time of export - apply modifiers)

They are not applied to the original meshes, instead new temporal meshes with the modifiers applied are created. I haven't found a way to delete the temporary meshes yet, but it seems like blender removes unlinked meshes on reopening the file. An option would be nice though.
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D Importer & Exporter

Postby majic79 » Sun Jan 29, 2012 9:04 pm

Using gooneybirds original blend file - I can export everything, but re-importing it and some planes are not brought back into line - so that people have a reference, I've tagged the version before I merged your code in Tom - but I think we need to spend a little time making sure that it's all working properly. The problem could be the import side of things, or it could be something to do with how the rotations are applied in the exporter
majic79
 
Posts: 106
Joined: Fri Dec 28, 2007 9:40 pm
Callsign: majic79
Version: 2_4_0
OS: GNU/Linux

Re: Blender 2.6 AC3D Importer & Exporter

Postby mr_no » Mon Jan 30, 2012 12:04 am

The script that JC_SV compiled was fine, but there's one thing that I changed for my own usage.
When the autosmoothing is off in Blender the exporter will not add "crease xx" line.
The Majics script will add "crease 30".

BOTH are wrong... Why?
Because when exported to FG the model doesn't look like the shaded model you had in Blender.
The game engine adds creasing if it isn't in the .ac file (45 degrees or so).

I control the sharp edges with "split edges" not with autosmoothing.
The solution I made is to rewrite function "extrait_crease" in the exporter, like this:
Code: Select all
def extrait_crease( obj, mesh ):
   pi = 3.141592653589793238462643383279502884197
   if len(obj.modifiers)!=0:
      for mod in obj.modifiers:
         if mod.type=='EDGE_SPLIT':
            return mod.split_angle/pi*180.0
   if mesh.use_auto_smooth:   
      if mesh.auto_smooth_angle!=0.0:
         return mesh.auto_smooth_angle/pi*180.0
   else:
      #return -1.0
      return 179.0
   
   return 30.0

You can notice I commented out "return -1.0" where the exporter would ignore creasing because autosmoothing was not set. I replaced it with "return 179.0". Solution with best results for FG.
Mosquito-XE JT-5B-autogyro Extra-300s STOL-Ch701
User avatar
mr_no
 
Posts: 360
Joined: Thu Jan 19, 2012 3:20 pm

Re: Blender 2.6 AC3D Importer & Exporter

Postby TheTom » Mon Jan 30, 2012 12:31 am

I've now pushed a new version which should correctly transform the rotation matrix on import and also is able to parse quoted names with spaces in it. On the exporter side I added code to check for non existant textures, which made the plugin crash on exporting a model of mine (relative texture paths don't seem to work...)

Regarding autosmoothing. I've also faced the same problem that smoothed surfaces (with the smooth button in blender) don't get imported and probably also don't get exported correctly.

@mr_no What computer are you using which supports that high precision floating point numbers? ;)
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

PreviousNext

Return to Development

Who is online

Users browsing this forum: No registered users and 4 guests