如何正确延伸 3Ds Max 材质

发布于 2024-07-20 07:20:46 字数 2571 浏览 7 评论 0原文

基本上,我只是尝试向 3Ds Max 9 中的“标准”材质添加更多属性。实际上,我已经设法通过 max 脚本完成此任务,但它破坏了我们的导出器。

导出器对于使用普通“标准”材质进行蒙皮的任何东西都可以正常工作,但扩展版本似乎对导出器隐藏了基类的属性。

到目前为止我所得到的是:


plugin material Standard_WithOutlines
name:"Standard & Outlines"
classID:#(0x73212413, 0x1ca9e3e6)
extends:Standard replaceUI:false version:1
(
    parameters shaderParameters
    (
        diffuse type:#color
        glossiness type:#float
        specular type:#color
        specularLevel type:#float
        selfIllumColor type:#color
        selfIllumAmount type:#float
        opacity type:#float

        on diffuse get val do delegate.diffuse
        on glossiness get val do delegate.glossiness / 100.0
        on specular get val do delegate.specular
        on specularLevel get val do delegate.specularLevel
        on selfIllumColor get val do delegate.selfIllumColor
        on selfIllumAmount get val do delegate.selfIllumAmount
        on opacity get val do delegate.opacity / 100.0

        on diffuse set val do delegate.diffuse = val
        on glossiness set val do delegate.glossiness = val * 100.0
        on specular set val do delegate.specular = val
        on specularLevel set val do delegate.specularLevel = val
        on selfIllumColor set val do delegate.selfIllumColor = val
        on selfIllumAmount set val do delegate.selfIllumAmount = val
        on opacity set val do delegate.opacity = val * 100.0
    )

    parameters MainParams rollout:ExtendedMatRollout
    (
        ShowOutlining type:#boolean animatable:false default:false ui:outline_Enabled
        OutlineColour type:#color animatable:false default:(color 0 0 0) ui:outline_Colour
        OutlineThickness type:#float animatable:false default:5 ui:outline_Thickness
    )

    rollout ExtendedMatRollout "Extended Parameters"
    (
        groupBox outlinegrp "Outlining" pos:[8,0] width:312 height:62
        checkbox outline_Enabled "Enabled" pos:[18,16] width:128 height:16
        colorPicker outline_Colour "Colour:" pos:[160,34] width:56 height:20 enabled:ShowOutlining
        spinner outline_Thickness "Thickness:" pos:[50,36] width:80 height:16 enabled:ShowOutlining range:[0,100,0]
        on outline_Enabled changed state do
        (
            outline_Colour.enabled = state
            outline_Thickness.enabled = state
        )

    )
)

通过自己声明变量,导出器可以读取它们,但这实际上并没有链接到 UI 设置的值。 为了解决这个问题,我使用“on XXX get/set”事件链接到隐藏的项目。 所以这些现在可以正常工作,但是漫反射和镜面反射等材质贴图不起作用(据我所知,这是对物体进行纹理处理的唯一方法)。

我应该如何将这几个设置添加到材质类型中,以便它也导出“委托”类中的所有数据(基本继承是否要求太多)?

谢谢

Basically, I'm just trying to add a few more properties to the "Standard" material in 3Ds Max 9. I've actually managed to accomplish this through max script, but it is breaking our exporter.

The exporter works fine for anything skinned with the normal "Standard" material, but the extended version seems to hide the base class's properties from the exporter.

What I have so far is this:


