Model import and export

From FlightGear wiki
Jump to navigation Jump to search
This article or section contains out-of-date information

Please help improve this article by updating it. There may be additional information on the talk page.


The Problem

When you create an aircraft model, generally an object like a wing is composed of other parts. A wing may consist of the wing body, the aileron, the flap and perhaps a wingtip. There may be hardware such as stays, guidelines, actuators, etc. It is desirable to export the entire wing with all its parts intact and _independent_. Some export or import tools may not support independent 'sub-objects' and will merge all the parts of a wing into single object (or 'mesh' as objects consisting of polygons are generally called in the 3d world).

What happens if you export or import using a tool that does not support sub objects? You get a wing with all its parts 'welded' together so they cannot be individually manipulated. This is not a good thing.

FlightGear Import/Export

In FlightGear, a utility called '3dconvert' is bundled with the source (Windows binary available here), which has the ability to convert a number of 3d file formats. Exporting and importing 3d files for FlightGear can involve using the bundled '3dconvert', although it does not have to, given there are a number of third-party converters and import/export tools for 3d modeling applications.

It depends on a library called PLIB for making conversions between formats. As of this writing, _3dconvert_ can only open or save in formats supported by PLIB with any restrictions PLIB places on them.

This utility is dependent on the PLIB library. If you dig deep enough into PLIB documentation, you may find in a very obscure page

Non-class Functions http://plib.sourceforge.net/ssg/non_class.html (subject to change)

containing a table of formats PLIB is capable of opening and saving. Not all features of certain formats are supported in a given version of the library. This chart explains which formats PLIB recognizes and what features it supports. It also can tell you which features some formats lack.

The problem to solve is getting an aircraft model from GMAX's proprietary binary 3d format into a format more in keeping with the FlightGear community. Moreover, it is desirable to store 3d models in a format that has some longevity and is human readable. Those are two good reasons to get your model out from GMAX's trap.

