|
I don’t have a ready-made example of exactly what you are trying to do, but making a basic shader is easy:
string $sName = `shadingNode -asShader "lambert" -n MyShader`;
You can mix MEL in with your C++ using MGlobal::executeCommand().
I believe the part you need that I don’t have handy would use createNode() to create the file node and you would use connectAttr() to hook the nodes up. Just look in the hyperShade (or better yet, if you have it, the new Node Editor) to see the needed connections.
To complete the task of putting the shader on your mesh object you can use
sets -e -fe $sName "myObjectName"
Given the edit/compile/copy/test cycle time involved in C development, I would think it would be most efficient to prototype this in MEL (or python) by putting it all in a file and loading that and executing it. If you want to later make an all-C++ single-file solution you would then have a working outline of what needs done. Given the speed of most machines, MEL is actually not a bad solution for things like this, but you cannot get access to most of what you need to really do a good job making anything but simple meshes without using the API (C++ or python).
I don’t know what your tool needs are, I have buried MEL code like that in a translator plug-in, which integrates into Maya using load/save/import/export/export all. I have also written MPxCommand plug-ins in which I created a new MEL command that used “-” flags to load or save a private format of mesh parts as a pipeline tool. On that project, I used a lot of MEL, which made shelf buttons, assigned shaders and so on, but the low-level meshFn stuff was all done in C. That give great flexibility because most of the scope creep (gee, what if I added...) was all able to be done in MEL.
<* Wes *>
|