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

creating a file node

2 views
Skip to first unread message

pk_pk

unread,
Mar 25, 2008, 7:26:22 PM3/25/08
to
hi,

how can i create a file node using the maya api?

i would like to create a file node which i can assign to a
MFnPhongShader object.

does anyone have any ideas?

thanks,
kanita

aen

unread,
Mar 25, 2008, 8:27:06 PM3/25/08
to
Hi Kanita...
Sorry, but its been over a year since I worked directly with the API.
However if you have not looked for it the:
"....\Autodesk\Maya8.5\devkit\plug-ins" directory, there are a
number of examples of creating and connecting shader networks.
cgfxShaderNode.cpp
checkerShader.cpp

hth's aen

pk_pk

unread,
Mar 26, 2008, 8:05:43 PM3/26/08
to

hi aen,

thanks for that lead. it actually helped out a lot- i was able to make
the file texture node and hook it up to the material. all that remains
is hooking up the MFnPhongShader material to a phong shading group.

thanks!
kp

DTrel

unread,
Mar 26, 2008, 9:42:44 PM3/26/08
to

Glad to help...

Hooking up a shader network basically amount to the properl configuration of the
Dependency Graph (DC) (not the DAG) - dirty node propagation.
There is a very good video intermediate level video tutorial for this;
"Learning Autodesk Maya - Understanding the Maya API - The Dependency Graph"
http://www.creationengine.com/html/p.lasso?p=15143
(copies of this may also be floating around the net?)
At first it seems to be a very simple tutorial, but at the end they give some
practical understanding of API Nodes and Maya Classes (which are weird).

Also... www.highend3d.com has a good API Forum, not very active but they do have
good listing of archived postings. And Highend3d also have some plugins with
full source code, reverse engineering works great.

luck...aen


pk_pk

unread,
Mar 28, 2008, 2:20:54 PM3/28/08
to
On Mar 26, 6:42 pm, DTrel <DT...@blue.nine.org> wrote:
> Also...www.highend3d.comhas a good API Forum, not very active but they do have

> good listing of archived postings. And Highend3d also have some plugins with
> full source code, reverse engineering works great.
>
> luck...aen

Hi Aen,

After I created the shading network, I used the example from here
(http://ewertb.soundlinker.com/api/api.008.htm) to assign the shading
group to my mesh/components:

MStatus MShadingGroup::AssignToShadingGroup(
const MObject & shadingGroup,
const MDagPath & dagPath,
const MObject & component )
{
MStatus status;
MFnSet fnSG( shadingGroup, &status );

if ( fnSG.restriction() != MFnSet::kRenderableOnly )
return MS::kFailure;

status = fnSG.addMember( dagPath, component );
if ( status != MS::kSuccess )
{
cerr << " ! MShadingGroup::assignToShadingGroup could not add Dag/
Component to SG ! " << endl;
}

return status;
}

Although the "addMemeber" line above succeeds, I get the following
error in the script editor window:

// Error: line 5: Cannot add the following items to the set since they
would break the exclusivity constraint: pCube3.f[0] //
// Error: line 5: Cannot add the following items to the set since they
would break the exclusivity constraint: pSphereShape1 //

My parmeters to AssignToShadingGroup are something like (wrote them as
strings for explanation purposes):

shadingGroup: "phong1SG"
dagPath: "pCube3"
component: "pCube3.f[0]"

Do you know why this could be happening? The meshes in my scene
already have some other materials applied so do I need to break the
connection to old materials before assigning new ones?

I thought maybe the way I'm creating my shading engine may be the
problem also. To create the shading group, I had to use the following
mel command (I got this from the script editor when you create a
shading engine using the UI):

MString addShadingEngineToSet = "sets -renderable true -
noSurfaceShader true -empty -name " + phong.name() + "SG";
MGlobal::executeCommand(addShadingEngineToSet, result, false, true);

I'm looking into where I can find the video you suggested.

Thanks for any help!
kanita

aen

unread,
Mar 29, 2008, 4:49:35 AM3/29/08
to

Hey kanita,

I do remember seeing that exact coding before...

http://highend3d.com/boards/lofiversion/index.php/t225882.html

This forum thread has a partial resolution to your problem, its seems to be a
common problem (or Ewerts code is flawed or limited?). To properly understand
the problem you do need an understanding of the API and DG.
http://images.autodesk.com/adsk/files/maya_85_apiwhitepaper.pdf
The AutoDesk API WhitePaper is a downloadable and has the Maya Classes
translated to understandable terminology its a good printable reference. They
also have a list of plugin samples (\Autodesk\MayaXXX\devkit\plug-ins) which you
should be able to run, and modify until they don't work (error message = limits
of the system).
"Understanding the Maya API - The Dependency Graph" is an AutoDesk newbie level
video intro to the API. You may not need this but they do show the common do's
and don'ts for API programming. Personally I find that watching a video tutorial
and taking a few notes really helps in the learning cycle, you can bypass months
of wear, tear and frustration with a video tutorial.

hth's aen...

pk_pk

unread,
Mar 31, 2008, 1:47:31 PM3/31/08
to
> the problem you do need an understanding of the API and DG.http://images.autodesk.com/adsk/files/maya_85_apiwhitepaper.pdf

> The AutoDesk API WhitePaper is a downloadable and has the Maya Classes
> translated to understandable terminology its a good printable reference. They
> also have a list of plugin samples (\Autodesk\MayaXXX\devkit\plug-ins) which you
> should be able to run, and modify until they don't work (error message = limits
> of the system).
> "Understanding the Maya API - The Dependency Graph" is an AutoDesk newbie level
> video intro to the API. You may not need this but they do show the common do's
> and don'ts for API programming. Personally I find that watching a video tutorial
> and taking a few notes really helps in the learning cycle, you can bypass months
> of wear, tear and frustration with a video tutorial.
>
> hth's aen...

thanks for the link aen. i ended up doing what was in the post (i.e.
looping through all the sets and removing the objects from the old
shading group sets). it works now. this is so much easier in script-
but the speed up i'm seeing in my tool is worth it. =)

thanks again!
kanita

0 new messages