pouët.net

Help with exporting a skinned and smoothed mesh from 3ds max

category: general [glöplog]
 
BB Image

I have a mesh in 3ds max with a skin modifier and a turbosmooth modifier on top, so I can work with as few vertices as possible.
The problem is when I want to export the mesh, I can get the mesh in its smoothed state by using the GetTriObjectFromNode function, but when I get the skinning information its ofcourse only bones and weights for the vertices in the low poly mesh, as the skin modifier is below in the modifier stack.
I guess 3ds max does smoothing of both the vertices and weights, as the object bends very nicely when increasing the iterations of the smoothing, but if I export the smoothed mesh and just copy the bones and weights from the closest vertex with bones assigned I get ugly sharp edges, and if I do the extra work of skinning the mesh in its smoothed form I get smooth bends when exporting.

So, is there any clever way to get bones and weights assignment for all vertices, with as little work as possible?

How are animated meshes stored and handled in 64k intros?
added on the 2009-01-28 20:55:12 by hollowman hollowman
I doubt they are exported from max... But I'm no expert on this issue.
added on the 2009-01-28 22:01:12 by kelsey kelsey
you need to find out how the weights are calculated for the inbetweens, unfortunately that's tough in 3dsmax but you could see if blender does it in a nice way and copy theirs :-)
added on the 2009-01-28 22:10:06 by thec thec
cant you bloody ask smash, i reckon he's an expert about now in that area.. but usually you save a lowpoly mesh (preferably even just one side) as data and do the (symmetry+)meshsmoothing afterwards in code, not 3dsmax.

also weighting, vertexpainting and all that mumbojumbo is not favourable at all for a 64k. Recycle the mesh by cutting parts of the original mesh and use THAT as animation reference rather than a bloated bone system.
added on the 2009-01-28 22:21:54 by Maali Maali
"expert about that by now"
added on the 2009-01-28 22:22:21 by Maali Maali
and as for the exporting thing, might be an exporter issue if it works nicely inside 3dsmax itself.
added on the 2009-01-28 22:27:39 by Maali Maali
just collapse the mesh in the exporter ? you can do undo it when exporting is finished.
added on the 2009-01-28 22:32:51 by pantaloon pantaloon
pantaloon: Looks like he's exporting the bones as well.

Anyway AFAIK the TurboSmooth on top of the stack shouldn't create new points with weights and then reevaluate the skin modifier. Rather, it'll smooth the low-poly mesh after it's been mapped to the bones (and all weights etc. already discarded). To get the same result in your engine you'd do the same, i.e. export the low-poly mesh and use that for skinning, then do a smooth on the resulting mesh once per frame.

Or, try to interpolate the weights meaningfully instead of just copying the weight from the nearest vertex with a weight. E.g. interpolate between the two nearest weights based on distance. I think with TurboSmooth every added vertex should divide an edge between two of the original vertices. So every vertex should either have a weight or be on exactly two edges leading up to a vertex with a weight (then just use the average of those two).
added on the 2009-01-29 02:44:22 by doomdoom doomdoom
kelsey, and I doubt they are stored in the resolution they are displayed in, thats why I am curious how they are handled, how the smoothing is done and so on.

thec, the source code for the smoothing modifiers doesnt seem to be included in max sdk, but I guess they use Catmull–Clark algorithm. Still I am not sure what they do with the weights, the coloring makes it looks like the weights are smeared out, but thats just presentation, it probably is like doom says, that the smoothing is only done on the vertex coordinates after the skin modifier has done its thing

maali, ofcourse its an exporter issue, as I am writing the exporter plugin myself ;) If I ask here, hopefully smash drops by and gives hints that can be interesting for more people to read, instead if I just "bloody" ask him in private.

doom, I was hoping to avoid having to do the interpolation myself, but perhaps its the only way
added on the 2009-01-29 10:10:27 by hollowman hollowman
as doom said, if you put the smooth on top of the skin it'll skin the vertices and then smooth the mesh afterwards as if it were static.

the way i handle this is:
- export the low poly mesh (erm.. or half the low poly mesh) and bone weights.. this varies - sometimes we regenerate the bone weights using closest bone (to low poly mesh vertex) or a better scheme using a combination of that and walking across neighbouring vertices, so you dont get the situation where knee bones affect the other leg and so on. and sometimes we store it - usually just 1 bone index per vertex, which is usually just a 4 bit value and compresses well enough.
- you can use some clever packing technique to compress the vertex and index data - check out e.g. edgebreaker.
- at runtime i skin in the vertex shader not on cpu, so i need a final smoothed mesh before skinning. its a lot faster on modern graphics hardware to do it like this and keep the vertex buffers static.
- mesh smooth both the vertex positions and the weights/indices. weights can be smoothed using the same scheme as the positions, as doom said. if you produce a vertex on an edge created by two vertices with different bone indices, you add all the bone indices to the new vertex and smooth the weights - so you can quickly go from one weight per vertex to several. you need to be able to handle that.

3d packages use different smoothing routines, but catmull clark is pretty common - if its not the package default already, you can often get it to use that scheme instead. then it's easy to match using your own code if thats what you want to do. if you are going to do this, keep in mind you might well need to preserve the original polygons, not convert to triangles, to get the right result. (but hey, it can be smaller :) )

hollow: if you need anything give me a shout. :)
added on the 2009-01-29 10:34:38 by smash smash
(when i said i export the vertices and bone weights, i meant i export the vertices and the _bone index_ - ensuring that 1 bone per low-poly-mesh vertex is sufficient )
added on the 2009-01-29 10:36:16 by smash smash
Thanks for the info =)
added on the 2009-01-29 20:12:53 by hollowman hollowman

login