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 & Exporter

Postby majic79 » Fri Feb 03, 2012 9:16 pm

Blender 2.49 had an import/exporter? I started this work with blender 2.59 because there's nothing for 2.5X, and then ported it up to 2.6X when that was released in Oct last year
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 » Fri Feb 03, 2012 9:24 pm

Yes it has one, but it doesn't work. It's VERY different, api and all.

Anyway, proof that my exporter works p22 to p20:
viewtopic.php?f=4&t=15206
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 JC_SV » Fri Feb 03, 2012 10:07 pm

Thanks Majic79, TheTom and Mr_No.
I just downloaded Mr_No Scripts and started to test them. First model I tried to import ... don't worry of the images you are going to see :

Image

But this is NOT your script fault. It happens to be a model probably exported with first versions of the scripts where the .ac file had a texture path with something like "../../../../texture.png" . I opened the model (.ac file) and changed those "../../../../texture.png" to "texture.png" and it is ok now. You can see the importing using your Scripts after I edited the model (.ac file).

Image

I am posting this because this may happen to others. By now, I have a Blender 2.60a with old scripts still in my hard drive just to open some old models wich do not "want" to be imported with new versions of the scripts then I save them to .blend file and open in 2.61 and then export to .ac . I hope I explained myself right.

Up to the moment I am happy with your scripts...

Best Regards

JC_SV
JC_SV
 
Posts: 80
Joined: Tue Nov 29, 2011 8:06 pm

Re: Blender 2.6 AC3D Importer & Exporter

Postby majic79 » Fri Feb 03, 2012 10:46 pm

ok, well I've just pushed some mods from TomGeys scripts into my main exporter - just to handle the rotation and translation (using the u177 .blend file I was seeing the prop cone not getting the correct rotation when I re-imported the .ac file)

I might be able to port my code to work with the blender 2.49 API, but I don't see the point unless there's a big demand from blender 2.49 users?
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 » Sat Feb 04, 2012 1:19 am

JC_SV,
I didn't test but this code could work with anything 2.5+.
To edit those old .ac files you can just go into a text editor and find and replace all "../../../../" with "" (empty string).

Majic,
There's already a working 2.49 script. It comes with Blender. They left it out in 2.5 though, and that's why we're here.
My scripts goal is to do the basic. If you want to put some advanced things you can do that in yours (options, modifiers, etc).
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 » Sat Feb 04, 2012 11:18 am

Majic and I have now merged our changes together. The latest version can always be found on github:


I've now also updated the importer to try finding textures also just with the basename, thus if it for example doesn't find "../../../../texture.png" it also tries just with "texture.png".

@mr_no: Maybe we should better continue to work on only one script to not needless double the work. Eg. loading UV textures allready works in our script, but on the other hand there is still an issue with correctly importing smooth surfaces.
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D Importer & Exporter

Postby JC_SV » Sat Feb 04, 2012 4:31 pm

I am downloading your scripts. Yesterday I tried (your scripts and Majic79) and both were able to import de b25a.ac file with the original "../../../../texture.png". I am just waiting to have the smooth importing issue solved. Not just waiting but trying to find a solution with it but no success yet.
And yes it will be better to have just one version of scripts to avoid weird issues.

Best Regards.

JC_SV
JC_SV
 
Posts: 80
Joined: Tue Nov 29, 2011 8:06 pm

Re: Blender 2.6 AC3D Importer & Exporter

Postby mr_no » Sat Feb 04, 2012 6:49 pm

Smooth shading problems. Blender - AC3D (in game)

Auto smoothing (crease) works, but you need to know how to see and control it.
Let me describe the process:
Import an .ac. Auto smoothing is checked and angle set if crease is 30-80 degrees. In other case it's unchecked. Auto smooth unchecked means crease will be set to 179 degrees in the exported .ac file, and the models shading will look as it looks in Blender in real time. Just as you see it.

But, when an imported file has it's own 30-80 degrees setting the models smooth shading will look differently in game than it looks in Blender.
How will it look?
You can preview how the model will look in game in two ways.
1) render an image and Blender will follow auto smoothing and show the real model.
2) apply Edge Split to each mesh using the same angle as in auto smoothing

Image
Last edited by mr_no on Sat Feb 04, 2012 7:26 pm, edited 1 time in total.
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 mr_no » Sat Feb 04, 2012 7:09 pm

What you can do in your importer is put Edge Split option, so when imported all meshes will get Edge Split added to them. But DON'T apply the modifier. If applied the edge split will add more edges and create holes in meshes. This is something a user possibly doesn't want.

