Mesh texturing?

Mesh texturing?

Anonymous
Not applicable
443 Views
1 Reply
Message 1 of 2

Mesh texturing?

Anonymous
Not applicable
Hello everybody,

For a study project, I have to create a plugin which loads a mesh (OBJ), and change the texture image file (which is stored on the disk, PNG files) several times, in relation with the current time in the timeline.
But my problem is, how to apply a texture to a mesh?

I know I have to do several steps :
- Create a blinn shader,
- Get the "surfaceShader" attribute from my mesh,
- Connect the Blinn "outColor" attribute to the Mesh "surfaceShader" attribute,
- Create a file node,
- Set the file node "fileTextureName" attribute to the image path,
- And connect the file node "outColor" attribute to the Blinn "color" attribute.

But I don't know how to do this with the API (C++ for my project).

First problem :
When I do the first connection (material outColor -> mesh surfaceShader), the MDGModifier::connect function returns MStatus::kSuccess, but when I call the MDGModifier::doIt (just after), it returns kFailure.

And second problem:
How to create a file node?

Thanks a lot for your attention!

Romuuu
0 Likes
444 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

sorry for 9 years to reply it

 

here is my thread ,the same problem like yours

https://forums.autodesk.com/t5/maya-programming/material-outcolor-gt-surfaceshader-fail-bug-or-somet...

 

The problem one :

 

i found the reason, before connect it,you should break it first!!!!!!

 

the param of -F in MEL ,just help you break it first..... 

 

// break it
MPlugArray mpa;
destPlug1.connectedTo(mpa, true, false);
if (status != MS::kSuccess)
{
cerr << " find connect fail " << endl;
}
else {
cout << "find connect" << endl;
}

status = dgMod1.disconnect(mpa[0], destPlug1);
if (status != MS::kSuccess)
{
cerr << " disconnect failed " << endl;
}

0 Likes