Thanks for checking out a Sponsor below, it really does help!

Export UV mapped & textured meshes from gmax as OBJ formatted models

Exporting models from Gmax as OBJ meshes

Gmax has always been limited in terms where content created with it ends up, after all it's designed purpose was as a freely available 'mod' tool that would allow users the ability to create content for their favourite games, exported out using various "game packs" written specifically for that purpose.

What this meant for gmax as a general 3D modeling tool was that content could not normally be exported or saved out of the application without the use of an appropriate gamepack.

However, there are a number of ways this limitation can be worked around without the need to hack or reverse engineer gmax (which you shouldn't be doing anyway *cough*); this tutorial discusses one such process, namely, how to export meshes from gmax as OBJ models (the other is discussed here).

exporting gmax to OBJ requirements? ^

The only items needed to export models out from gmax as OBJ files are gmax v1.2 and one of the various gmax to OBJ scripts available on the Internet (see resources above), once installed open gmax then work on or load a model (read accompanying instructions on how to install both gmax and the OBJ Max scripts).

Prepping the model in gmax for export ^

Shown below is the model used throughout this tutorial, a simple low resolution model of a W.W.II British Churchill tank, it has two basic materials simply to help distinguish mesh sections but no textures assigned to those materials. Its also not been UVW unwrapped so has no UVW map - the reason for this is because not all the available OBJ exporters export clean UVW maps, material or texture information, so when exporting a mesh that has been properly prepped be aware that only the raw mesh data may be exported.

Make sure also, that all the objects to be exported are "Editable mesh" objects, so "Boolean's", "splines" and other types of object must be converted into a 'mesh' before exporting. You may also need to "collapse the stack" so any modifiers are applied to the mesh and check mesh groups - groups of objects may need to be ungrouped and broken back down to their original state. If these operations are not done the script will likely error out when run.

Model of a W.W.II British Churchill tank modelled and ready to be exported

Model of a W.W.II British Churchill tank modeled and ready to be exported

MAXscript Listener and gmax ^

Much of the work to do with the process of getting meshes out from gmax to the OBJ format goes on within the MAXscript Listener window, this is where all the 3D data from the scene or selected objects is output by the (various) gmax2obj script ready for the next stage.

HOW TO : open the MAXscript Listener

By default when starting gmax the "Create" panel will be active on the right hand side (if using the default interface configuration), showing an icon with an 'pointer' and 'star' - as shown below on the left of the row of icons.

gmax panel icons

To get to the MAXscript Listener the "Utilities" panel needs to be active. To do this click the "hammer" icon on the right (as shown above), the panel should change. Click the button titled "MAXscript", the listener window will then open.

Note : the listener may open with some text already present, simply select all (Ctrl+A) and delete.

Opening gmax's "MAXscript Listener" window from the "Utilities" panel

Opening gmax's "MAXscript Listener" window from the "Utilities" panel (the hammer icon) - note the default text that appears as a result of the gmax to obj script loading during start-up

Running Max scripts in Gmax ^

Before doing this next step in the process, in the 3D view port select the sections of the mesh that need to be exported, else the script may export the entire contents of the scene, even if that's not what's needed. As mentioned above, a script is used to instruct gmax to parse scene data, this automatically runs once the *.ms file is selected and loaded via the MAXscript Listener window, which in this instance outputs text - the amount of text and time it takes to process varies depending on the complexity of the model being exported.

HOW TO : run scripts from the MAXscript Listener

Note : If not already done, at this point it's best to select and delete any text that may have been present when the listener window opened.

In the Listener, go to "File >> Run Script..." and browse to the location where the script was installed (usually ..\gmax\scripts\startup\), select the script and click "Open", the script will load and gmax will automatically parse the scene or selected objects, writing text to the window.

Running a script from the Listener window

Running a script from the Listener window

Locating the *.ms Maxscript to run

Locating the *.ms Maxscript to run

Output after script has run, in this case 'obj' formatted text

Output after script has run, in this case 'obj' formatted text

The end of output

The end of output

Select, copy & pasting parsed data ^

Now that there is some content in the Listener, it needs to be copied into a text document. Because output can produce a lot of text it's often best to "cut" rather than "copy" the content; the reason for this is that gmax's Listener window only supports a limited amount of text being grabbed at any one time which often results in having to copy the contents in several parts; longer files increase the chance of your place being lost as content is 'copied', as 'cutting' removes the text it's easier to see exactly what remains and where it starts/ends.

HOW TO : cutting and pasting Listener text

To save confusion start from the top and work down, so scroll up and/or click near the top of the text and "Select All" using Ctrl+A, the cursor will jump to the last segment of text to be selected. 'Cut' the selected text with Ctrl+X, which will remove it from the Listener window to hold it in memory.

Open Notepad or other plain text editor (Crimson Editor etc.) and paste the cut text using Ctrl+V, which will appear in the new document. Repeat until all the text has been cut from the Listener window and pasted into the text document - make sure the cursor is placed at exactly the right place in the new text file to make sure the cut text follows on correctly otherwise the resulting file may be corrupted.

Selecting all of the Listener output

Selecting all of the Listener output

Pasting cut (or copied) Listener text into an open *.tat file

Pasting cut (or copied) Listener text into an open *.tat file

Save new document as *.obj ^

Once all the text has been pasted into the new text document it's then a simply matter of saving the file with the appropriate file extension; as the OBJ format is text based nothing further or 'special' needs to be done to the file in terms of compiling or processing it other than what is copied from the Listener window.

HOW TO : saving the text document as a file with the *.obj

If this is a new file click "File >> Save" to open the save browser. Browse to where the file needs to be saved then in the "Save as type" field select "All Files (*.*)"; this ensures that Windows doesn't 'force write' *.txt after the file (or whatever the default file extension is for the application being used as a text editor).

Design note: if "Save as type" isn't set to "All Files" Windows will append ".txt" after the file regardless as to what 'custom' extension is written. Additionally, if the file was already created as a *.txt file (it was double clicked to open from Windows Explorer, et-al) use "File >> Save As..." instead of "Save"

Once done type the name of file, then type ".obj" after it; for example, instead of "gmax_export.txt" type, "gmax_export.obj" - this forces the file to be saved as a *.obj file. That's it. On saving this will create a proper OBJ model file from the data cut from the gmax's MAXscript Listener.

Design note: the very top two lines of text from the Listener output should be removed when saving the file to make sure 'bad format' errors don't occur when importing the *.obj file into other 3D applications. In the example below, showing the top section of the copied Listener text, delete from the start, "Copy and paste...", to the very end after "... as a .obj file.".

Copy and paste the following lines into a text editor, and save them as a .obj file.
# -----------------
# Start of obj file
mtllib Unnamed.mtl
g Box01
usemtl Mtl #0:Standard
v -8.56909 -0.738508 16.041
v -8.56909 3.90634 16.041
v -8.56909 -0.738508 24.041
v -8.56909 3.90634 24.041
v 8.43091 -0.738508 16.041
v 8.91269 3.90634 16.041
v .....
Saving the text file

Saving the text file

Renaming by using "Save As..." to save the text file as *.obj instead of *.txt as it was previously

Renaming by using "Save As..." to save the text file as *.obj instead of *.txt as it was previously

Conclusion: import OBJ into other 3D applications ^

In order to get the OBJ file into another 3D application, that program will obviously need to be able to import *.obj formatted data. Failing that, the OBJ will need to be converted to another format that can be imported - if a file converter isn't available Blender 3D can be used to import the OBJ which can then be exported back out to a different format; *.dxf or *.3ds for example.

The gmax exported *.obj file of the Churchill tank model imported into Blender 3D, uvw mapped, materialed and textured

The gmax exported *.obj file of the Churchill tank model imported into Blender 3D, UVW mapped, materialed and textured

UVW map of the Churchill tank after import and clean-up

UVW map of the Churchill tank after import and clean-up

KatsBits Web
Search KatsBits using StartPage