Questions on DzBone
mattiascibien
Posts: 140
Hello,
my thesis finally got serious and I have to extend it a bit starting with DzBones.
I have two questions about it.
The first: can I get the geometry associated to the DzBone (like when you select one in the viewport) and how should I do this?
The second: the hierarchy you see in the Scene panel can be accessed also from code?
Comments
Hierarchy is the Node hierarchy. See DzNode::getNodeChildren()
The geometry is on the root DzNode of the figure. So think skeleton->getObject()->getCurrentShape()->getGeometry(). cast that to a DzFacetMesh and go from there. There is a selection map the associates what facet goes to which bone.
I have found how to get the mesh. The problem is that I am not able to find what you told me. There is a
getAllEdgesForGroup (DzFaceGroup *group, DzTSortedArray< int > &edges;) const
and a
DzFaceGroup * findFaceGroup (const QString &name;, int *index=NULL) const
in the documentation. But I am not so sure on wht name should I pass to the second function.
Does this help?:
That is actually pretty cool but I need to find geometries for specific bones like torso, head and abdomen to make a raycast and detect the bone the ray intersects (I acuallyhave a bridge to Bullet for the raycast but I need to send geometries to it).
Mesh doesn't necessarily belong to bones as it did in older versions of DS and Poser - it may have a group, which may be associated with a bone, butt hat's really cosmetic (so that you can click on it to select the bone) rather than needed for a figure to work.
All geometry is on the skeleton. The selection map is a mapping from faceGroup to bone.
DzNode::getSelectionMap
Ok but what I need is to get the vertices of only a part of a figure, not just a bone. For example I need to get the geometry for the upper body and I thought that if I am able to see them selected in the viewport I will be able to get them by code. Is this possible?
You need the selection map mentioned by dtamm, that's the thing that determines which areas select a bone when clicked.
I got this. But I actually need all of them, not just the selected ones. Should I use DzFaceGroup* faceGroup = facetMesh->getFaceGroup(i); Does these FaceGoups have names associated (like abdomen, ...).
Sorry for bothering you about this but I really need them for my thesis.
The selection map sets the relationship between the mesh and the bones, for the purposes of clicking in the viewport and visibility. If for each bone you invoke getSelectionMap that should enable you to get the mesh for each bone - it has nothing to do with whether or not they are currently selected, as I understand it. Of course you need to allow for bones with no selection map, and polygons that don't belong to any bone's selection map (though the latter should be rare, for Poser-compatibility).
Thanks for pointing me in the right direction. I'll check the docs and then tell you what I find :)
EDIT: check out. I have arrived to the DzSelectionMap but I cannot get any geometry from that.
i published the .cpp code for the mcjColllider node (plugin) for DS4.5
https://sites.google.com/site/mcasualsdazscripts2/mcjcolliderds45
here's how i handle selected bones
if the object is a bone, i go through the faces in the faceGroup
if it's a figure or a prop, i go through all the faces of the mesh
Looks like what I need Casual :) Thank you :) I will keep you posted.
EDIT: So face groups are named after the bone :)
it seems to work so far though i only tested this on Aiko3
... i think
... nope, i tested it on Genesis too! since that's how i built her dress
hmm, well i used the whole body as a collision object .... so i guess more testing of this would be needed
I have arrived to get the edges of the face groups. But as they are edges I need to build triangles.
I did it from facets in another piece of code. Is there a way to use the facets of the facegroup instead of the edges?