PDA

View Full Version : Changing MaterialIDs Scripte ???


stilgarna
10-20-2006, 01:42 PM
I have a big scene with 4900 cars, all instences

I have a base of 14 differents cars, with one Multi/Sub

I "only" need to change the IDs from MaterialID 1 to 44 to ID 71 to 115...

I have 14 cars to change....
the 4900 cars are base on the 14 cars...

For exemple
Car 1 : ID1 ID2 ID15 ID20 ID14
Car 2 : ID3 ID4 ID15 ID20 ID14
Etc...

Is there an easy way to do that... A script or something ?


Please Help this is an emergency...

Best regards...

rdg
10-20-2006, 02:59 PM
this is for editbale_mesh:

it adds a offset to the materialId of each face in a editable_mesh object:
(
-- the settings

matIDoffset = 2

-- the script
theSel = selection as array
for theObj in theSel do(
if classof theObj == Editable_Mesh then (
theNumFaces = getNumFaces theObj
print theNumFaces
for theFace = 1 to theNumFaces do (
theCurrentMatID = getFaceMatID theObj theFace
setFaceMatID theObj theFace (theCurrentMatID + matIDoffset)
format "%: % %\n" theObj.name theFace (theCurrentMatID + matIDoffset)

)
update theObj
)else(
print "Object is not Editable_Mesh"
)
)
)

Georg

stilgarna
10-20-2006, 03:02 PM
this is for editbale_mesh:

it adds a offset to the materialId of each face in a editable_mesh object:
(
-- the settings

matIDoffset = 2

-- the script
theSel = selection as array
for theObj in theSel do(
if classof theObj == Editable_Mesh then (
theNumFaces = getNumFaces theObj
print theNumFaces
for theFace = 1 to theNumFaces do (
theCurrentMatID = getFaceMatID theObj theFace
setFaceMatID theObj theFace (theCurrentMatID + matIDoffset)
format "%: % %\n" theObj.name theFace (theCurrentMatID + matIDoffset)

)
update theObj
)else(
print "Object is not Editable_Mesh"
)
)
)

Georg





Thanks... I will test it...

Thanks a lot...

stilgarna
10-20-2006, 03:09 PM
Thanks a lot man...

Your script work perfectly...



Many many thanks...

I'm just wondering if it's difficult to adapt for editable poly ?

rdg
10-20-2006, 03:12 PM
(
-- the settings

matIDoffset = 2

-- the script
theSel = selection as array
for theObj in theSel do(
theObjType = classof theObj
case theObjType of (
Editable_Mesh:(
theNumFaces = getNumFaces theObj
for theFace = 1 to theNumFaces do (
theCurrentMatID = getFaceMatID theObj theFace
setFaceMatID theObj theFace (theCurrentMatID + matIDoffset)
-- format "%: % %\n" theObj.name theFace (theCurrentMatID + matIDoffset)

)
update theObj
)
Editable_Poly: (
print "Object is POLY"
theNumFaces = getNumFaces theObj
for theFace = 1 to theNumFaces do (
theCurrentMatID = polyOp.getFaceMatID theObj theFace
polyOp.setFaceMatID theObj theFace (theCurrentMatID + matIDoffset)
format "%: % %\n" theObj.name theFace (theCurrentMatID + matIDoffset)
)
)
default:(
print "Object cannot be processed"
)
)
)

)


Now please tell me why you have to offset your matIDs?
I never saw MultiSub-Material with 115 sub-materials ...

Georg

stilgarna
10-20-2006, 03:19 PM
I made a very heavy scene for an architectural project...

17500 elements - 9 000 000 Polys... etc etc...


For several passes like Mask or Z buf I use an overide material...

An if a palm brack have Material ID1 and Car whells too...

For a mask pass with a pure red shader in the brack, the whells are red too with an overide material...

Idem with an oclusion... if ou have and alpha in a leaf shader with the same ID of a wall....



And I never use Scene state...

CGTalk Moderation
10-20-2006, 03:19 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.