Game Development Community

dev|Pro Game Development Curriculum

Updated milkshape exporter

by Chris Robertson · 06/19/2004 (4:40 pm) · 257 comments

Last Updated: 12/11/08

Download the new milkshape exporter here.

You must be using at least Milkshape 1.8.3 to use this exporter.

Features:
- Triangle stripper
- Multiple collision meshes
- LOS collision meshes
- Full level of detail control
- Blended animations
- Mesh visibility animation
- Auto-details
- Auto-billboards
- Easy to use sequence/mesh/material property editor

Geometry
Any mesh whos name begins with 'Collision' will be interpreted as a collision mesh. These meshes should have a negative detail level. Any mesh whose name begins with 'LOScol' will be interpreted as a line of sight collision mesh.

LOD
The exporter supports any number of detail levels per mesh. Detail levels are stored as numbers at the end of the mesh name. If your meshes already have numbers at the end of their name, you will need to add a non numerical character at the end, or they will be interpreted as LOD. eg.

body0 will produce a mesh called 'body' with detail level 0
foot12d5 will produce a mesh called 'foot12d' with detail level 5

The original milkshape exporter output shapes with all visible meshes at detail level 0. If you are not making use of LOD, this is the best value to give to visible meshes. Meshes with a negative LOD will be exported but are not visible (eg collision meshes).

Sequences
Sequence special material naming convention has changed, as there is much more information to pack into the name now. Old sequence names are supported, but will be converted to the new convention when you apply changes to the model. All sequence information is now stored in the comment string of the special material.

A '*' at the start of the name indicates that this is a sequence special material

The best way to edit sequences is via the exporter dialog. Just add/select a sequence, then press the Edit button.

Configuration Files
The exporter supports configuration files using the same format as 3dsmax. The configuration file should use the same name as the exported dts shape. eg. use a configuration file called shape.cfg when exporting shape.dts. For most shapes you will not need to use a configuration file, the defaults provided by the exporter will be sufficient.

Documentation
Some alpha documentation is located within the zip file. It is based mostly on the existing 3dsmax/maya documentation and is still a work in progress. If you find any errors, or would like to add something, please feel free to contact me.

Known Issues
- Alpha sorting is supported (in that sorted meshes are passed through the sorting code), but I have not actually seen it working yet. When you view a sorted mesh in the show tool, some of the faces have been split (the poly count goes up), but the faces still appear sorted incorrectly.


I have tried hard to make this exporter fully functional, but it is quite possible that there are still problems with it. I advise you to SAVE your work before you export it, and because the exporter modifies the ms3d file to apply your changes, you should backup your files before using it. If you find something wrong, or even have a suggestion, please let me know.
#101
04/24/2005 (11:01 pm)
@Sean: IFL and DSQ are both working. If you find any bugs in the latest version, either email me directly, or give details here.
#102
04/28/2005 (7:57 am)
I seem to be having some difficulities with collision meshes...I'll investigate more throughly. I'm using some LOD meshes with trailing numbers...and I'm getting the Node to export[Col0], but the actual mesh isn't writing to the dts file. I know, because the ai I'm using needs to search for a collision mesh of the item in question...and they don't ever search for ammo...but when I hack a known collisionable item, it works...odd, because ShowTool has it in the Tree..more later.

My bad; by simply naming a mesh Collision-1[even with the appending -1], didn't produce a correct mesh[produced a mesh of LOD level of 0], I had to manually enter a LOD value of -1, in the dialog; then it worked.
#103
04/28/2005 (8:05 am)
@Rex: Are you "T-Rex" from the gS forums? I'm "EddieRay" over there... and I'm just starting to put 2 and 2 together to get 5 (for very large values of 2)... ;-)

@Chris: Did you write the DTS exporter that comes "stock" with Milkshape 1.7.4 now... or are you working on this as a separate project, or ??? How does your project relate to the code included with TGE in the tools directory... is it a separate project, or are you contributing to that project? Can we get source code for the MS exporter you've been working on, or are you keeping it "closed" for now? Thanks!
#104
04/28/2005 (10:21 am)
=)...
#105
04/28/2005 (10:46 am)
=)...
#106
04/28/2005 (11:53 am)
@Dave: MMEO-R looks pretty sweet! Is it almost finished yet?

I've been trying to use the DTS exporter for gameSpace, which is the modeller I'm most familiar with, but the darn thing just won't work for me for skeletal animation stuff (partly me, partly gS, and partly the exporter at fault here, I'm sure)... and I spend more time (2-3x) futzing with export process than I do actually modelling, rigging, etc. Not good for someone who already has limited "play time", and who actually wants to get some game programming done... ;-)

I recently acquired the nifty "Game Programming All-In-One" book, and that pretty much drove me register Milkshape the first night I had the book, just so I could follow along with the modelling sessions. The DTS exporter for Milkshape seems to be SO easy to use, and just WORKS! Milkshape is very easy to use, in general as well. By the way, is there a way to drag-select vertices for assignment while you're on the Joint tab, but without switching back to the Model tab...?

