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 mr_no » Mon Jan 30, 2012 12:53 am

Yeah exactly, that pi is funny, but that's what was in the exporter. I only changed that "return line". :P
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 majic79 » Mon Jan 30, 2012 1:44 am

I've taken that bit of code and added it to the exporter (hope that's Ok with you) - also modified so that the exporter defaults to exporting all visible objects (the other option is from all objects) and then it's either all of those objects, or just those selected (I've switched this back to default off)
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 2:41 am

I don't know about others but I would prefer "just those selected" to be a priority.
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 helijah » Mon Jan 30, 2012 8:34 am

Hey TheTom, mr_no and majic79,

I just tested the latest version. Fantastic. Import and export are functional. Congratulations to you all. A fun detail. I did my test on my B24 Liberator. Import the .ac and after export a new .ac

Old b24.ac : 3.2 Mb ( 3235 Kb )

New b24.ac : 2.5 Mb ( 2524 Kb )

Another example with the BAe 125

Old bae125.ac : 2.4 Mb ( 2482 kb )

New bae125.ac : 1.9 Mb (1963 Kb )

Interresting, is not it ?

By cons, if I use my .blend and I export the .ac, the result is very strange.:
Export after import .ac :
Image

Export with my .blend
Image

But this is not very serious. I only have to redo my .blend with my .ac :)

Regards Emmanuel

P.S. The bae125.blend file : http://helijah.free.fr/blender/bae125.blend
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 & Exporter

Postby majic79 » Mon Jan 30, 2012 9:32 am

Thanks Helijah - I've alos noticed that the sizes of the exports are considerably reduced compared to the original imports. it makes me wonder what information is missing from the file. I am investigating it (but limited time again - will have a few hours to spare tomorrow night).

I really believe that the .blend file should be left unmodified by the export process - I'm glad you think it's not too serious, I think it's pretty serious!

Tom - please don't try and pull in a modified importer - I looked at an output from the exporter in g3dviewer and it showed some items rotated into the wrong position (location was correct, just orientation wrong), so that suggests the error is in the export rotation sequence

Mr_No - appreciate the feedback - would like to know everyone elses thoughts on it, also did you know you can save presets? So if you prefer one thing, you can save that preset and behave like that by default (the out of the box configuration is aimed at what I think is best, but then someone else may think otherwise)
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 » Mon Jan 30, 2012 11:30 am

majic79 wrote in Mon Jan 30, 2012 9:32 am:I really believe that the .blend file should be left unmodified by the export process

I've just made a test and after reopening the file the temporary meshes were gone. So no modification is made to the original .blend file.

majic79 wrote in Mon Jan 30, 2012 9:32 am:Tom - please don't try and pull in a modified importer - I looked at an output from the exporter in g3dviewer and it showed some items rotated into the wrong position (location was correct, just orientation wrong), so that suggests the error is in the export rotation sequence

Strange. I have no problem with exporting and importing the bae125 - only the textures are missing. The really strange thing is that it looks great in osgviewer, but completely wrong in g3dviewer.
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D Importer & Exporter

Postby majic79 » Mon Jan 30, 2012 12:00 pm

TheTom wrote in Mon Jan 30, 2012 11:30 am:
majic79 wrote in Mon Jan 30, 2012 9:32 am:I really believe that the .blend file should be left unmodified by the export process

I've just made a test and after reopening the file the temporary meshes were gone. So no modification is made to the original .blend file.

If you save the file after performing the export, does it save the temporary meshes? I don't want anyone using the exporter to export something, then look at blender and say "hey, everything's moved?! WTF is going on here" - we'll work it out

TheTom wrote in Mon Jan 30, 2012 11:30 am:
majic79 wrote in Mon Jan 30, 2012 9:32 am:Tom - please don't try and pull in a modified importer - I looked at an output from the exporter in g3dviewer and it showed some items rotated into the wrong position (location was correct, just orientation wrong), so that suggests the error is in the export rotation sequence

Strange. I have no problem with exporting and importing the bae125 - only the textures are missing. The really strange thing is that it looks great in osgviewer, but completely wrong in g3dviewer.

g3dviewer is a bit basic - no textures, no smoothing - but it rotates and locates everything correctly - I've been using it to check my outputs, I'll also use osgviewer to check it out
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 » Mon Jan 30, 2012 12:11 pm

majic79 wrote in Mon Jan 30, 2012 12:00 pm:If you save the file after performing the export, does it save the temporary meshes?

Even if I save the file after importing and before reopening the temporary meshes get removed.

majic79 wrote in Mon Jan 30, 2012 12:00 pm:g3dviewer is a bit basic - no textures, no smoothing - but it rotates and locates everything correctly