plugin material Standard_WithOutlines
name:"Standard & Outlines"
classID:#(0x73212413, 0x1ca9e3e6)
extends:Standard replaceUI:false version:1
(
    parameters shaderParameters
    (
        diffuse type:#color
        glossiness type:#float
        specular type:#color
        specularLevel type:#float
        selfIllumColor type:#color
        selfIllumAmount type:#float
        opacity type:#float

        on diffuse get val do delegate.diffuse
        on glossiness get val do delegate.glossiness / 100.0
        on specular get val do delegate.specular
        on specularLevel get val do delegate.specularLevel
        on selfIllumColor get val do delegate.selfIllumColor
        on selfIllumAmount get val do delegate.selfIllumAmount
        on opacity get val do delegate.opacity / 100.0

        on diffuse set val do delegate.diffuse = val
        on glossiness set val do delegate.glossiness = val * 100.0
        on specular set val do delegate.specular = val
        on specularLevel set val do delegate.specularLevel = val
        on selfIllumColor set val do delegate.selfIllumColor = val
        on selfIllumAmount set val do delegate.selfIllumAmount = val
        on opacity set val do delegate.opacity = val * 100.0
    )

    parameters MainParams rollout:ExtendedMatRollout
    (
        ShowOutlining type:#boolean animatable:false default:false ui:outline_Enabled
        OutlineColour type:#color animatable:false default:(color 0 0 0) ui:outline_Colour
        OutlineThickness type:#float animatable:false default:5 ui:outline_Thickness
    )

    rollout ExtendedMatRollout "Extended Parameters"
    (
        groupBox outlinegrp "Outlining" pos:[8,0] width:312 height:62
        checkbox outline_Enabled "Enabled" pos:[18,16] width:128 height:16
        colorPicker outline_Colour "Colour:" pos:[160,34] width:56 height:20 enabled:ShowOutlining
        spinner outline_Thickness "Thickness:" pos:[50,36] width:80 height:16 enabled:ShowOutlining range:[0,100,0]
        on outline_Enabled changed state do
        (
            outline_Colour.enabled = state
            outline_Thickness.enabled = state
        )

    )
)

By declaring the variables myself, the exporter could read them, but this didn't actually link to the values being set by the UI. To solve that, I used the 'on XXX get/set' events to link to the hidden items. So those now work correctly, but the material maps for things like diffuse and specular don't work (which is the only way to texture the thing AFAIK).

How should I be going about adding these couple of settings to a material type, so that it exports all of the data within the 'delegate' class as well (is basic inheritance too much to ask for)?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉梦枕江山 2024-07-27 07:20:46

两种可能性:

  1. 您的导出器是否枚举了所有参数块? 我想脚本中的参数最终会出现在一个额外的 pblock 中。 如果您的导出器只查看 pblock 0,这可能是您的问题。

  2. 我以前没有见过这种用法,其中参数在脚本和委托中具有相同的名称。 我认为您通常应该在脚本中创建新参数并使用不同的名称适当地分配给委托参数。 至少,我就是这样做的。

Two possiblities:

  1. Does your exporter enumerate all the paramblocks? I imagine that your parameters in the script will end up in an additional pblock. If your exporter just looks at pblock 0 that might be your problem.

  2. I haven't seen this usage before where parameters have the same name in the script and the delegate. I think you typically are supposed to make new parameters in the script and assign to the delegate ones appropriately, using different names. At least, that's how I've done it.

我是有多爱你 2024-07-27 07:20:46

这是一个基本的扩展着色器。
我认为您遇到的问题是您的推出未指定参数。
如果它没有定义,那么你就找不到它们,如果找不到它们,那么导出器就会出错。

plugin material Matte name:"Matte" classID:#(0x61108483, 0x4d218a72) extends:Standard replaceUI:true version:1
( 
    parameters main rollout:params
    (
        kdColor type:#color default:[90,90,90] ui:mkdColor
        on kdColor set val do delegate.diffuse_color = val
    )

    rollout params "Matte Parameters"
    (
        -- Basic matte parameters
        group "Basic Parameters" (
            colorpicker mkdColor "Diffuse: " across:2
        )

    )
)

Here's a basic extended shader.
I think the problem you have is that your rollout is not specified for the parameters.
If it's not defined, then you cannot find then, if it cannot find them then exporter get's all buggy.

plugin material Matte name:"Matte" classID:#(0x61108483, 0x4d218a72) extends:Standard replaceUI:true version:1
( 
    parameters main rollout:params
    (
        kdColor type:#color default:[90,90,90] ui:mkdColor
        on kdColor set val do delegate.diffuse_color = val
    )

    rollout params "Matte Parameters"
    (
        -- Basic matte parameters
        group "Basic Parameters" (
            colorpicker mkdColor "Diffuse: " across:2
        )

    )
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文