The other thing I'm going to try is the Blender DTS exporter... I like Blender even though it's steep learning curve has slowed me down - it's got a lot of what I want in terms of basic workflow. I like the fact that the Blender exporters are written in Python and I can tweak them to my needs. My first few tries with the rigging, skinning and animating tutorials with Blender have been very successful... and I like the separate "Pose" mode that keeps you from accidentally repositioning the skeleton or messing up the base pose, etc.

So, basically, I think the path I'm going to try next is from gameSpace (for modelling and texture-mapping) to Milkshape for rigging, animation and export to DTS. gameSpace supports MS3D export, but I don't think that includes bones/joints and vertex assignments. I'll have to poke around and see if there's a way to get the bones/assignments out of gS and into MS.

@Chris: Thank you SO MUCH for working on this! And, please, please, please, make the source available for the exporter so that we may learn from all your experience in writing it!

Thanks everyone!

Ed
#107
04/28/2005 (12:22 pm)
=)...
#108
04/28/2005 (12:36 pm)
Quote:
.....but I'm learning every day (at 45 years old, that's saying something).

I know what you mean, Bruthah! I'm 40, and I'm still learning new things at a rate that my brain should be full in not-too-long... then I guess old knowledge will just start oozing out my ears... ;-)

Quote:
Any app that can model intuitively and export 3DS files would be a better art path than using Milkshape alone. As I said before, Milkshape does do mesh dissecting and skinning pretty well - it's still a bit clunky even for that, but you get used to it I guess.

I'll take that as some good advice. I *think* gS supports 3DS for export... but I'm not sure to what extent.
#109
04/28/2005 (4:27 pm)
Ya, I'm the 'Terrible Lizard' over at gS, EddieRay. I use a combination of gS and milkshape to do my shapes, I've even been able to produce dsq's for a shape I've exported thru GameSpace...:). I've found Chris's exporter to be the best around working with the application. I also noticed some weirdness with dsq's...no matter how I tried I could not cull the Root Node from the shape...while for a dts shape it seems quite possible?? Perhaps something to do with the skinned object, not sure. I found it nearly impossible to work with the Caligari animation system, but managed a degree of success. I managed to get a rigged shape existing in a valid scene with multiple Clips of sequences and exported them all in satisfactory condition. No small feat when dealing with the box of smoke and mirrors...

...and if you can, DigitalDave; prod Chris into producing[for sale, ;), of course] a Milkshape plugin for animation control...:)! I had sent him some snaps of the controllers available in gS and their rudimentary functions/outline and I wonder if he ever looked into it? Something like that is very needed for any developer utilizing Milkshape3D for their modelling pipeline. I've heard many complain about it's animation system; I've always managed it pretty well. It's got it's quirks like all tools. But it does need help in controlling the Nodes during posing. There is a .SMD plugin that gives you the ability to save out portions and shuffle them around, so it is expanding a bit in features...something like this, with a save out feature would be awesome!
#110
04/28/2005 (4:36 pm)
@Rex (and Dave): The LOD problem sounds like an exporter bug. I will look into it.

@Dave: Mr Box should still be ok. It sounds like you just need to reduce the joint size in the milkshape options.

@Ed: The version of exporter that comes with milkshape 1.7.4 is the same as the one in the TGE tools directory. I did not write it, and ms2dtsExporterPlus is an entirely separate project.

It has always been my intention to release the source code, but I want to have the exporter in reasonably stable/finished state first.
#111
04/28/2005 (4:44 pm)
=)...
#112
04/28/2005 (4:45 pm)
I use Joint Size= 0.0120, I think, that's pretty small...for something scaled 1:1 for export to TGE.
#113
04/29/2005 (5:27 am)
=)...
#114
04/29/2005 (10:10 am)
@Rex: Cool... I know what you mean about gS and fighting with it. It always seems to do something "very odd" at some point. I *save* early and often, and spend a lot of time with UNDO and going back to previous saves. I'm still convinced it's a problem caused by gS, me, and the DTS exporter, all in an ongoing "battle". ;-) Once you start skinning and animating your model in gS, it's very easy to get yourself into trouble... that's for sure. And the whole "scale problem"... that's unfortunate. I don't like the Scale Normalizer plugin... that seems to cause inexplicable problems for me in gS when I use it. There's gotta be a better way...
Quote:
I managed to get a rigged shape existing in a valid scene with multiple Clips of sequences and exported them all in satisfactory condition.
Wow... now that's saying something! I'm not at the point where I can consider even *attempting* to try such a bold maneuver yet... ;-) It took me an entire evening just to get a bendy-rod shape from gS to animated DTS... and the export worked, but the shape didn't "bend" correctly (looked like disjoint sections of mesh that moved independently with their bones). I had to hand-assign every vertex to muscles/tendons... the "Attach skin to skeleton" operation worked perfectly fine for gS (everything looked super, animation deformations were perfect, etc.), but the exporter kept balking and saying there were vertices without a proper assignment. Unfortunately, I just can't "ditch" gS altogether, since it has such great capabilities for modelling and texturing (and I like the rigging, skinning and animation in gS a lot too) - it's mainly the scene hierarchy goofiness (can't great a "group" with no members, groups get automatically deleted if there is only one child, etc.) and little odd weirdness that bothers me.

