AbcExport: How to export the bbox of hierarchical xform nodes?

AbcExport: How to export the bbox of hierarchical xform nodes?

Anonymous
Not applicable
557 Views
0 Replies
Message 1 of 1

AbcExport: How to export the bbox of hierarchical xform nodes?

Anonymous
Not applicable

 

How to export the bbox of hierarchical xform nodes?

Hi all,

I'm going to extend Maya2014 AbcExport plugin to export the bbox of hierarchical xform nodes. But I encountered some problems.

For example, here are the hierarchical xform nodes in maya:

group3                              (xform)
   |___group1                       (xform)
   |      |___pCube1                (xform)
   |      |      |____pCubeShape1   (polygon)
   |      |___pCube2                (xform)
   |             |____pCubeShape2   (polygon)
   |___group2                       (xform)
   |      |___pCube3                (xform)
   |      |      |____pCubeShape3   (polygon)
   |      |___pCube4                (xform)
   |             |____pCubeShape4   (polygon)

I'm going to export the bbox of every xform node, e.g. group1, group2, group3, pCube1, pCube2, pCube3, pCube4.


I modified MayaTransformWrite.cpp like this:

----------------------------------
class MayaTransformWriter
{
    ...
    Alembic::Abc::OBox3dProperty myTransBoxProp;    
    MDagPath myTransDag;
}
----------------------------------
MayaTransformWriter::MayaTransformWriter(Alembic::AbcGeom::OObject & iParent, ...)
{
    if (iDag.hasFn(MFn::kJoint))
    {
    ...
    }else{
            ...
            mAttrs = AttributesWriterPtr(new AttributesWriter(cp, up, obj, trans, iTimeIndex, iArgs));
            
            myTransDag = iDag;// save current dag to myTransDag
            MyTest(myTransDag);
            ...
    }
    ...
}
----------------------------------
MayaTransformWriter::MayaTransformWriter(MayaTransformWriter & iParent, ...)
{
    if (iDag.hasFn(MFn::kJoint))
    {
    ...
    }else{
            ...
            mAttrs = AttributesWriterPtr(new AttributesWriter(cp, up, obj, trans, iTimeIndex, iArgs));
            
            myTransDag = iDag;// save current dag to myTransDag
            MyTest(myTransDag);
            ...
    }
    ...
}
----------------------------------
void MayaTransformWriter::write()
{
    size_t numSamples = mAnimChanList.size();
    if (numSamples > 0)
    {
        ...
        mSchema.set(mSample);

        MyTest(myTransDag);// use myTransDag
    }
}
----------------------------------
void MayaTransformWriter::MyTest(MDagPath iDag)
{
    MStatus status;

    unsigned int childCount = iDag.childCount(&status);
    CHECK_MSTATUS(status);

    if(childCount > 0)
    {
        MObject child(iDag.child(0, &status));     CHECK_MSTATUS(status);

        MFnDagNode fnChildDagNode(child, &status);     CHECK_MSTATUS(status);

        MDagPath childDagPath; status = fnChildDagNode.getPath(childDagPath);  CHECK_MSTATUS(status);//
        printf("fnDagNode.getPath(&): %s\n", childDagPath.fullPathName().asChar());
        if(!childDagPath.isValid(&status))
        {
            CHECK_MSTATUS(status);
            childDagPath = fnChildDagNode.dagPath(&status);     CHECK_MSTATUS(status);//
            printf("fnDagNode.dagPath()=%s\n", childDagPath.fullPathName().asChar());
        }
        assert(!childDagPath.isNull() && "childDagPath is null");

        if(childDagPath.apiType() == MFn::kMesh) // child node is a mesh shape node
        {
            setAbcBBoxFromNode(fnChildDagNode);
        }else{
            if(isAnimated())
            {
                setAbcBBoxFromNode_animation(iDag); // <---- export the bbox for animation xform node
                //setAbcBBoxFromNode(iDag);
            }else{
                setAbcBBoxFromNode(iDag);
            }

        }

    }else{
        printf("it has no child\n");
    }
}

void MayaTransformWriter::setAbcBBoxFromNode(const MFnDagNode &fnDag)
{
    transBoxProp = mSchema.getChildBoundsProperty();
    MBoundingBox bbox;
    bbox = fnDag.boundingBox();
    Alembic::Abc::V3d min(bbox.min().x, bbox.min().y, bbox.min().z);
    Alembic::Abc::V3d max(bbox.max().x, bbox.max().y, bbox.max().z);
    Alembic::Abc::Box3d b(min, max);
    transBoxProp.set(b);
}
void MayaTransformWriter::setAbcBBoxFromNode_animation(const MDagPath &inDagPath)
{
   //  how to export the bbox for animation xform node?
}

 

setAbcBBoxFromNode() can't handle the animation xform correctly, so I have to implement another setAbcBBoxFromNode_animation() for the animation xform node. I tried several ways but failed.

 

 

So my questions are:
- I don't know how to implement function setAbcBBoxFromNode_animation(). Could you give me any clue or any suggestion?
- Is there any simpler method to export the bbox of the hierarchical xform node?

 

Cheers
yao

 

 

 

0 Likes
558 Views
0 Replies
Replies (0)