Are you sure g3dviewer rotates correctly? I've tried it with the default 777-200 and eg. the texture coordinates are shown completely wrong. One more strange thing is that I haven't found any .ac file which uses rotations. Even AC3D itself doesn't seem to use it...

edit: I've had a quick look at the g3dviewer sources and it completely ignores the rotation matrix on importing .ac models.
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D Importer & Exporter

Postby majic79 » Mon Jan 30, 2012 1:08 pm

if it seems that nothing honours .ac file rotations, then perhaps the exporter is better off finalising the rotation for the export (so the rotation matrix will always result in zero rotation)
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 » Mon Jan 30, 2012 6:42 pm

I haven't found any .ac file using the rotation field yet. As the ac3d format doesn't support multiple instances of the same mesh it probably would be useless to export it (Only for animations a rotation of the axis could be necessary).

I have updated my branch to transform all vertices with the rotation matrix before exporting and only export positions of objects. It now works correctly on all files I've tested it (also my rather complex file with multilevel object hierarchies). I have now also found the correct function to remove the temporary meshes without reopening the file.

edit: No I've got a problem that I don't know how we should handle object hierarchies and what should be exported. Currently there are two options. Export visible only and export selected/all objects. The problem is if I select an object which has a parent element which shouldn't get exported the object itself won't be exported.

I would suggest to only export selected (and visible?) objects and (optionally) all their visible children. If in a child chain a child is invisible all descendant children shall also be ignored apart from if a child is selected which would then in this case be exported as a global object with no parent relation. Maybe there should also be an option to select between exporting hierarchical objects or just selected objects without any parenting information. I think this would provide an export process where most people would see the output as expected.
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D Importer & Exporter

Postby TheTom » Tue Jan 31, 2012 6:01 pm

I've pushed a new version. I restructured and rewritten nearly the whole exporter. Now also exporting objects linked from other .blend files works and some bugs have been fixed (eg. relative texture path didn't work or selected objects with a not selected/visible parent now also get exported).
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D Importer & Exporter

Postby majic79 » Wed Feb 01, 2012 1:15 pm

OK, I'll have a look at it tomorrow - sadly I didn't get time Tuesday, and I'm not likely to have time tonight - RL workload supersedes this I'm afraid...
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 » Wed Feb 01, 2012 10:33 pm

I just found the blender python api reference.
I've found and corrected errors in the exporter concerning material shininess (shi) and surface data (SURF 0x00).
I'll look into the errors in the importer as well.
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 » Fri Feb 03, 2012 3:40 pm

mr_no wrote in Wed Feb 01, 2012 10:33 pm:I've found and corrected errors in the exporter concerning material shininess (shi) and surface data (SURF 0x00).

Have you published your changes somewhere?

I have also a problem with the material. Blender doesn't support emiting a color. You can only set emit to a certain value. There exists an option in the exporter to use the mirror color as emis color, but it is not used. I have implemented it now and multiply the mirror color by the emit factor (to prevent unintentional emission).
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Blender 2.6 AC3D Importer & Exporter

Postby mr_no » Fri Feb 03, 2012 7:56 pm

I took the script from Helijahs web site and fixed it! :mrgreen:
Now both importer and exporter work.
I did a lot of changes to the importer. Some are:
-load UV texture
-don't add texture to material because then you need material duplicates
-fixed more material issues
-fixed reading of SURF info concerning double sided and smooth surfaces
-each face can be flat or smooth shaded on it's own
-check double sided in blender
-check auto smooth and import angle
-check object show transparent

Exporter now writes correct SURF info concerning smooth faces and double sided meshes.

Also looking at older 2.49 importer the material shininess (shi) is translated into material.specular_intensity both in the importer and exporter, and so it is in mine.

Know issues:
-Errors can appear when AC3Ds mesh has faces that are both single and double sided. This wont work in Blender and importer will create a mesh with only one type of faces, because Blender does this on mesh level not on a face level
-The creasing will not show in real time in the shaded model in Blender. Render an image to see how the shading really looks.

When you are creating your mesh doing Object->apply->location-rotation-scale prevents the unwanted errors in the exported meshes. That means everything from wrong scale to inverted faces. This is common sense for experienced modeller but not everyone knows it, as I have forgotten till the other day.

I tested importer and exporter on simple meshes and on the P22 Tri-Pacer.
If you have any problems just tell me.

mr_no_blenderAC3D_03022012.zip
http://www.mediafire.com/?6e6e1gc8plok9o9
Mosquito-XE JT-5B-autogyro Extra-300s STOL-Ch701
User avatar
mr_no
 
Posts: 360
Joined: Thu Jan 19, 2012 3:20 pm

PreviousNext

Return to Development

Who is online

Users browsing this forum: No registered users and 3 guests