Wednesday, 13 September 2017

3DS max 2016 Metasequoia (.MQO) Importer

Since the website with the Metasequoia importers/exporters for modern versions of 3DS max has disappeared I tried my hand at compiling sio29’s 3DS max 9 code for 3DS max 2016.

sio29’s 3DS max 9 code is available here [link].

I downloaded and installed 3DS max 2016 and the 3DS max 2016 SDK via the Autodesk virtual agent since the web installer failed.

The SDK says that plugins for 3DS max 2016 must be compiled with Visual C++ 2012 so I installed VS 2012 Express for Desktop to get the 2012 compiler.

I first tried to open sio29’s project and have it upgraded but was unable to get the project property settings correct. 3DS max 2016 SDK requires Unicode plugins and even though I set Unicode as the character set, it did not affect the code for some reason.

Next attempt, I instead installed the Visual Studio 3DS max plugin wizard by following the instructions in the SDK. When you set the path in the .vsz file to the 3dsmaxPluginWizard directory make sure there are no double quotes other than at the start and end of the complete line. Because of UAC run VS as administrator.

I created an import plugin project and added all the files in sio29’s “ulib” folders via the “Add existing items” menu.

Then I copied and pasted the plugin code from sio29’s .cpp file into my corresponding .cpp.
I also copied and pasted from sio29’s .rc file to my .rc file.

Lots of errors, mainly due to sio29’s code using Multibyte Character Set (MBCS) and not Unicode.

The SDK functions require Unicode strings so I used the functions described at MSDN [link] to convert the strings between MBCS and Unicode.

Some additional headers needed to be included, e.g triobj.h, stdmat.h

The string functions such as lstrcmpi in the “ulib” code needed to be changed to the specific MBCS versions (lstrcmpiA) since Unicode had been defined meaning lstrcmpi was defined as lstrcmpiW. The code in the “ulib” folders uses too many const char* and char to convert it to Unicode!

The plugin wizard fails to write the parameters in the DoImport/DoExport function definitions for some reason so those needed to be added too.

In the exporter project properties the bmm.lib file needed to be added to the Linker>Input>Additional Dependencies due unresolved symbols for bitmap stuff. And the path for BIPEXP.h appended in the include.

For errors I didn’t understand I commented out the offending code.

To debug the plugin the Hybrid configuration is used and not the Debug configuration. The debug configuration will not build successfully.

When debugging note that the plugins are loaded late in the 3DS max startup process so do not cancel Symbol loading early. The symbols can be loaded later using the Debug>Modules window however.

The only change I made to sio29’s .mqo reading code was to change the check of the header. As written it was never going to fail for unknown .mqo versions. Note it will accept version 1.1 .mqo files but n-gons (faces with 5 or more vertices) are not handled by sio29's code so may crash the plugin

For the exporter the only change I made was to write “Eof” instead of “eof” at the end of the .mqo file.

These plugins will not work with 3DS max 2017 or later since the corresponding SDK is required and the plugins need to be compiled with a newer version of Visual Studio.

Use at your own risk!

Download link: http://www.mediafire.com/file/dedcb3c4gcagadm/mqo2016.zip

UPDATE 2MAR18:

Updated the importer so the texture map is not used also for alpha and bump maps and fixed some bugs found while testing the sample models that come with Metasequoia 4.

Download link: http://www.mediafire.com/file/dyc14n8hoe1keuj/mqoimp2016.zip





2 comments:

  1. Is that you, sapper? Why didn't you tell me you're working on an update to 3ds max mqo plugins! :O Downloading right now and testing!

    ReplyDelete
    Replies
    1. Thought you had 3DS 2018. Anyway this importer needs some work to make it fully compatible with Metasequoia 4.

      Delete