Dashboard_avatar
Feb 16, 2008
Post id: 271881 Report Item

I've really been hacking my way through this, so I thought it would be much better (and I can stop bothering you guys!) if I actually understood what was going on.

Here's what I know:

DAG is directed acyclic graph, basically a tree structure that allows multiple parents. This is whole thing that Maya works with, the entire scene is stored in this DAG.

Each "thing" that a non Mayan would think is an object (like a sphere) is actually two things; a transform structure that describes the location in the world and a mesh structure that describes the size of the object and the number of triangles etc etc.

It seems that the transform is generally the parent node of the mesh node. Is that correct?

So I guess my confusion comes down to what is a DagNode vs a DagPath? I suppose a camera and a sphere should be pretty much the same in Maya's DAG, but I seem to have a whole different way to get attributes of a camera vs a mesh. Can you give me a one line description of MFnDagNode, MDependencyNode, and MFnDagPath and how they are related? The class descriptors didn't help my understanding much, and Rob the Bloke's website has great examples, but I still don't really understand what each of these structures is actually storing/their relationship to each other.

Maybe you have a good tutorial link that explains this already?

Thanks!

Dave

Dashboard_avatar
Feb 16, 2008
Post id: 271882 Report Item

Some really crap notes i wrote years ago, some stuff is slightly in accurate, but i've learned a lot since then... http://www.robthebloke.org/mayaapi/MayaApi1_1.htm

Dependency Node == a node that has attributes that can depend on another. All nodes are dependency nodes (including dag nodes). A good example would be a material.

DAG Node == a transform or a shape. These are things that physically exist within the scene. They can be parented, but not in a cyclic way, i.e.

joint1 -> joint2 -> joint1

would be illegal.

A Dag path is the path to an object, for instance:

joint1->joint2->joint3

would be the path to joint3. A dag node may have one or more dag paths to it, for example:

transform1->mesh1
transform2->mesh1
transform3->transform4->transform5->mesh1

There would be a single mesh node (i.e. one dependency node for it), but there are three paths to the mesh, given by the long names: (these are perfectly valid to use in mel!)

|transform1|mesh1
|transform2|mesh1
|transform3|transform4|transform5|mesh1

You can construct a dag path from MObjects if you want, i.e. (in psuedo code, but hopefully you'll see what i mean)

MDagPath p;
p.push("transform1");
p.push("mesh1");

MFnDagNode is just a fuction set to ease access to a dag node. So, lets say i was to do something like this:

MObject o = getMobjectFromSomewhereFor("mesh1");
MFnDagNode fn(o);

now, the function set has been initialised by an MObject to mesh1. But, MObject is basically just a direct pointer to the mesh. If i tried to get the world space matrix from that mesh, how does the API know which instance of mesh1 to return? The answer is that it doesn't, so it just fails and returns the local space matrix.

So, instead we can initialise the function set with a dag path, i.e.

MDagPath p;
p.push("transform1");
p.push("mesh1");
MFnDagNode fn(p);

now the function set knows which instance we are talking about, and can give us back some world space data. Uhm, if that makes sense up to now, then cool, that's more or less all you need to know about....

but, one last thing that can happen, but is extremely rare (the GUI doesn't let you do it, you have to do this with mel or the API)....

It makes a lot of sense with the shape nodes, but the same can also apply to transforms, i.e:

|joint1
|joint2|joint1
|joint3|joint2|joint1
|joint5|joint1

the above paths to joint1 are all valid, which is why if you did this:

MFnDagNode fn( joint1 );

you get the funcs:

fn.parentCount();
fn.parent( instance_num );

uhm. hope that makes sense. In reality instanced transforms are extremely rare - infact i've never seen a Maya file with them unless i purposefully created one.

Dashboard_avatar
Feb 16, 2008
Post id: 271883 Report Item

QUOTE(David Doria @ 02/16/08, 11:29 AM) [snapback]281205[/snapback]
DAG is directed acyclic graph, basically a tree structure that allows multiple parents.

yes.

QUOTE
This is whole thing that Maya works with, the entire scene is stored in this DAG.

No. The entire scene is stored in the dependency graph (DG) as sets of Dependency nodes. The DAG nodes are a subset of the data, i.e. just the transforms and shapes, and they exist in second structure known as the DAG. Things such as skin clusters, materials, textures etc are all DG nodes, not DAG nodes....

QUOTE
Each "thing" that a non Mayan would think is an object (like a sphere) is actually two things; a transform structure that describes the location in the world and a mesh structure that describes the size of the object and the number of triangles etc etc.


Ok, so you create a mesh node*. It has faces, some vertices, normals etc. This DOES not have a physical presence at all. You cant see it, you can't position it, because it is just a collection of attributes on a dependency node. In order to see the node, you have to position it within the scene by parenting it underneath a transform node (or multiple nodes).

* Maya won't actually let you create a mesh node on it's own, it will always create a transform by default. This can mess you up if you are not aware of it, an example:

CODE
MFnMesh fn;
MObject obj = fn.create( /*some params missing */);

//
// at this point, obj will actually hold a refernce to the transform node that got
// created, rather than the mesh node. fn will also be invalid because maya attempts to
// attach the function set to the transform node, which fails.... so, fix it like so:
//

MFnTransform fnX( obj );
fn.setObject( fnX.child(0) );


QUOTE
It seems that the transform is generally the parent node of the mesh node. Is that correct?


a mesh will always have at least one parent transform to position it in the world. It may have a few transforms positioning it multiple times in the world.

QUOTE
So I guess my confusion comes down to what is a DagNode vs a DagPath?


A dag node is just a dependency node. A dag node can have multiple child nodes. A dag node can also have multiple parent nodes. A dag path uniquely identifies a given instance of a dag node within the scene.

QUOTE
I suppose a camera and a sphere should be pretty much the same in Maya's DAG, but I seem to have a whole different way to get attributes of a camera vs a mesh.


They are more or less the same. You can use the common base class MFnDagNode to access the data of both, you just have to use the findPlug() method to pull data directly from attributes. To simplify things a little bit, the classes MFnCamera and MFnMesh are provided to simply the data access.

Try this for example, initialise an MFnCamera using an MObject and get the eyePoint passing in MSpace::kWorld. Then try initialising the MFnCamera using an MDagPath to the camera, and get the eyePoint() again using MSpace::kWorld. You should notice the difference! The same is also true if you try to get points or normals from a msh using MSpace::kWorld.

Dashboard_avatar
Feb 17, 2008
Post id: 271884 Report Item

thanks man, I read it tonight, but I've got to spend tomorrow figuring out what it means!!

Write a Post

You must be logged in to Post

Login at the top of this page, or click here to create an account.

Related Marketplace Items

  • 000

  • Camaro01

  • Subwaygates3

  • S3d-cloths-casual0

  • Gargoyle2

  • 1

  • Hans03

  • Kitchen_0007_01