Use something like this (only as an option for a user):
Code: Select all
def edge_split( context):
   bpy.ops.object.select_all(action='DESELECT')
   list_objects = context.scene.objects
   for obj in list_objects:
      if obj.type == 'MESH':
         obj_name = obj.name
         bpy.ops.object.select_name(name=obj_name)
         if (obj.use_auto_smooth == True):
            split_angle = obj.auto_smooth_angle
            if ((degrees(split_angle) > 29.999999) and (degrees(split_angle) < 80.000001 ) ):
               bpy.ops.object.modifier_add( type='EDGE_SPLIT')   
               for mod in obj.modifiers:
                  if mod.type=='EDGE_SPLIT':
                     mod.split_angle = split_angle

And I'm done coding on my own so we don't misunderstand each other. I was impatient. :|
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 mr_no » Sat Feb 04, 2012 9:46 pm

OK so I tested your code and this is what I've found:
-As you know meshes aren't all smooth. (Each face can be smooth or flat)
-Some objects are double sided that aren't supposed to be that.
Both of the above are related to 'SURF' parsing.

-You are creating many duplicates of materials. I mean MANY!
Ignore putting texture into material. Put it in uv_texture.
Objects can have the same material but different texture, or different texture but the same material.
Basically just create all materials in a scene, then create meshes with uv_textures and give mesh a material.

These are the same things I corrected in the other script, so look at it for clues.
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 439Tiger » Tue Feb 07, 2012 3:36 am

I've got a problem with the importer, I think.

This is what I get when I import the .ac file into Blender with the latest script dated 4 Feb:

Image

And if I use 3D viewer, I get this:

Image

Here is the .ac file if someone wants to take a look at it:

http://www.divshare.com/download/16733513-006
Specializing in Canadian built aircraft and aircraft flown by the RCAF

http://www.flightgearcanada.ca/ or: https://sites.google.com/site/flightgearcanada/
User avatar
439Tiger
 
Posts: 1163
Joined: Sat Jan 01, 2011 3:39 am
Location: St-Georges-de-Beauce, Québec, Canada (CYSG)
Callsign: C-CYSG
Version: 2.10.03
OS: Windoze 7

Re: Blender 2.6 AC3D Importer & Exporter

Postby DFaber » Tue Feb 07, 2012 11:09 am

Hello Guys,

first off I really appreciate your work on the exporter. The Exporter works well for me but now I noticed something strange. Some Models export fine (including texture file and mapping), but others export without textures, just plain mesh.
When I open these blend files in 2.49, there is no texture set and I have to re-set the texture for every object.

Is there anything I missed?

Greetings
Detlef Faber
FlightGear Development:
http://flightgear-de.net

my 3D-Art:
https://www.sol2500.net
DFaber
 
Posts: 709
Joined: Fri Dec 01, 2006 8:51 pm
Location: Aachen, Germany
Version: GIT
OS: Linux

Re: Blender 2.6 AC3D Importer & Exporter

Postby majic79 » Tue Feb 07, 2012 2:30 pm

439Tiger: I'll have a look at it this week - might be a little delay as I'm prepping for an event at the weekend and don't have much time for myself between now and then, it will get looked at!

DFaber: Can you tell us what version of the scripts you are looking at? Currently the exporter only supports UV texture mapping (it won't export any other type of texture map) and I've not tried to see if blender will convert from one to the other for us (lack of time), but if you can supply the original .blend file (and associated textures) I'm happy to have a look at it for you
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 » Tue Feb 07, 2012 5:59 pm

majic79 wrote in Tue Feb 07, 2012 2:30 pm:439Tiger: I'll have a look at it this week - might be a little delay as I'm prepping for an event at the weekend and don't have much time for myself between now and then, it will get looked at!

The problem is that the file contains a face with > 4 vertices (15 to be exact) what caused the importer to crash after importing the first few objects. I have commited a temporary fix which ignores faces with more then 4 vertices instead of crashing. Also the .ac files has some strange surface codes (0,1,2 allowed but 3 used...). Where does this file come from?
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D Importer & Exporter

Postby 439Tiger » Tue Feb 07, 2012 7:13 pm

It is one of Dave Culp's aircraft, the TF-104G, it comes from here:

http://www.fguk.eu/hangar/index.php?folder=YWlyY3JhZnQ=
Specializing in Canadian built aircraft and aircraft flown by the RCAF

http://www.flightgearcanada.ca/ or: https://sites.google.com/site/flightgearcanada/
User avatar
439Tiger
 
Posts: 1163
Joined: Sat Jan 01, 2011 3:39 am
Location: St-Georges-de-Beauce, Québec, Canada (CYSG)
Callsign: C-CYSG
Version: 2.10.03
OS: Windoze 7

PreviousNext

Return to Development

Who is online

Users browsing this forum: No registered users and 10 guests