Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Forcing triangulation of mesh in MAYA Plugin

128 views
Skip to first unread message

Bernhard Glück

unread,
Jan 11, 2002, 2:01:58 PM1/11/02
to
Hi !

I am writing a MAYA Exporter plugin, that exports all mesh nodes (
polygonal shapes ) of a scene to a propreiatary mesh format, used by a
game graphics engine.

I get all the MFnMesh nodes and then want to write out the data.
However all
objects seem to consist out of quads and not triangles but i need
triangles so
that i can later calculate triangle strips out of them to speed up
rendering in realtime. I can't put my own algorithm , because i need
the EDGE data of a given mesh too ( to aid shadow volume calculation )

So HOW can i force the triangulation ( like Polygon->Triangulate )
from my C++ Plugin ? I don't want to have the artist to have to
triangulate manually ? Is there a way to do this with a given
MFnMesh..

Another problem I walk the DAG, and i seem to get TWO Mesh objects for
any Polygon mesh... here is my DAG walk code:


MStatus exportIrisBrush::doIt( const MArgList& args )
//
// Description:
// implements the MEL exportIrisBrush command.
//
// Arguments:
// args - the argument list that was passes to the command from MEL
//
// Return Value:
// MS::kSuccess - command succeeded
// MS::kFailure - command failed (returning this value will cause the
// MEL script that is being run to terminate
unless the
// error is caught using a "catch" statement.
//
{
MStatus status = MS::kSuccess;

// Create a Dag iterator
MItDag dagIterator;
cout << "Starting the Dag walk ...\n\n";

// Walk the Dag
for ( ; !dagIterator.isDone(); dagIterator.next() )
{
// Get the path to the node
MDagPath dagPath;
status = dagIterator.getPath( dagPath );

// Create Dag node
MFnDagNode dagNode( dagPath,&status );

// Output debug info
cout << "Node: " << dagNode.name().asChar() << "\n";
cout << "Path: " << dagPath.fullPathName().asChar() << "\n";

// Check if we have a mesh node
if (dagPath.hasFn(MFn::kMesh))
{
MFnMesh mesh ( dagPath );

exportMesh ( mesh );
}

cout << "\n\n";
}


// Since this class is derived off of MPxCommand, you can use the
// inherited methods to return values and set error messages
setResult( "exportIrisBrush command executed!\n" );

return status;
}

so when i create a Polygonal sphere i get a MESH node for it twice !!
PfnSpher and PfnSphereShape ??? How can i avoid this ?


Thanks in advance
Bernhard Glück

Anim8life

unread,
Jan 11, 2002, 2:48:17 PM1/11/02
to

>
>I get all the MFnMesh nodes and then want to write out the data.
>However all
>objects seem to consist out of quads and not triangles but i need
>triangles

You can tessellate to either quads or triangles...I currently do this for an
rtg export that I'm doing for a game import.


>Another problem I walk the DAG, and i seem to get TWO Mesh objects for
>any Polygon mesh..

there is are 2 nodes/components per object...a "transforms" and a "shape" node
(me thinks I have the terminology right)...


Bernhard Glück

unread,
Jan 11, 2002, 7:51:57 PM1/11/02
to
grif...@aol.com (Anim8life) wrote in message news:<20020111144817...@mb-mq.aol.com>...

> >
> >I get all the MFnMesh nodes and then want to write out the data.
> >However all
> >objects seem to consist out of quads and not triangles but i need
> >triangles
>
> You can tessellate to either quads or triangles...I currently do this for an
> rtg export that I'm doing for a game import.
I knew that, i just asked how i can tesselate to triangles from within
my PLUGIN ... I know how to do it in MAYA itself ( using MEL or the UI
)

>
>
> >Another problem I walk the DAG, and i seem to get TWO Mesh objects for
> >any Polygon mesh..
>
> there is are 2 nodes/components per object...a "transforms" and a "shape" node
> (me thinks I have the terminology right)...

Hm ok that i understood too, but why do both objects support the
MFnMesh Interface ? I mean When one is the transform .. ok but it
should not support the MFnMesh interfaces since it has no mesh .....
How should i distinguis between the two ?

Bernhard Glück

unread,
Jan 12, 2002, 12:32:15 PM1/12/02
to
Addendum question:


Is there also a way to convert NON MESH nodes ( like NURBS surfaces or
Paint Effects ) to polygonal ones with the MAYA API ? (C++ not MEL
please )

And are all MESH nodes stored as quads ? Because if yes i can do the
triangulation myself ..... otherwise the same question as before
persists...

0 new messages