Attribute (Field)
Compute (Member Function)
DG:Denpendency Graph
(Horizontal view, input and output connection between different nodes)
DAG:Directed Acyclic Graph
(Vertical view, Hierarchy, ex. transformation -> shape)
DAG is a DG
MDagPath (Hierarchy info of node, you can manipulate geometry in world coordinate space)
MObject (Handle to node, you just can manipulate geometry in object coordinate space)
Push-Pull Approach
Push: forward propogate the message which updating each child node's flag(dirty bit).
Pull: backward propogate the message which updating each parent node's status.
updating: updating, execute each node's compute function, DAG Path from root to child.
(共三趟)
dirty data:通常指資料已被改變(如:在記憶體內的data),但尚未write back(如:在硬碟的檔案系統)。
MPxNode:
xxxCmd.cpp (network view)
virtual MStatus doIt ( const MArgList& );
virtual MStatus undoIt();
virtual MStatus redoIt();
virtual bool isUndoable() const { return true; }
static void *creator() { return new MeltCmd; }
特別是在doIt()利用MPlug來存取場景中所有node的attribute, 並建立node與node之間的連結.
(MPlug xxPlug = xxxFn.findPlug("xxx");
(利用MDagModifier或MDgModifier 的connect(), disconnect(),createNode())
ex:
MFnDependencyNode nodeFn(obj);
MPlug xPlg = nodeFn.findPlug("translateX");
double tx;
xPlg.getValue(tx); //get an attribute at current time.
MTime t(1.5, MTime::kSeconds);
MDGContext ctx(t);
transxPlug.getValue(tx, ctx); //get an attribute at specific time.
xxxNode.cpp (node view)
virtual MStatus compute(MPlug &plug, MDataBlock &data ){
利用MDataHandle來存取data, (data.inputVaule(), data.outputValue()),
並計算output attribute的值.
}
static MStatus initialize(){
利用MFnXXAttribue 來初始attribute,
addAttribute();
attributeAffects(); //建立node中attribute的互動關係.
}
static void *creator();
static const MTypeId id;
MPxLocatorNode:
virtual void draw( M3dView &; view, const MDagPath &path,
M3dView::DisplayStyle style, M3dView::DisplayStatus status );
virtual bool isBounded() const;
virtual MBoundingBox boundingBox() const;
static void *creator();
static MStatus initialize();
MPxCommand:
virtual MStatus doIt ( const MArgList&);
virtual MStatus undoIt();
virtual MStatus redoIt();
virtual bool isUndoable() const { return true; }
static void *creator() { return new MeltCmd; }
No comments:
Post a Comment