Editor 如何在没有材质编辑器的情况下访问maxscript中的材质?
在maxscript中,似乎有两个选项可以通过“精简材质编辑器”(compact Material Editor)和“板岩材质编辑器”(Slate Material Editor)访问材质。问题在于,如果max设置为使用Slate编辑器,则试图通过compact editor(Editor 如何在没有材质编辑器的情况下访问maxscript中的材质?,editor,maxscript,Editor,Maxscript,在maxscript中,似乎有两个选项可以通过“精简材质编辑器”(compact Material Editor)和“板岩材质编辑器”(Slate Material Editor)访问材质。问题在于,如果max设置为使用Slate编辑器,则试图通过compact editor(currentMaterialLibrary,sceneMaterials,meditMaterials)访问/修改材质的scrip将失败,反之亦然 无论使用哪种编辑器,是否有办法直接在maxscript中访问材质 一旦我
currentMaterialLibrary
,sceneMaterials
,meditMaterials
)访问/修改材质的scrip将失败,反之亦然
无论使用哪种编辑器,是否有办法直接在maxscript中访问材质
一旦我有了材料,我想:
你对你要做的事情不是很明确,但是你可以做的是在场景中的所有材质中循环,然后从那里选择你想要做任何事情的材质。通过这种方式,它不关心材质编辑器使用的设置
for mat in scenematerials do
(
print ("material name: " + mat.name)
)
如果要查找所有现有材质(无论是否在场景中),以下代码段将为您完成此操作
for aMtlType in material.classes do
(
for aMtl in (getClassInstances aMtlType processAllAnimatables:true) do
(
print aMtl
-- Does this material exist in the scene or not?
if (findItem sceneMaterials aMtl) == 0 do (print "This material does not exist in the scene")
)
)
我不太确定如何从现场清除它。可以获取依赖项(refs.dependents aMtl),然后将对此材质的任何引用替换为新的默认材质。虽然我还没有试过(甚至没有试过运行),但这应该是可行的。所以仔细测试并小心使用:-)
对于第二个问题-检查属性-您可以检查它是否具有适当的属性,并根据需要设置值
如果(hasProperty aMtl“diffuse”)执行(aMtl.diffuse=0)Stig,感谢您的回答。有两件事,首先我想从场景中清除未指定的材质,以便未使用材质上缺少的纹理不会在场景打开/网络渲染时抛出错误,其次我想检查某些材质属性(即光泽细分),以便购买具有“不必要的高值”的模型不要破坏渲染时间。这是非常有趣的,比你的输入和帮助我,了解这更多。同时,我了解到compact meditor使用插槽ID,将未指定ID重置为默认材质将清除场景中的相关贴图。
defMtl = ...
for d in refs.dependents aMtl do (
refIdx = 0
for i = 1 to refs.getNumRefs d do ( if (refs.getreference d i) == aMtl ) do ( refIdx = i )
refs.replaceReference aMtl refIdx defMtl
)