艺术的追求从编程开始

C/C++/UNIX/PYTHON/ALGORITHM

导航

九、DAG hierarchy

DAG 节点有两种,Transformation/shape。

shape节点是transformation的子节点。 transformation节点包括position, rotation, scale, parents infromation.

 

A dag path 代表从root node到shape node 所经历的一个transform的集合。

 

instancing:当transform或者shape节点有多个父节点的时候,他们被认为instanced。例如一颗树上的很多个树叶,可以共用一个shape节点,如图:

leaf是shape节点。

Transform3 and the Leaf is instanced (it has two parents). The two valid DAG paths in this example are: Transform 1 - Transform 3 - Leaf and Transform 2 - Transform 3 - Leaf.

For example:

MFnDagNode—has methods for determining the number of parents, and the parents of a node.

MFnTransformis the function set for operating on transform nodes (derived from MFnDagNode) and has methods to get and set transformation, such as rotation, translation, or scale.

MFnNurbsSurface—is one of many types of function sets which operate on the many types of shape nodes (also derived fromMFnDagNode, but not derived from MFnTransform) and has methods to get and set the CVs of the surface, etc.

 

 

DAG path: 节点间用|隔开,每个instance node可以有多条路径。

DAG paths and worldspace operations in the API

DAG path represents how a shape is inserted into the scene, a DAG path must be used when attempting any world space operation via the API.

Almost all of the classes that contains methods that will return an MObject for a node also contain methods that will return DAG paths so you can get an MDagPath handle to the desired node. As well, all the MFn classes can be constructed with either an MObject or anMDagPath. 但如果是用MObject来构建MFn,则不能使用world space的操作。

The MDagPath represents paths as a stack of nodes with the root node being on the bottom of the stack. The push() and pop() methods allow nodes along the path to be added or removed from the representation.

These methods do not add and remove nodes from the actual DAG but only from the representation constructed by theMDagPath class. 

The MDagPath class allows these transformations to be returned using theinclusiveMatrix() and exclusiveMatrix() classes.

每条路径的变换矩阵可以有两种方式:inclusive matrix是包括最后一个节点的Matrix, exclusiveMatrix()不包括最后一个节点。

For example, if a path is defined as:

|RootTransform|Transform1|Transform2|Shape

the inclusive matrix down to Transform2 would be the accumulation of RootTransform, Transform1, and Transform2. The exclusive matrix would contain the accumulation of only RootTransform and Transform1.

 

1. 为什么要将shape node加入DAG path

selection操作返回的是选择到物体的shape节点的父tranform节点,

 MGlobal::getActiveSelectionList()返回的MDagPath是shape node前的transform节点,用extendToShape()函数。

Function set对应MDagPath路径上最后一个节点,如果是shape就应该用shape的function set, 是transform就用tranform的function set。

 

2. 一个transform node只有一个shape node,除了下面情况:

 

|Transform1|Shape1 is the original historical object while |Transform1|Shape1a is the actual object visible in any interactive window. |Transform1|Shape1 is also called an intermediate object.This is important later when working with the dependency graph.

3. Dag walking example:

这个例子,iterating through DAG either a depth first  or breadth first manner。是file translator的基础。

 

posted on 2016-01-30 12:34  Rambo.Wang  阅读(298)  评论(0编辑  收藏  举报