View Full Version : Need some help with GroupIDs and GroupParts
02-27-2009, 08:10 PM
I've recently been tasked with creating a new mesh modifier node. I've got the core functionality working already, but i'm having difficulty transferring the material assignments correctly.
Looking at the DG and help docs I read up on groupID and groupParts, but I'm still kind unsure about the role they play with regards to material assignments. Under what circumstances do these get created, modified, and why are they here? What kinds of data do they hold?
I'm looking for some more practical explanations of how this works, as well as some general tips for how to preserve the assignments through the history to the new final outmesh. Thanks in advance!
03-02-2009, 06:41 PM
groupIDs and groupParts are pretty confusing. They're used to handle component-level shading in Maya. Somebody posted earlier asking how to handle component-level shading via the API before. I posted a response that might shed some more details on it here:
http://forums.cgsociety.org/showthread.php?f=89&t=663397 (this was a 2nd thread requesting similar functionality)
For the most part you shouldn't need to deal with groupParts. groupIDs however you will need as any new component group you create requires a unique groupID (which currently can only be obtained via a groupId node). I'm not sure what level of access your modifier node needs to transfer shading assignments, but you should be able to read it from your input meshData (MFnMeshData).
The actual methods to read in the component-group data is actually inherited from its parent MFnGeometryData. From that interface you should be able to read the objectGroups and the MFnComponent from the objectGroup (and ultimately the component indices necessary to recreate the indices downstream).
Hope this helps!
03-03-2009, 07:01 PM
Sweet! This helps a bit, yes. This is my understanding so far...
An object group contains indices of particular types of components (verts, faces, etc). These groups are connected in the DG and help to tell sets and SGs what components belong in a set.
Looking at some other plug-ins, I've found that normally, you would do the following in the compute method:
// Iterate through the groups...
// for (id=0; id < meshDataFn.objectGroupCount(); id++)...
compId = meshDataFn.objectGroup(id) // Get the compId of the id'th in the sequence
// Get the compoent elements...
// Iterate through the elements (comps), add your new faces
// Create a new object group with your components, compType
So I'm wondering, how do I know what new components should belong to which component group to be added? Would the solution be to build some sort of lookup table (old faces to new faces) and add those (that would suck, since the 3rd party lib i'm using for the modification only understands verts, edges, faces, and normals)?
Thanks again for your help!
03-03-2009, 08:57 PM
Yep your understanding of the groups is correct as is your code snippet. That is how you would retrieve the indices.
As far as remapping... That's a good question. So if I understand you correctly, your modifier node is piping the source mesh data into the 3rd party lib which then outputs a resulting mesh?
That'd be a tough one. I can't think of a way to cross reference the data. If you were using MFnMesh::create() at the very least you could define the face index order yourself. Do you know any details about how the 3rd party lib operates in the input mesh? Alternatively you could do a post operation to try to best fit the shading groups back onto the original mesh via some mesh compare. That's probably a lot more work than you want though. What it boils down to really is your 3rd party lib and what info you can glean from that to help the remapping process.
Perhaps the 3rd party lib supports some form of blind data for which you could tag faceIDs to the original data prior to the modification?
03-03-2009, 11:23 PM
Awesome. I think i found something in the 3rd party lib that lets me associate new faces with old.
Everything seems to be working so far, now I'm trying to ensure the node is hooked up correctly in the DG for everything to come through (looking at the PolyModifierCmd stuff). Thanks for your help!
03-03-2009, 11:23 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.