3DS Max SDK for games development As part of our new graphics engine for our game I've been researching about writing max4 exporter plugins for a skeletal animation system and for the world format. I'll be sharing a lot of my new found knowledge here. Why? Because I'm such a nice guy :-)
Quick Links Getting Started Sample code Skeletal animation World format External tutorials Open Source Projects
Where to begin? There are numerous approaches to developing a 3dsmax exporter. Listed below are some of the open source projects aimed at making the task simpler. By all means, take a look at those, but if you want to create a really good file format, then you will need a good understanding of the max sdk, and that means spending a long time reading though the max sdk help files. So if you think you are ready to begin coding an exporter, there are two ways to start up your VC++ project; you could read "Plug-In Project" in the max sdk for instructions on how to set it a VC++ max plugin project, and code from scratch, or follow the "Using the Appwizard" and "first coding steps" instructions to get started the easy way. A word of caution, don't go blindly rushing to do your exporter before you've got a good idea of what you want to be exporting. Suppose you are doing a skeletal animation format. Some things to consider before starting: Is the artist using Character Studio or just 3D Studio Max? If the artist is using Character Studio, is (s)he using physique or just biped? How many bones will the artist use per character? What sort of textures do you want? Do you need to support animated textures? How about bump and specular textures? Information about creating bump maps is here
Using the Appwizard
3D Studio MAX Plugin AppWizard R4.0 can be found in the directory \3dsmax4\maxsdk\Help\SDKAPWZ It is used for creating skeleton code for developing various types of plugins. Copy SDKAPWZ.awx file into your Visual Studio directory, e.g. C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin\IDE Run Visual C++ and click new. The appwizard will appear in the list of options. On step 1 of 3, click "File Export" On step 2 of 3, type exporter in the Plugin category On step 3 of 3, find the paths that you want to use and then the appwizard creates the skeleton code for you.
First coding steps On line 116, below the line that says "Return the 'i-th' file name extension (i.e. "3DS")", type in the filename extension you want to use for your format (between the quotes) Go down filling in the relevant text whenever you see: return _T(""); Click Build in the menu, and build the .dle file Copy the file to your 3dsmax plugins directory and load up 3dsmax Load up a max file and click export. You filename extension should be listed, select it. You will see the following window:
The export fails because you need to write more code before it exports anything. We'll come back to this soon, but right now you are probably wondering...
How does the skeleton code work?
First lets take a look at DllEntry.cpp - it provides a number of functions that every max plug-in must provide. Read the page "DLL, Library Functions, and Class Descriptors" in the max sdk help file. The DLL and library functions described match the functions shown in DllEntry.cpp. The Class Descriptor described matches the function near the top of the main .cpp file (your exporter name.cpp)
How do I get it to export something? The bottom function in the main .cpp file is of the form: int YourExporterName::DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts, DWORD options) Write your export code in that function
Sample Code The source code to the 3DS exporter is located in 3dsmax4\maxsdk\Samples\ImpExp The Direct3D exporters are downloadable here. It includes the source code for both max3 and max4 exporters. The book "Game Programming Gem 2" contains the source code to a 3ds max skin exporter and animation toolkit (for max3 and character studio 2.2) Cal3D, the free skeletal animation library, includes the exporter source code
Skeletal animation: Vertex Shader Matrix Palette Skinning This section is about design considerations for a skeletal animation system, specifically an animation system using vertex shaders. One of the best sources of information on this is nvidia's paper Efficient Animation, which argues that VS matrix palette skinning is the best way to do character animation in directx8. If you want to do your own VS skinning you should read the entire article, but one of the important points is the limit on the number of bones in the mesh; limited memory on the GeForce 3 means the maximum is 32 (for 4x3 matrices) or 24 (for 4x4 matrices). You need to decide whether or not you want to support weighted vertices, i.e. vertices are influenced by (the average of) more than one bone's movement. Supporting this may result in smoother, more realistic animation, but the implementation is more complex.
World/Level file format The .3ds format is a good place to start. I'll be writing more on this soon.
External max sdk tutorials From 3D Studio MAX to Direct 3D: Introduction to Plugin Development, Part 1 From 3D Studio MAX to Direct 3D: Introduction to Plugin Development, Part 2 How to fix and recompile the 3ds max DX 8.1 SDK Exporter Exporting an .X File With 3ds Max 3 or 4 Using the DX SDK Exporter
Open Source Projects to assist plugin development Freexporter Flexporter Lib3ds
Discreet Knowledgebase A library of 3DS Max info is available here
Back to... 3ds max page Modeling and animation packages page Main index page Last updated: 22nd September 2002 http://www.cyberloonies.com/3dsmax-sdk.html