Hi,
ok, I am quite new to writing Plugins for Maya and now I am stuck: I am currently writing an exporter for Polygon-Meshes. Exporting the Vertices and so on is no problem, but I don
Hi,
ok, I am quite new to writing Plugins for Maya and now I am stuck: I am currently writing an exporter for Polygon-Meshes. Exporting the Vertices and so on is no problem, but I don
search for getConnectedShaders or getConnectedSetsAndMembers on this forum. You should find several postings with source code.
g-
Thanks, that helped a lot. However, I still wonder how to find out which Filetexture is connected to which Colorchannel.
Any ideas
Michael
This is the way I do it, (More or less, doing this from memory so you might have to check a couple of things, but it should be more or less correct)
// obj is the MObject representing the shader....
MFnDependecyNode fnDep( obj );
// get the attribute plug
MPlug colorPlug = fnDep.findPlug( "color" );
MPlugArray connections;
MString filename;
colorPlug.connectedTo( connections,true,true );
// check each connection for a file texture.
for( unsigned int i=0;i (less than)connections.length();i++)
{
// get the node of this connection - replace squiggly brackets with suare ones (arrrgggh html)
MObject node = connections{i}.node();
// is it a file texture node?
if( node.apiType == MFn::kFileTexture )
{
MFnDependencyNode fnNode( node );
// find the fileTextureName attribute
MPlug fileNamePlug = fnNode.findPlug("ftn");
// get the filename
fileNamePlug.getValue( filename );
// stop looping
break;
}
}
// if you've got Maya 4.01, you can go on and use MImage to get the texture data...
MImag image;
unsigned int width,height,depth;
// load texture file
image.readFromFile( filename );
// get texture dimensions
image.getSize( width, height );
// get bytes per pixel.
depth = image.depth;
// alwas 32bit RGBA, no matter what the depth is (annoyingly)
unsigned char *pData = image.pixels;
// do something
// release image data
image.release();
// sorry about the less than sign thing, cant put it in cos of annoying html tags
Thanks, I will try it out soon.
Michael