Join Date: May 2007
Thanked 0 Times in 0 Posts
Hey, thanks for responding.
I was trying to be clear, obviously I wasn't successful.
Let me try and answer your questions first.
In certain game engines (and specifically the one I'm currently using, Unreal), one creates a static mesh and its simplified collision model together in the same Maya file. The collision model gets a specific prefix (MCDCX_) which the Unreal editor uses to identify it as the colllision model component of the importing mesh. Both the mesh and the collision model are exported from Maya together into one .ase file, and both are imported together into Unreal from that one file.
The problem is that the Ureal editor doesn't distinguish materials which were assigned to the collision model (automatically, accidentially, or otherwise) from materials which were assigned to the mesh (for all I know that information isn't even present in the .ase file). Since collision models are never drawn or seen, it makes sense that any materials referenced in the .ase file MUST belong to the mesh, and it installs the mesh in the game environment with that many materials, one too many if a collision model was exported along with it that had a material assigned to it. With me so far?
I wasn't aware I could delete the automatically assigned lambert material which Maya assigns to the collision model. Maya won't let me delete the lambert shader itself (complains it's read only), but maybe there is a way to delete it from the collision model? If so, that would solve this particular part of the problem (an extra un-needed material being exported with the mesh).
The specific NAMES of the materials in Maya are NOT exported. The information in the .ase file works like this:
There are X materials. Here is is list of the poly faces which use material one. Here is a list of the poly faces which use material two. Here is a list of the poly faces which use material three. Etc.
Once the mesh has been imported into Unreal, one can assign any material one wishes to any particular list of poly faces. What one CAN'T do in Unreal however is change the members in a list. That can only be done in Maya, where one can assign materials to poly faces.
Often when I make meshes in Maya I just use a checker pattern so I can see what I'm doing with UVs, or I might use a texture which closely resembles the final texture which will be assigned in Unreal so I can visually see what's going on. But the material system in Unreal is not the same as the material system in Maya, Unreal is much more complex and powerful. I cannot create the dynamic materials in Maya I can create in Unreal (or, if it's possible to do so, I don't know how). But it's also not necessary. All I need in Maya is the ability to manage UVs and vertex painting.
Anyway, once the mesh has been imported into Unreal, one assigns materials to the various "lists" (or "collections" or "groups" or "sets", however you prefer to conceptualize it) of poly faces, and only then do you have the final mesh as it will appear in the game with all of it dynamic materials displayed. I repeat, there is NO transfer of material names from Maya to Unreal, only information about which material by number (i.e., the ordered sequence decided in Maya) belongs to which set of poly faces. Still with me?
Now, why is it important to have a specific list of poly faces be the first (or second or whatever) material in the material list? Usually it's not. But in Unreal, where one is programming in Unreal script, which is an object oriented language, one often subclasses something to augment or modify the object's behavior. Much of the code base is not available for modification however, because it's "native" i.e., written in C++ and not available to users.
So lets suppose I subclass some object from Unreal's inventory. When this particular object is picked up by a player, the code base changes one of the materials of the object, modifying its appearance. Hardwired somewhere in the code, higher up in the object's heirarchy and buried in native C++ code where I can't get to it, there is a statement which effectively says:
Change the first (or second or whatever) material of the object from material X to material Y.
That material corresponds to a particular list of poly faces on the static mesh picked up by the player. I cannot change the code, it's always going to change the material belonging to the first (or second or whatever) list of faces on the mesh. So what I need to do is make sure that the faces on my mesh which are going to be changed correspond to the faces which Unreal's code expects to change.
This is not easy to understand, so I'll give a concrete example. Suppose my object is a gun, and it has five materials. Whenever the object is picked up, Unreal's code is going to change the material of the barrel of the gun from gunmetal grey to glowing red. Now, it just so happens that the material of the barrel is the third material in the list of materials for that mesh. Unreal (Epic folks) designed the gun after all, and the corresponding code says:
if (picked up by player)
//change the color of the barrel
material = color(GLOWING_RED);
I'm just using pseudo code here, nothing legit.
Suppose I have subclassed the gun and I have provided my own custom static mesh. The above code presents no problem for me, so long as I can make sure that the material which is assigned to the barrel of the gun is the  material in the list of the meshe's materials. But the order (sequence, ordinal) of the materials was arbitrarily decided by Maya when the mesh was exported. It can't be changed once it has been imported into Unreal, so it has to be decided in Maya, like this
But I need:
So my original question was:
How does one sort the material list before exporting to a static mesh?
I still can't do it. I've tried changing the names of the materials in Maya, hoping that would influence the order, but it does nothing. Someone told me that I must name them like this:
But I tried that too and it had no effect.
If you know of a way I can delete the automatically assigned lambert material from the collision model, I can at least solve one part of this problem, the part having to do with creating one too many materials in the mesh's material list. But I still need to find a way to get Maya to "order" the material list according to my wishes.
Long winded, but I really need an answer, and I don't even want to tell you how much time I have already wasted looking for a solution, without success :headbang:
P.S. - The plugin I'm using (Axmesh) has no controls to do any of this. It specifically assumes that this sort of work has been done already by the host program (Maya in this case). One can change material names in Maya which influences the order in which they are DISPLAYED inside Maya. Additionally one can select alphabetical, or creation order, or the reverse of either. But none of that seems to influence the order of the materials which are offered to the plugin when the mesh is exported.
Last edited by briano : 24-10-2008 at 11:35 PM.