I'm writing a simple Maya (6.0) exporter using the Maya API (following a tutorial on GameDev.net) and I've managed to extract vertices and polygons all ok so but I'm really struggling getting the texture filenames (and there isn't much on the web about the API). Anyone here have experience with the Maya API?
My exact problem: I've found the material that I want and then I've found the color plug for that but when I ask it if its a fileTexture it says no (printing out its API type gave me kAttribute3Float). Now I'm sure that the material is connected to a fileTexture node in Maya so why does it give me this???
Relevant code snippet:
srcNode is a the Lambert shader that I want.
"if( src.hasFn( MFn::kFileTexture ) )" is what fails although it really shouldn't.
There are a few things left that I can try to get this thing to work but maybe someone here has worked with the Maya API and has some idea what is going on (or not).
My exact problem: I've found the material that I want and then I've found the color plug for that but when I ask it if its a fileTexture it says no (printing out its API type gave me kAttribute3Float). Now I'm sure that the material is connected to a fileTexture node in Maya so why does it give me this???
Relevant code snippet:
Code:
MFnDependencyNode fnDependNode( srcNode );
MPlug plug = fnDependNode.findPlug( MString( "color" ), &stat );
if( stat )
{
MPlugArray cc;
plug.connectedTo( cc, true , false );
if ( cc.length() == 1 )
{
// As a destination there can be only one source.
MObject src = cc[0];
// Is it a file texture?
if( src.hasFn( MFn::kFileTexture ) )
{
MFnDependencyNode fnFile( src );
MPlug ftnPlug = fnFile.findPlug( MString( "fileTextureName" ), &stat );
if( stat )
{
MString fileTextureName;
ftnPlug.getValue( fileTextureName );
cout << "Texture: " << fileTextureName.asChar() << endl;
}
else
{
cout << "Couldn't connect to tex_name plug to get filetexture." << endl;
}
}
"if( src.hasFn( MFn::kFileTexture ) )" is what fails although it really shouldn't.
There are a few things left that I can try to get this thing to work but maybe someone here has worked with the Maya API and has some idea what is going on (or not).