zoukankan      html  css  js  c++  java
  • 用mel编写自定义节点的属性编辑器界面

    用mel编写自定义节点的属性编辑器界面比较麻烦,而且网上例子又少,下面给出一个范例,说明基本的格式
    1. // 初始化节点时调用
    2. global proc initControl(string $attrName)
    3. {
    4. // 传进来的参数是节点属性名,使用这个方法获得节点名称
    5. string $nodeName = `plugNode $attrName`;
    6. setUITemplate -pst "attributeEditorTemplate";
    7. button -label "Compute Weight" -c ("cageDeform -init -name " + $nodeName) computeWeightButton;
    8. setUITemplate -ppt;
    9. }
    10. // 修改节点时(例如点击另一个同类节点)调用
    11. // 此函数的目的是对按钮绑定的命令做相应修改,使其能应用于相应节点
    12. global proc modifyControl(string $attrName)
    13. {
    14.   // 当attrName = “cageDeformer1.noAttr”
    15. // plugNode 命令能够提取节点名字cageDeformer1
    16. string $nodeName = `plugNode $attrName`;
    17. print $nodeName;
    18. button -e -c ("meshControl -init -name " + $nodeName) computeWeightButton;
    19. }
    20. // 函数名同文件名一样,同节点名cageDeformer对应
    21. global proc AEcageDeformerTemplate(string $nodeName)
    22. {
    23. editorTemplate -beginScrollLayout;
    24.         // 新建一个卷展栏
    25. editorTemplate -beginLayout "Weight Scheme" -collapse false;
    26. // addControl自动指定合适类型的控件
    27. editorTemplate -addControl "maxNeighbourNum";
    28. editorTemplate -addControl "weightPower";
    29.          // 在指定的时机调用前面的函数
    30. editorTemplate -callCustom "initControl" "modifyControl" "noAttr";
    31. editorTemplate -endLayout;
    32. editorTemplate -suppress "outMesh";
    33. editorTemplate -suppress "inControlMesh";
    34. editorTemplate -suppress "refMesh";
    35. editorTemplate -suppress "refControlMesh";
    36. editorTemplate -beginLayout "Node Behavior" -collapse true;
    37. editorTemplate -addControl "nodeState";
    38. editorTemplate -addControl "caching";
    39. editorTemplate -endLayout;
    40. editorTemplate -addExtraControls;
    41. editorTemplate -endScrollLayout;
    42. }

    下面是-callCustom的文档解释

    Specifies that at this point in the template when building the dialog, the procedure specified by the first argument is to be called to create some UI objects when a new node type is edited. The procedure specified by the second argument is to be called if an attribute editor already exists and another node of the same type is now to be edited. The replacing procedure should connect any controls created by the creating procedure to the equivalent attributes in the new node. A list of zero or more attributes specifies the attributes which the two procedures will involve. The procedures should have the signature:
    proc AEcustomNew(string attributeName1, string attributeName2)
    
    The number of attributes specified in the call should correspond to the number of attributes in the procedure signature.
     




  • 相关阅读:
    6、short s1 = 1; s1 = s1 + 1;有错吗?short s1 = 1; s1 += 1;有错吗?-Java面试题答案
    5、switch语句能否作用在byte上,能否作用在long上,能否作用在String上?-Java面试题答案
    4、在JAVA中如何跳出当前的多重嵌套循环?-Java面试题答案
    3、说说&和&&的区别-Java面试题答案
    2、Java有没有goto?-Java,面试题答案
    1、一个".java"源文件中是否可以包括多个类(不是内部类)?有什么限制?-Java面试题答案
    javaScript属性
    javaScript基本知识
    javaScript额外笔记
    OOP-基础知识(c#)
  • 原文地址:https://www.cnblogs.com/dydx/p/4286746.html
Copyright © 2011-2022 走看看