In Milkshape, I made the same "bendy-rod" shape and had it animating in Torque in about an hour... but only that long because I had to learn how joints and vertex assignments work in MS, and how to animate in MS, and had to set up a datablock in Torque to use the new DTS. That brings up a question for Chris... see below...

Anyway... I've gotta get a good "art path" worked out to get things into Milkshape so I can use the beautiful exporter Chris has made. Maybe I can come up with a way to export to .MS3D format (but including bones/joints) so the animation and export could be done in MS.

@Chris: Okay... well, I'm SO glad you've made your own exporter! And thank you, thank you, thank you, in advance, for releasing the source code! It'll be so much easier for people to make tools like this with more solid, working examples to borrow from. One thought... you might want to change the name of your exporter, just to avoid confusion with the TGE "tools" exporter...

Okay, the question that came up: When I assign vertices to joints in MS, it tends to make some undesireable deformations (and I did try some different strategies). For example, for my bendy-rod shape, I had two joints - the upper-arm and the lower-arm kinda thing. I assigned all the vertices *beyond* the elbow to the lower arm to minimize the weird deformation at the joint. Basically, MS doesn't seem to do "vertex weighting" so all assigned vertices rotate completely with the bone... so for the arm, once I got past about 30 degrees or so, the mesh deformation was getting a bit "crinkly". However, the exported DTS seems to not have this issue - it's like the shape really is using true vertex weighting kinda stuff. Is this true? How do you handle this in the exporter? For example, does the exporter find vertices of two different joints that live in the same face and apply weighting to them to give a better deformation around the joints (i.e. where the sets of assigned vertices come together)?

Thanks guys!

Ed
#115
04/29/2005 (10:31 am)
That reminds me... does the MS exporter use a 1:1 scale?
#116
04/29/2005 (11:47 am)
=)...
#117
04/29/2005 (12:26 pm)
I understand what you're describing Dave. It's usually not necessary in gS (at least) to use "helper bones", since the joints themselves can have vertices assigned to them (gS calls these vertices the "tendon", and the vertices that are assigned to the bone are called the "muscle") and that has the general effect of a "helper" bone like you're describing. Actually, given my experience with gS, it seemed a bit odd to me that MS wouldn't let you assign vertices to the *bones*, and potentially assume that the rest were the joint vertices to be blended, or something along those lines.

But what I'm getting at is more the nitty gritty of how TGE seems to be actually using "vertex blending" or "vertex weighting", while MS does not seem to do this at all... and why. I'm not even sure whether DTS format support vertex blending or not... but I don't see any way in MS to assign vertices to be "shared" between bones.

Basically, the DTS model, when loaded and animated in TGE looked to me to have a lot nicer deformation of the mesh around the "elbow" joint than it did when I was making the animation in MS and could see the "crinkle". Actually, I made it sorta ugly in MS on purpose... to see if the DTS would exhibit the same "crinkle"... and it didn't seem to...

Thanks,

Ed
#118
04/29/2005 (3:16 pm)
Okay, here's the gag on Bones/Joints between GameSpace and Milkshape.

In GameSpace; what you see as the rotational driver is the HingeJoint object and what you see as the structure is the Bone Object, the link between a Parent Node and a Child.

If you take this same shape and export it to Milkshape[or DTS, prolly most others accepting bones], some odd things happen, and this is due to Caligari's schema for skinning a mesh and driving it with the rig system. You will find that the function between the two objects has reversed, once things leave the 'GameSpace'. What was a rotator in GameSpace is now a support/link object in Milkshape and the structural element linking the Nodes is now the rotational driver of the vertices....! Without naming your Bone objects in GameSpace uniquely may result in them all being named the same in the finished shape[ms3d for sure, dts, I think?]. I know this is what happens to rigs sent to the Milkfarm. You need to name the BONES objects in gS to get a proper export to Ms3d.

Milkshape's bad deformations are due to it's skinning schema, which is a single bone per vertex, period. Full weighting is produced. Helper bones are indeed needed to get proper deformations. Building/Weighting a shape in GameSpace and exporting it to Ms3d will produce a little better, but not perfect. That's how it goes with Milkshape. Anyhoo, here was some more info on Milkshape/GameSpace/Bones/Joints....hope it helps.

...and I can take a look at scenes causing trouble or needing help to make it into the engine. Just ask anytime.
#119
04/29/2005 (3:54 pm)
=)...
#120
04/29/2005 (4:21 pm)
For selecting verts with a drag while maintaining the joint 'active', try holding Shift while drag-selecting a box in a Ortho Viewport, :).

For selecting verts in the Perspective Viewport, while maintaining the joint 'active', Shift+alt, while draging a box around the desired vertices, careful; sometimes it does some weird out of view selecting too....;).

...all while keeping the Joints Tab active too, BTW...:).