Finding all Textures
in a Scene
Maya has some fairly nice little tricks when dealing with textures.
Essentially we have to build a list of all MFn::kFileTexture nodes.
We could simply write out the full path names of the textures
to the exported file. Alternatively we can make use of the maya
class MImage to access the image data directly.
For the purposes of this example, i have described both methods.
To find the filename of the applied texture, you have to access
the fileTextureName (ftn) attribute of the file texture node.
This string attribute will hold the full path for the texture
file.
The second half of the function then writes all of the texture
files to a custom texture pack. MImage is used to read the texture
data from the file node. The width, height and byte depth are
then written to the file.
It is worth mentioning that MImage also allows you to resize
image files. It may therefore be a good idea to ensure, that the
width and height of the image are both powers of two.
|