Jump to content
  • Advertisement
Sign in to follow this  
iterator

OpenGL Maya Exporter - Triangles

This topic is 3968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!