We are exporting thinking particles data from max to maya using xmesh.
When bringing the object into maya, all groupId nodes and shadergroups are properly connected, however the group components are not defined in the mesh… so none of the materials are actually assigned to any faces.
Any ideas? I thought this was working, as we have used this before, but this is a changing topology cache, which might upset the system… We are rendering out of maya for this high priority show, and if we cant get xmesh to work, we will have to reshade these assets in max asap. (the show comes on air in about 3 weeks, so we dont have a lot of time to figure out a fix)
I think we found the issue. The matIDmap file that was generated on export does not have an entry for all the material IDs that the mesh is using. It only lists the IDs for what the multi sub material had, instead of the IDs that the topology has.
This is bad, because this means that the consistency of the topology export/import (the material ID metadata of the faces) depends on the shading of the object. Ideally, the matIDmap would have ‘default’ entries for any/all material IDs that don’t have a corresponding material for them. That way the component information is not lost when importing into maya.
The current export functions in max provide ways to clear and set the material ID mapping. Is there also a way to query the accumulated mapping information? That would allow us to write a matIDmap file with the appropriate number of IDs.
The first thing that comes to mind is we could make a utility that reads an xmesh sequence, and writes a matIDmap file with a stand-in material for every material ID used in the sequence. We could make such a utility today. Would this work for you?
I’ll need to review what we’re doing currently. After that I’ll get back to you about our other options.
The current approach uses this function to identify what material ID mapping the xmesh would be using:
XMeshSaver_MaterialUtils.getMaterialFromNodes()
I think there are two problems:
The IDs carried by the xmesh data depend on the id mapping file. It shouldnt, the ID mapping file should just help in setting up the appropriate shading names for the independently maintained ID/component information of the topology
The getMaterialFromNodes function does not work reliably for TP materials. In our case, the TP material had a total of 59 nested IDs, but the function only returned 13. The code there is quite complicated so i didnt try to troubleshoot why its failing, but here is a code snippet that “flattens” a TP material:
local theTPMaterial = theTPToSave.material
local iMatCount = 0
if (theTPMaterial != undefined) do
iMatCount = (getNumSubMtls theTPMaterial)
local theMaterial = MultiMaterial numsubs:iMatCount
local matIDList = #()
for m = 1 to iMatCount do
(
setsubmtl theMaterial m (getsubmtl theTPMaterial m)
append matIDList m
)
XMeshSaverUtils.ClearAllMaterialIDMapping()
XMeshSaverUtils.SetMaterialIDMapping theTPToSave matIDList matIDList
Unfortunately I don’t think we’ll be able to change this in the time frame that you require. However I am interested in improving our material handling, so perhaps we could discuss this after we’ve solved your immediate problem?
No, currently the XMesh Saver does not accumulate mapping information. You could do this yourself in script (disable the XMesh Saver’s material ID mapping; for each frame, examine the mesh, and keep track of the material IDs that it uses), or we could make a utility that does this for an existing xmesh sequence (see the end of this post).
Would it be possible for you to please send us a scene file that includes such a material?
I assume you’re saving a single particle system?
I believe this is the easiest workaround: we could make a utility that reads an xmesh sequence, and writes a matIDmap file with a stand-in material for every material ID used in the sequence. Would this work for you?
I solved our immediate problem by making sure the material has the same number of sub materials as the mesh has material IDs, so the emergency has passed!
Sorry, i meant accumulated material ID information. That is being collected if im not mistaken, otherwise it would not be able to cache it out.
Also, this seems to be a maya import only problem, as i can import the ‘bad’ data back into max and all the material IDs are present. They only go missing if i import the mesh into maya, and the matID file did not have the right number of IDs listed.
Yes and yes. You will need TP5 for the material most likely.
Since i already fixed our particular issue, no worries about finding a workaround, we could just focus on a long term solution