Maya Exporter - Triangles

Started by
4 comments, last by Jan-Lieuwe 16 years, 4 months ago
I'm writing a Maya exporter for use in an OpenGL app. I've seen many tutorials on how to export geometry from Maya, and they are pretty good, but the problem is that unless the user explicity chooses "Triangulation" from the Polygon menu the geometry can be returned as quads, i.e., 4 vertices. I've looked around but cannot find any way for the Maya API to simply return fully triangulated data. I don't want the user to have to manually triangulate the model. Does anyone know how do do this, or do I have to triangulate polys myself in my exporter (or on import into my app)? Thanks!
Advertisement
www.geometricinformatics.com/userguidemaya.pdf

Didn't actually read it.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Thanks for the reply, but that link is just a Maya tutorial.
Try executing the MEL polyTriangulate command in your plug-in.

E.g. do something like this for each mesh:
MFnMesh fnMesh( dagPath );
MString cmd("polyTriangulate -ch 0 ");
cmd += fnMesh.name();
MGlobal::executeCommand( cmd ); // you may need to pass in a CommandResult here ...

and when you are done just call the "undo" command to restore the meshes to what they were before exporting.
Thanks netrion, I'm going to try that. I also just noticed a couple of methods in MItMeshPolygon - numTriangles, getTriangle and getTriangles that will return triangulated information for a single polygon.
In 3DS Max I had to triangulate the meshes as well during export (and undo it afterwards), but simply selecting the mesh and telling it to triangulate gave wrong results.

I don't know whether Maya has this concept called 'smoothing groups', but in Max I solved the problem by triangulating each smoothing group separately (or something like that).

A vertex that belongs to multiple smoothing groups also has more normals associated with it, so it had to be duplicated during export.

Anyway, not sure if this applies to Maya as well.

This topic is closed to new replies.

Advertisement