Is it possible to get face & vert count in materialclass?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
Old 04 April 2014   #1
Is it possible to get face & vert count in materialclass?

Im wondering if its possible to get the amount of faces and verts a material would use on a single editable mesh?

For example say I have this script "multimaterials in specific"

for obj in geometry do(
	if classof obj.material == multimaterial then(
		for z = 1 to obj.material.count do(
		)
	)
)


would it be possible to in the z loop to count how many faces and verts the first material uses and then the same again for the next material on the same mesh?
 
Old 04 April 2014   #2
can you not just do that by counting the faces by material id?
__________________
Matt Rennie
Sr. Character Rigger
Rockstar North
 
Old 04 April 2014   #3
Originally Posted by MattRennie: can you not just do that by counting the faces by material id?

I thought so but it seems that with 2 different materials applied to the same mesh all the material ID's are 1 for some reason. getfacematid is what I should be using right?

*EDIT* OK IDK what it was maybe some sort of bug but I restarted max and its getting the ids correct now. It was really messing with my head.


Anyway now im trying to get the vert count in multimaterials on single meshes and im having a bit more trouble with it then I thought I would. Unless there is an easier way to do it this is currently how im doing it

clearlistener()

for obj in geometry do(
	ids = obj.material.materialIDList
	if classof obj.material == multimaterial then(
		for id=1 to ids.count do(
			for f = 1 to obj.numfaces do(
				if getfacematid obj f == ids[id] do(
					zz=meshop.getVertsUsingFace obj f
					print zz
				)
			)
			format "Current mat: % \n" obj.material[id].name --above in listener is the verts
		)
	)
)


Basically zz is the verts in the material, I figured when there is a "," in the array then it represents 1 vert and then its just #..# then its 3. I was trying to figure out math functions for this where I could get the total verts per material in one mesh but nothing seems to be working for me.

Last edited by Troopermanaic : 04 April 2014 at 11:09 PM.
 
Old 04 April 2014   #4
This will works on Editable_Mesh only
(
 	clearlistener()
 	getFaceVerts = meshop.getVertsUsingFace
 	for obj in geometry where isKindOf obj Editable_Mesh and isKindOf obj.mat multimaterial do
 	(
 		array = for mat in obj.mat.materiallist collect #(mat.name, #{}) 
 		for f = 1 to obj.numfaces where (number = findItem obj.mat.materialIDList (getfacematid obj f)) != 0 do
 		(
 			join array[number][2] (getFaceVerts obj f)
 		)
 		print array
 	)
 )
__________________
Looking in the right side. [bgaTools]
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:44 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.