Maya for 3D Printing - Rapid Prototyping
In this course we're going to look at something a little different, creating technically accurate 3D printed parts.
# 1 23-10-2008 , 02:27 PM
Registered User
Join Date: May 2007
Posts: 15

How to sort material before exporting to mesh?

Somewhere in Maya there is a window which allows one to sort the material list before exporting to a static mesh. For example, I want my Red material to be #1 and my blue material to be #2, etc. in the final .ase file (I'm using axmesh, but that's irrelevant, this is a Maya thing).

Can't find this window anywhere, I know it exists because I've used it before. Can someone point me to the magic button please? :headbang:

Thanks!

# 2 24-10-2008 , 09:12 AM
Registered User
Join Date: May 2007
Posts: 15

Difficult to believe...

It's difficult to believe that among all the expert Maya professionals out there, no-one knows the answer to this question!

Am I to believe that Maya, probably the largest, richest, most complex software application I have ever used, capable of doing almost everything except fixing my kitchen sink, LACKS the capacity to do something as basic and ESSENTIAL as ordering the export material list so the exported static mesh has its materials in the same order?

What if I want to delete a material? Let's take a specific (simple) example.

I want to create a box, which will be a static mesh in my game. I'm also going to create a collision model for the box. I assign a single material to the box, and NO material to the collision model.

Now, I select both together and use the axmesh plugin to export the .ase file. How many materials does the box have? Two, according to Axmesh, but that's because Maya automatically assigned a lambert material to the collision model, so that material is in the list of materials to be exported with the mesh. And when I import the mesh into my game editor, sure enough it has two materials. Axmesh is right, there are a total of two materials involved here, but I only want to use one of them (the specifically assigned one) on my mesh. So there has to be a way to delete the unwanted lambert material from the material list prior to export. Otherwise, the exported mesh has (in this case) TWO sections, and in the game that means it is essentially TWO objects and requires more time to draw.

So all you static mesh builders for games are simply exporting your meshes that have collision models with an extra section, and you don't care that you're forcing the graphics card do extra unnecessary work during gametime? You count polygons down to the nth degree, but then casually double the number of logical meshes in your game? Really? user added image

# 3 24-10-2008 , 06:16 PM
Chirone's Avatar
Subscriber
Join Date: Dec 2007
Location: NZ
Posts: 3,125
your first and second post appear to be different?

in the first you ask how to sort your materials? (materials are ordered by the name of the material so you just rename your materials)

in the second post you want to export your mesh and collision model and not have any materials on the collision model
in that case just delete the materials from the collision model when you export it

am i correct to read that you have two models you're exporting (in that example), one model, and one collision model. why not just delete the material from the collision model or assign no material?

i'm unfamiliar with the exporter you're using, but when i was using Steam and the smd plugins you'd export your models 3 times and the collision model didn't have any materials attached to it.



the reason why no one has answered your question is likely because no one knows what you've asked.

I for one haven't heard of "ordering materials for export" because it doesn't make sense. ordering materials to me sounds like you want to order them by name.

what's the purpose? the only thing the models keep when they are exported (related to materials) is the name of the materials (at least with smd files they do)
if its somethine like the order in which the materials are exported then i dont see any relevance in that because exported files should know the name of the material file.



Edit add: someone else who hasn't seen this thread might be able to answer your question. there might be some magic window or magic button in the hypershade to order your materials as you want them to.
actually, surely it's part of your plug in, as i mentioned before, typically exported models know the name of their materials, so it must be part of your plug in




that's a "Ch" pronounced as a "K"

Computer skills I should have:
Objective C, C#, Java, MEL. Python, C++, XML, JavaScript, XSLT, HTML, SQL, CSS, FXScript, Clips, SOAR, ActionScript, OpenGL, DirectX
Maya, XSI, Photoshop, AfterEffects, Motion, Illustrator, Flash, Swift3D

Last edited by Chirone; 24-10-2008 at 06:38 PM.
# 4 24-10-2008 , 08:29 PM
Registered User
Join Date: May 2007
Posts: 15
[deleted] see following reply...


Last edited by briano; 24-10-2008 at 09:05 PM.
# 5 24-10-2008 , 09:04 PM
Registered User
Join Date: May 2007
Posts: 15
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[3] = 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 [3] 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

Maya assigned:
stock (0)
handgrip (1)
trigger (2)
shoulderStrap (3)
barrel (4)

But I need:
stock (0)
handgrip (1)
trigger (2)
barrel (3)
shoulderStrap (4)

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:

