Questions on DzBone

mattiascibienmattiascibien 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

  • dtammdtamm Posts: 126
    edited December 1969

    gravity0 said:
    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?

    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.

  • mattiascibienmattiascibien Posts: 140
    edited December 1969

    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.

  • ammon_fde0d92863ammon_fde0d92863 Posts: 119
    edited December 1969

    gravity0 said:
    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?:

    
    for(int i = 0; i < facetMesh->getNumFaceGroups(); i++)
    {
      DzFaceGroup* faceGroup = facetMesh->getFaceGroup(i);
      DzTSortedArray edges; 
      facetMesh->getAllEdgesForGroup(faceGroup, edges);
    }
    
  • mattiascibienmattiascibien Posts: 140
    edited December 1969

    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).

  • Richard HaseltineRichard Haseltine Posts: 100,833
    edited December 1969

    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.

  • dtammdtamm Posts: 126
    edited December 1969

    All geometry is on the skeleton. The selection map is a mapping from faceGroup to bone.
    DzNode::getSelectionMap

  • mattiascibienmattiascibien Posts: 140
    edited December 1969

    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.

    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?

  • Richard HaseltineRichard Haseltine Posts: 100,833
    edited December 1969

    You need the selection map mentioned by dtamm, that's the thing that determines which areas select a bone when clicked.

  • mattiascibienmattiascibien Posts: 140
    edited December 1969

    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.

  • Richard HaseltineRichard Haseltine Posts: 100,833
    edited December 1969

    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).

  • mattiascibienmattiascibien Posts: 140
    edited January 2013

    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.

    Post edited by mattiascibien on
  • mCasualmCasual Posts: 4,607
    edited January 2013

    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

            DzSkeleton *targetNode;
            DzFaceGroup *faceGroup;
            for( int n = 0; n < numTargetNodes; n++ )
            {
                    targetNode = (DzSkeleton*) targetList.at( n );
                    if( !targetNode )
                    { 
                            return( false ); 
                    } //cause for concerm
                    bool bIsAbone;
                    DzFacetMesh *targetMesh = 0;
                    if( targetNode->inherits( "DzBone" ) )
                    {
                            bIsAbone = true;
                            QString boneName = targetNode->getName();
                            targetNode = targetNode->getSkeleton();
                            targetMesh = getCachedMesh( targetNode );
                            if( targetMesh )
                            {
                                    faceGroup = targetMesh->findFaceGroup( boneName );
                            }
                    }
                    else
                    {
                            bIsAbone = false;
                            targetMesh = getCachedMesh( targetNode );
                    }
    


    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

    Post edited by mCasual on
  • mattiascibienmattiascibien Posts: 140
    edited January 2013

    Looks like what I need Casual :) Thank you :) I will keep you posted.


    EDIT: So face groups are named after the bone :)

    Post edited by mattiascibien on
  • mCasualmCasual Posts: 4,607
    edited January 2013

    gravity0 said:
    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

    promodress.jpg
    1280 x 720 - 72K
    Post edited by mCasual on
  • mattiascibienmattiascibien Posts: 140
    edited December 1969

    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?

Sign In or Register to comment.