Maya插件(四):DAG、DG、MPlug、Attribute等基本概念

前沿

        在Maya中,场景的组织是DAG(Directed Acyclic Graph)形式的,不同于场景树,如下图就是一个有向无环图:

                                                       

 这个DAG只是组织了模型的几何信息(transfrom, rotation, scal, 顶点数据)。除此之外,还有其它的Dependency Node,影响模型的动画、渲染等。以上加起来构成了一个DG(Dependency Graph)。

 

DAG

         在Maya中,DAG组织由两种类型的结点组成transform 和 Shape。transform提供position、rotation、scale信息,并且有孩子结点;Shape只提供geometry信息,并且没有孩子结点。

示例,在Maya中创建一个立方体,DAG如下图所示:

                                      

 

pCube1 为Transform结点,pCubeShape1结点。 一般地,Transform结点下仅有一个Shape结点。

 

DG(Dependency Graph)

         DG是Maya的核心,其上的结点具有输入、输出、计算能力,下面是12个基本的结点类,用户可以继承实现自己的结点类。

 

        The dependency graph (DG) is a collection of entities connected together. Unlike the DAG, these connections can be cyclic, and do not represent a parenting relationship. Instead, the connections in the graph allow data to move from one entity in the graph to another. The entities in the graph which accept and output data are called dependency graph nodes.

        Dependency graph nodes are the part of a dependency graph which perform computations. A node takes in a set of input data (supplied by connections to other nodes, or which are simply supplied to the node) and use them to create a set of output data. Dependency graph nodes are used for almost everything in Maya such as model creation, deformation, animation, simulation, and audio processing.

         Most objects in Maya are dependency graph nodes, or networks of nodes (several nodes connected together). For example, DAG nodes are dependency graph nodes, and shaders are networks of nodes.

        When dependency graph nodes are connected together they can affect DAG nodes and thus affect what is rendered.

        如下图所示:

       

         Transform1、Transform2、Transform3、Sphere是DAG Node(也是DG Node),Time只是个DG Node.

 

DG网络的计算

        When an attribute of a node is changed, the dependency graph checks to see if that attribute affects any output. If it does, each of those outputs is marked dirty, meaning that its cached value is stale and needs to be recomputed. Then for each of those output attributes, the dependency graph checks to see if they are the source for a connection. If so, then the connection is followed, and the destination attribute is marked dirty also. This process recurs, and at the end all attributes of nodes in the graph which need to be recomputed are marked dirty. It is important to note that at this time no attributes have been recomputed, instead the state has just been updated so we know which data is no longer valid. The evaluation and re-computation of those invalid attributes occurs as part of a separate step.

        DAG上是要绘制的模型,DG Node影响了模型的绘制,前者为主线,后者为辅助。

 

Attribute && Plug

       Attribute定义了数据接口,描述了数据类型和名字,Plug存放了相应的attribute的数据,通过plug访问attribute的内容, plug同时也是连接两个Node的端口。

       Plug分Non-networked 和 Networked两种,Non-networked plug用于建立到attribute的连接、或读写attribute的数据;Networked plug在连接2个不同nodes的attributes时由Maya创建。

      下图描述了它们之间的关系(个人体会):

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值