Beispiel #1
0
void EntityInstanceNode::Flatten()
{
    EntityNode& instanceClassNode = EntityNode::Get( m_Entity->GetEntity()->GetPath() );

    if( instanceClassNode == EntityNode::Null )
        return;

    MFnDagNode instanceFn( thisMObject() );

    MFnDagNode nodeFn( instanceClassNode.thisMObject() );
    u32 len = nodeFn.childCount();

    MDagPath path;
    MFnTransform newTransformFn;
    MObject newTransform = newTransformFn.create();

    MTransformationMatrix matrix = instanceFn.transformationMatrix();
    newTransformFn.set( matrix );
    newTransformFn.getPath( path );

    for( u32 i = 0; i < len; ++i )
    {
        MFnDagNode nodeFn( nodeFn.child( i ) );

        MDagPath child;
        nodeFn.getPath( child );
        MDagPath result;

        Maya::duplicate( child, path, result, false, false );
    }

    Maya::LockHierarchy( thisMObject(), false );
}
MStatus lrutils::makeHomeNull(MObject obj, MFnTransform& transformFn, MObject& groupObj) {
    MStatus status = MS::kFailure;
    
    status = transformFn.setObject(obj);
    MyCheckStatusReturn(status, "invalid MObject provided for MFnTransform.setObject()");

    if( status == MS::kSuccess ) {
        MDagModifier dagMod;
        groupObj = dagMod.createNode( "transform", MObject::kNullObj, &status );
        MyCheckStatusReturn(status, "MDagModifier.createNode() failed");
        dagMod.doIt();

        MFnTransform groupFn;
        groupFn.setObject(groupObj);
        groupFn.set(transformFn.transformation());
        groupFn.addChild(obj);
        
        MString groupName = transformFn.name();
        groupName = groupName.substring(0, groupName.numChars() - 4);
        groupName += "GRP";
        groupFn.setName(groupName);
        
    }

    return status;
}