How to compile the MayaImportx86 DLL (Maya 2011)

From The DarkMod Wiki
Jump to navigationJump to search

(greebo's memo on how to compile the Maya Import library for exporting meshes and animations from Maya to D3.)

Use the following to build the Maya exporter plugin for Doom 3:

  • Windows 7 (Ultimate)
  • Windows Virtual PC (for XP Mode)
  • Maya 2011
  • Visual Studio 2008 SP1
  • Doom 3 SDK (downloaded from iddevnet)

Step by Step

  • Set up Windows XP Mode
  • Install VS 2008 SP1 (to the Virtual Machine, as for all programs listed here)
  • Install Maya 2011 to C:\Programme\Autodesk\Maya2011
  • Note the include and lib folders, which must be present in this location.
  • Install the D3 SDK to C:\Games\Doom3_SDK
  • Open the solution C:\Games\Doom3_SDK\src\D3Game.sln, and let the conversion wizard finish its work.
  • Open the MayaImport project
  • Set the Solution Configuration to "Release".
  • Set the include and lib paths for this project:
    • Remove the MayaImport\Maya4.5\include path
    • C/C++ > Additional Include Directories: C:\Programme\Autodesk\Maya2011\include
    • Linker > Additional Library Directories: C:\Programme\Autodesk\Maya2011\lib
    • Linker > Additional Dependencies: Foundation.lib, OpenMaya.lib and OpenMayaAnim.lib
  • In the Solution Explorer, remove the MayaImport\Maya4.5 tree (right-click remove), it contains erroneous .lib references, which will confuse the linker later on.
  • Open the file maya_main.cpp and apply the following fixes.
  • Add the <iostream> inclusion to the top of the file (line 1), before precompiled.h:
#include <iostream>
  • The Maya helper #include directives at line 5 should read like this:
//#include "Maya5.0/maya.h"  // comment this line
#include "Maya6.0/maya.h"    // uncomment this one
  • OSPathToRelativepath() function at line 178. Instead of
	if ( base == NULL && strlen(game) > 0 ) {

		base = s = strstr( osPath, game );

		while( s = strstr( s, game ) ) {
			s += strlen( game );
			if ( s[0] == '/' || s[0] == '\\' ) {
				base = s;
			}
		}
	}

the while loop should be protected by a NULL pointer check:

	if ( base == NULL && strlen(game) > 0 ) {

		base = s = (char*)strstr( osPath, game );

		if (s != NULL)
		{
			while( s = strstr( s, game ) ) {
				s += strlen( game );
				if ( s[0] == '/' || s[0] == '\\' ) {
					base = s;
				}
			}
		}
	}
  • You can attempt to compile the MayaImport project, but it will fail due to some const-ness errors. You'll need to fix some const-ness errors to get it to compile:
  • At line 174 the strstr() call needs a char* pointer, so we need to const_cast the incoming osPath:
base = strstr( const_cast<char*>(osPath), BASE_GAMEDIR );
  • The same error in line 179, same fix:
base = s = strstr( const_cast<char*>(osPath), game );
  • Save and the project should compile.
  • The DLL is in the folder: C:\Games\Doom3_SDK\src\ReleaseDLL
  • Copy the DLL to your Doom3 folder and test it.