Okay so after lots of tutorials and reading up on Max script I am going to attempt my first production tool and I was wondering if you guys had any feed back on where I should get started.
Here’s the skinny on what I want the tool to do.
So we have lots of building in our game that have to many material ID’s on them(some have 10 +). So I was tasked with finding ways to consolidate material ID’s to around 4 per building. Well after an hour of looking at a building trying to find out what textures where used more or less it dawned on me that I could possibly write a tool that tells me the percentage of surface area one texture takes over another one.
For example say I have a 6 sided box and out of thoes six sides 3 sides are red 2 are blue and 1 is yellow. When I run the script in the box I want the tool to spit out the following information to a text box or simple word pad doc for each texture that is applied to the model.
Texture name = Red.tga
How many faces texture is applied to = 3
% out of 100 that this texture is used on model = 50%
Texture name = Blue.tga
How many faces texture is applied to = 2
% out of 100 that this texture is used on model = 33%
Texture name = Yellow.tga
How many faces texture is applied to = 1
% out of 100 that this texture is used on model = 17%
It seams pretty straight froward but do any of you see anything that would not work or take a really long time for a beginner to do? This would be my first real “production” tool so I don’t want to say that I can do this and then not be able to deliver it at on time or at all.
Well thanks for any in site you might guys(gals?) might have on this matter.
This seems like a pretty good starting idea for a script. It is not hugely complicated and shouldn’t take all that long, but is complex enough that it should force you to learn some stuff that will be useful.
I’d imagine the steps for your script would be something like this (not necessarily most efficient way but it should work):
[LIST=6]
[li] For each object in selection:
[/li][li] For each face of this object, find its area (polyop.getFaceArea if working with an Editable Poly object, which you should be really) and also get the material ID (polyop.getFaceMatID).
[/li][li] For all faces matching a certain ID, add their areas together (you could do this in the above loop to avoid having to store large arrays).
[/li][li] Add them all together to get the object’s total surface area.
[/li][li] Check the object’s overall materials and see what the “pretty name” of the object’s multi/sub corresponds to which of the total areas for each ID. Calculate for each ID the percentage of area out of the total surface area.
[/li][li] Assemble a string output to a simple prompt window or message box indicating which materials have what percentage of total area.
[/li][/LIST]
Some places to start looking in the MAXScript help would be for those polyOp commands I mentioned above. Also look up material accessing methods.
If you haven’t done much scripting before you will also have to learn to work with loops (quite easy really) and probably get acquainted with error handling - eg. bail out nicely with a warning to the user if the object has no material assigned at all, or if the material isn’t a multi/sub material, or if the object isn’t an EPoly, etc. etc…
Further ideas for improvement might be to automatically select the faces of the result which had the least surface area, or even better to have buttons in the output window allowing the user to quickly select all faces matching that material ID.
[QUOTE=MoP;3076]This seems like a pretty good starting idea for a script. It is not hugely complicated and shouldn’t take all that long, but is complex enough that it should force you to learn some stuff that will be useful.
I’d imagine the steps for your script would be something like this (not necessarily most efficient way but it should work):
[LIST=6]
[li] For each object in selection:
[/li][li] For each face of this object, find its area (polyop.getFaceArea if working with an Editable Poly object, which you should be really) and also get the material ID (polyop.getFaceMatID).
[/li][li] For all faces matching a certain ID, add their areas together (you could do this in the above loop to avoid having to store large arrays).
[/li][li] Add them all together to get the object’s total surface area.
[/li][li] Check the object’s overall materials and see what the “pretty name” of the object’s multi/sub corresponds to which of the total areas for each ID. Calculate for each ID the percentage of area out of the total surface area.
[/li][li] Assemble a string output to a simple prompt window or message box indicating which materials have what percentage of total area.
[/li][/LIST]
Some places to start looking in the MAXScript help would be for those polyOp commands I mentioned above. Also look up material accessing methods.
If you haven’t done much scripting before you will also have to learn to work with loops (quite easy really) and probably get acquainted with error handling - eg. bail out nicely with a warning to the user if the object has no material assigned at all, or if the material isn’t a multi/sub material, or if the object isn’t an EPoly, etc. etc…
Further ideas for improvement might be to automatically select the faces of the result which had the least surface area, or even better to have buttons in the output window allowing the user to quickly select all faces matching that material ID.
Hope that helps.[/QUOTE]
Sweetness that was just what I was looking for…I am going to be working on this in my spare time and over the weekend and will post with results. Thanks again.