Writing Maya/3dsMax import script for custom model file format

Started by
5 comments, last by Kryzon 13 years, 9 months ago
Hello!

I'm not new to programming or 3d modelling, but I'd say that I'm new to scripting in maya/3dsmax because I never touched it before.
I would like to write a script or plugin for either Maya or 3dsMax to import custom model file, how ever I can't seem to find any tutorials or anything on it.
I see so many people writing and releasing scripts and plugins to import 3d models from various games, but yet there are no tutorials...

Could someone please give me some pointers or maybe link me to some tutorials about writing either script or plugin for Maya or 3ds max to import custom 3d model file?

Thanks ;)
Advertisement
not sure about Maya, but for 3D studio max you need an install of 3ds Max 2010 and the included SDK(on the original program disc).

http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=7481355
There some stuff right here in the Gamedev.net Articles about how to write a custom tool outside of maya.

Well I'm asking more about how to write importer for custom 3d model file, not just how to write script. I've had a look at maxscript and it's not hard compared to programming languages like c# or java, but I don't understand how to script it to actually import my custom model file. I've read through maxscripts of several custom model format importers, but I still don't get it, I need someone to explain or show to me :S
Have a look at this document on how to develop a 3ds max C++ plugin: http://ebooks.labkom.org/Graphics%203D/3DSMAX_SDK_DavidLanier.pdf
You need to have the SDK to make one. It is shipped with 3ds max.

assainator
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

Quote:There some stuff right here in the Gamedev.net Articles about how to write a custom tool outside of maya.

Whilst I appreciate that my opinion is extremely biased, I'd actually recommend
this one instead. It goes into a hell of lot more detail about how the nodes and data is organised.

Quote:Original post by edvinas
Well I'm asking more about how to write importer for custom 3d model file, not just how to write script. I've had a look at maxscript and it's not hard compared to programming languages like c# or java, but I don't understand how to script it to actually import my custom model file. I've read through maxscripts of several custom model format importers, but I still don't get it, I need someone to explain or show to me :S


Are you asking how to write an exporter? (i.e. Maya --> custom file) or do you really mean importer? (custom file --> Maya)

There are very few references around for writing importers, but there is a little more info around about exporters. Which ever way you go, writing Maya plug-ins is *way* easier than writing plug-ins for Max. (The Max SDK is bloody awful! The Maya API however is a joy to work with!). Not only that, but my Maya notes above should give you a good head start!

So anyway, writing an importer for either Max or Maya is a royal pain in the ****. I'm going to ignore max for now, since it's only sadists who'd ever want to deal with that piece of crap.

With the Maya API, you are generally going to be looking towards the create methods of the relevant function sets. i.e. MFnMesh, MFnTransform etc. If you can't find a function set for the node type you need, you'll have to drop down to MFnDependencyNode (which will do absolutely everything you'll ever need, however the other functions sets are generally easier if one is available). For most things then, it's a case of create a node, set the parameters, and connect any attributes (aka MPlug's in API speak). BUT!

There are some areas of the API where the function sets are seriously lacking, and you will have to connect up hundreds of attributes in a very explicit pre-defined way. The only way to find out what these connections are is to look at a working example (i.e. create a blendshape network in Maya, see what it's node connections are, and then do the same thing in code). It can be a bit tedious, so what I tend to do is actually call some mel script functions (which will set up the correct connections), and then modify the data from the API (see MGlobal::executeScript). It's a bit tedious, and there are a few GUI related gotcha's (such as materials needing to be created from mel script via the shadingNode command, or the sets command needed to assign materials to polygons). But other than that, it's not too bad. Make sure you Check every single return argument though!

As I said earlier, the Max SDK is a bloody mess. I'd avoid it completely and just use max script to be honest. There are quite a few nasty little undocumented functions that you need to call in the SDK (can't remember the names, but they are called things like InvalidateINodeCache and various other horrors). David Lanier is the guru of the Max SDK, so the forums at dl3d are well worth visiting (when you inevitably get stuck ;) )
Regarding a 3DS Max plugin, I believe it would be best (compatibility-wise) to use MaxScript.
If you're writing for a Max > 4.0, they all pretty much can handle the same script (as long as you're not using a new feature only reserved for the newest, of course).
It's very forward- and backward-compatible.

Reference: http://www.scriptspot.com/3ds-max/tutorials/script-installation-in-3ds-max

EDIT: Forgot to say: as opposed to building your script with the SDK, and having to re-compile your plugin for some different version ranges that have different SDKs.

[Edited by - Kryzon on July 16, 2010 6:49:14 AM]

This topic is closed to new replies.

Advertisement