Two major 3d design applications are AC3D and Blender. AC3D is the format FlightGear uses 'natively' for aircraft models. It is good that FlightGear uses a non-binary format for aircraft models. The AC3D model files are in 'ac' format and have an '.ac' file extension. Blender is another popular 3d modeling application, its files are in Blender format and have a '.blend' extension. Blender can import or export a number of 3d formats using Python scripts (don't worry, the scripts are easy to use and bundled with the latest version of Blender).

This tutorial will focus on Blender, because I am currently using it for my modeling.

Getting Your Model Out of GMAX

An intermediate format is needed to get our model from GMAX into Blender, because GMAX cannot export non-binary 3d files. This is our first problem to solve. Fortunately, others have found a workaround for this situation. Data can be extracted from GMAX objects by writing a Maxscript (the native scripting language used in GMAX) program that collects the data and prints it to the conveniently provided "script listener" which listens to the output of scripts and displays it in a text window. The clever person can then copy the data from the window and paste into a text editor, which can then save the data into a file.

(I will not go into using GMAX plugins. These are issued by game companies that partner with GMAX and distributed software you can plug in to GMAX to export to a particular 3d format used by the game. Feel free to search for these and use them if you can find them and get them to work.)

This file can then be fed into another conversion or import tool. Either directly into a 3d modeling application or another conversion tool.

I found only one workable script for GMAX, one that displays object data in Wavefront OBJ format in the listener window. It is called {NAME HERE} and you can possibly get it {HERE} before it disappears. (See below)

Or you can try my own script that displays AC3D data in in the window.

In any case, you must go through the tedious task of copying and pasting the data. The listener window has some limit on the number of characters you can copy to the clipboard, so you will need to carefully break up the copying into several small selections for large objects.

Sorry.

Note: You may encounter a problem where the script reports an error. This is typically caused by a "grouped" object. You need to select any compound grouped objects and "ungroup" them before export.

SketchUp

See this page: Modelling - SketchUp for importing from SketchUp.

Blender

Getting Your Objects into Blender

Now that you've got your objects into an intermediate format, you need to get them into your 3d modeling application. I will focus on Blender, but it applies to other applications as well.

If you have the latest version of Blender {version} you _should_ have at least one script for importing Wavefront (.obj) format files. The scripts can be found on the File --> Import or File --> Export menus. Any import or export scripts installed should show up on these menus. Naturally, you will want to look on the Import menu. There is another OBJ filter you may encounter. I found this one limited, so skipped it for the one that seemed more full featured. The one you want is called Wavefront (.obj) and is authored by {author}.

The only step left is to import the OBJ files created by your cutting and pasting into Blender.

Each independent object in your GMAX 'scene' should be there in Blender. Try selecting a part, say the aileron. It should be separately manipulable.

Getting your objects out of Blender and into Flightgear

Suppose your object was an entire aircraft (you have a strong constitution, doing all that copying and pasting, I disassembled by aircraft into parts, exported them and reassembled them to avoid too much copying at once) or you have created one in Blender from your imported parts.

To use the aircraft in FlightGear, you export in AC3D format. See here for main page about this subject: Blender AC3D import and export

Exporting in AC from GMAX

This discusses a little script I wrote to export objects from GMAX into AC3D format.

gMax2AC


Additional Issues

Suppose the scripts to import additional 3d file formats did not exist in Blender. It only natively recognizes three formats (at time of writing), VRML 1.0, DXF, Videoscape and STL. Most are not widely in use today for 3d modeling (in my experience). DXF is a widely used standard format for CAD, but it lacks sub-object support. As far as I know, you cannot use DXF as an intermediate format and have your parts survive unmerged. (According to PLIB chart).

Here are some failed attempts:

GMAX->AC3D->VRML 1.0 using _threedeconvert_ merges objects.

Of course, if you have the Blender AC3D importer, this is unnecessary and not an issue.

GMAX-OBJ->VRML 2.0

Here I used a third-party file converter. Unfortunately, it only outputs VRML 2.0 and vanilla Blender only imports VRML1.0, which meant this is not a good path.

It just makes clear that you must be careful about which conversion tool or import/export tool you use, be sure it supports sub-objects.

What happens if objects are merged? Have fun picking all the parts of of a complex landing gear out of a single merged object!

Why Export from GMAX?

Several reasons:

  • GMAX is a "dead end", an application developed as a "crippled" version of a high end 3d design suite, deployed for game modding. This year (2005) all support by its make has been dropped. GMAX will only be distributed and supported within individual game environments, if at all.
  • GMAX 3d files are in a proprietary binary format, which means humans cannot read them, it makes it difficult to translate to other formats because the format is only known to the developer. This reduces the "longevity" and ability to share your files.

Both of these issues add up to a situation that can leave your files "orphaned." I put hundreds of hours into my models and do not want them trapped on a "sinking ship" platform that I cannot get them out again to work on.

The official gmax website now points to the parent company AutoDesk, which apparently has discontinued or dropped support for the application.

If you go to the Discreet website (the company that released and managed GMAX)

http://www.discreet.com/products/gmax/

it takes you to

http://usa.autodesk.com/adsk/servlet/index?id=5562445&siteID=123112

which states

"As of October 6, 2005, Autodesk will no longer offer Gmax® software as a stand-alone product. If you are interested in other 3D animation, modeling, and rendering applications from Autodesk please check out Autodesk® 3ds Max® software. You can download a free 30-day trial, view product demonstrations, read customer success stories, and get more information about this powerful, versatile product."

Maxscript Resources

There appears very little Maxscript material online. No tutorials, instructions, specifications, other than the official 3ds Maxscript help file I got somewhere. Many of the Maxscript sites are down, gone, password protected or otherwise unavailable. There were several versions of GMAX released, I find that many plugins and scripts are incompatible. I just don't have the time or interest for such a scattered set of resources and community, when there exist strong communities around open source applications such as Blender.

I will not be responsible for the chaotic state of these resources or their applicability or availability, but here are some helpful ones if they still exist by the time you go to them.

Chris Cookson was the author of several important Maxscript import/export scripts, which are no longer easily available.

See this thread

http://www.turbosquid.com/Forum/Index.cfm/stgAct/PostList/intThreadID/16045

for current 2005 status.


The OBJ importers are

v1.1 http://www.turbosquid.com/Forum/Index.cfm/stgAct/PostList/intThreadID/16045

v1.1a http://pages.videotron.com/browser/Downloads/GMAX/scripts/importobj.ms


http://tutorials.city-of-doors.com/gmax.html

Mentions the 10kb limit on cut and paste from script listener.

The script mentioned here for working around this for at least one file format is here

http://nwvault.ign.com/View.php?view=Other.Detail&id=148

and still available at the time of writing. It was last updated in 2003. Perhaps you can adapt it. Good luck.


This is a GMax-compatible Maxscript which will import and export (via the listener) ASCII mdl files...

This Maxscript © utility will import/export Bioware's © mdl model files for Neverwinter Nights ©.

DLA presents 'Aurora Importer' by Joco. This maxscript utility serves one function: it imports an as...

Notes

https://github.com/majic79/Blender-AC3D