Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to use assignUVs with an uvSets plug?

Anonymous

How to use assignUVs with an uvSets plug?

Anonymous
Not applicable

As far as i understand, you usually create a uvSet and then call assignUVs to map triangle corners to uvIDs.

 

But uvSets are exposed as a plug, too. When I use the uvSet plug to generate UVs in a node, how do i trigger the assignUVs function of the shape object to (re)assign the uvSet, when the uvSet output from the uvGenerator node changed?

0 Likes
Reply
658 Views
4 Replies
Replies (4)

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

There is an API for this, MFnMesh::assignUVs

 

Yours,

Li

0 Likes

Anonymous
Not applicable
Hello.

I know there is an API, but as far as i understand the concept of
MPxNode, you should not use the maya api inside MPxNode::compute, but
only write data to the MDataBlock object.

When i am not allowed to use assignUVs in the Node, this means i need to
assign them using some connection (which is what I am searching for) or
in a MPxCommand during the creation of the MPxNode (which will not work,
when the node input changes the number of triangles afterwards).

with kind regards,
Alex
0 Likes

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

If you want to modify it in compute, have you tried to write them as a compound?

 

uvSet compound

uvSet.uvSetName string

uvSet.uvSetPoints float2 compound array(uvSet.uvSetPoints.uvSetPointsU uvSet.uvSetPoints.uvSetPointsV)

currentUVSet, string

 

But I guess it should be another node's data? It is not a good idea to modify another node's attribute inside compute.

 

Yours,

Li

0 Likes

Anonymous
Not applicable

I get an inputMesh without any UVs. Then i want to compute UVs and assign them to the inputMesh again, if possible.

Now i can connect outMesh or worldMesh to my node and a uvSet plug from the node to the mesh (it's a cycle, but it shouldn't recurse).

 

The problem is, i do not only need to transfer the uvSet in the compute method, but also need to call assignUVs on the input object for the set to work.

 

The current solution copies the inMesh to an outMesh and assigns UVs when creating the outMesh. I think this is probably not the correct way to do it and way slower than a solution which just copies an uvSet.

 

I will try if this can solved by using a callback like your described in the blog post linked in the other thread.

0 Likes