stock__Skin00
handgrip__Skin01
trigger__Skin02
barrel__Skin03
shoulderStrap__Skin04

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.
# 6 24-10-2008 , 09:44 PM
Chirone's Avatar
Subscriber
Join Date: Dec 2007
Location: NZ
Posts: 3,125
hey dude, i share your pain (and i wasn't at my computer to see your original post, but i'm guessing it was very offensive in which case i'm lucky i didn't see it considering i have about 30 hours work to do in 14 hours)

ok i didnt have the same problems with you because i guesss Source works differently to Unreal
I'm not going to waste your time saying what they were

not entirely sure how to fix your ordering problem (i've only effectively had 4 months to play with maya) so there may be some window somerwhere that i'm unaware of

as for deleting the default lambert, if you can't hit delete on it and make it go away then you can't delete it
but to remove the material just make a new material, assign that, and then delete it, the model will go deep green and that means it has no material on it




that's a "Ch" pronounced as a "K"

Computer skills I should have:
Objective C, C#, Java, MEL. Python, C++, XML, JavaScript, XSLT, HTML, SQL, CSS, FXScript, Clips, SOAR, ActionScript, OpenGL, DirectX
Maya, XSI, Photoshop, AfterEffects, Motion, Illustrator, Flash, Swift3D
# 7 24-10-2008 , 11:52 PM
Registered User
Join Date: May 2007
Posts: 15
Naw, the deleted post was just a screw up, I must have accidently hit a key and the message posted while I was in the middle of composing. So I just posted again when I was finished and deleted the unfinished original.

Hey, I actually thought of the great suggestion you made about assigning a material to the collision model and then deleting the material. Yes it goes dark green. But the plugin either crashes when I try to export the mesh, or worse, it includes every material in the Maya file for every object in the file as though it belonged to (i.e., was assigned to) the exporting mesh.

Anyway, I do appreciate the time and energy you have donated. Clearly, I'm doing things that either no-one else has tried, or more likely, no-one else has considered. It makes me wonder how many static meshes there are out there in the gaming world with a extra un-needed un-used material that is causing the graphics engine to work harder doing nothing useful.:attn:

If I ever do figure this out I'll write it up here, but it seems impossible to me that I'm the first and only person to encounter this problem!

# 8 24-10-2008 , 11:57 PM
Chirone's Avatar
Subscriber
Join Date: Dec 2007
Location: NZ
Posts: 3,125
What a funny response to not having materials (albeit equally frustrating :p)

Originally posted by briano
Clearly, I'm doing things that either no-one else has tried, or more likely, no-one else has considered. It makes me wonder how many static meshes there are out there in the gaming world with a extra un-needed un-used material that is causing the graphics engine to work harder doing nothing useful.:attn:

hahaha, we thought the same thing when we made our mod for half life :p
and it makes me wonder why no one has thought to make their own character models or own AI for mods

the Valve people don't care about the modders because they get no money off them user added image
i'm going to guess the unreal people are the same :p




that's a "Ch" pronounced as a "K"

Computer skills I should have:
Objective C, C#, Java, MEL. Python, C++, XML, JavaScript, XSLT, HTML, SQL, CSS, FXScript, Clips, SOAR, ActionScript, OpenGL, DirectX
Maya, XSI, Photoshop, AfterEffects, Motion, Illustrator, Flash, Swift3D
# 9 26-10-2008 , 09:09 AM
Registered User
Join Date: May 2007
Posts: 15
Well, I never did find the feature I was searching for in Maya. But I've found work-arounds for both problems.

To prevent an extra material from being exported (the one assigned to the collision model), just assign one of the materials used by the static mesh to the collision model as well (duh!). So simple it hurts.

To order the material list exported by the ActorX plugin - it turns out (MUCH to my surprise) that the .ase file is in ASCII format, and what's more it looks like a programming or page layout language. Since the necesity to order materials is a rare occurance, it was easy enough to just cut/paste in the .ase file before importing into Unreal. Also so simple it hurts.

A classic case of not being able to see the forest for the trees! :blush:

# 10 26-10-2008 , 01:17 PM
Chirone's Avatar
Subscriber
Join Date: Dec 2007
Location: NZ
Posts: 3,125
ouch!

haha, dont you just hate it when you spend days and even weeks on a problem only to find out that the solution is so trivial?

good to know you found a solution




that's a "Ch" pronounced as a "K"

Computer skills I should have:
Objective C, C#, Java, MEL. Python, C++, XML, JavaScript, XSLT, HTML, SQL, CSS, FXScript, Clips, SOAR, ActionScript, OpenGL, DirectX
Maya, XSI, Photoshop, AfterEffects, Motion, Illustrator, Flash, Swift3D
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads