Exemplo n.º 1
0
void MayaTransformWriter::pushTransformStack(const MFnIkJoint & iJoint,
	bool iForceStatic)
{
	// check joints that are driven by Maya FBIK
	// Maya FBIK has no connection to joints' TRS plugs
	// but TRS of joints are driven by FBIK, they are not static
	// Maya 2012's new HumanIK has connections to joints.
	// FBIK is a special case.
	bool forceAnimated = false;
	MStatus status = MS::kSuccess;
	if (iJoint.hikJointName(&status).length() > 0 && status) {
		forceAnimated = true;
	}

	// inspect the translate
	addTranslate(iJoint, "translate", "translateX", "translateY", "translateZ",
		Alembic::AbcGeom::kTranslateHint, false, iForceStatic, forceAnimated,
		mSample, mAnimChanList);

	// inspect the inverseParent scale
	// [IS] is ignored when Segment Scale Compensate is false
	MPlug scaleCompensatePlug = iJoint.findPlug("segmentScaleCompensate");
	if (scaleCompensatePlug.asBool())
	{
		addScale(iJoint, "inverseScale", "inverseScaleX", "inverseScaleY",
			"inverseScaleZ", true, iForceStatic, forceAnimated, mSample, mAnimChanList);
	}

	MTransformationMatrix::RotationOrder eJointOrientOrder, eRotOrder, eRotateAxisOrder;
	double vals[3];

	// for reordering rotate names
	MString rotateNames[3];
	unsigned int rotOrder[3];

	// now look at the joint orientation
	rotateNames[0] = "jointOrientX";
	rotateNames[1] = "jointOrientY";
	rotateNames[2] = "jointOrientZ";

	iJoint.getOrientation(vals, eJointOrientOrder);
	if (util::getRotOrder(eJointOrientOrder, rotOrder[0], rotOrder[1], rotOrder[2]))
	{
		addRotate(iJoint, "jointOrient", rotateNames, rotOrder,
			Alembic::AbcGeom::kRotateHint, iForceStatic, true,
			mSample, mAnimChanList, mJointOrientOpIndex);
	}

	rotateNames[0] = "rotateX";
	rotateNames[1] = "rotateY";
	rotateNames[2] = "rotateZ";

	// if this returns false then the rotation order was kInvalid or kLast
	eRotOrder = iJoint.rotationOrder();
	if (util::getRotOrder(eRotOrder, rotOrder[0], rotOrder[1],
		rotOrder[2]))
	{
		addRotate(iJoint, "rotate", rotateNames, rotOrder,
			Alembic::AbcGeom::kRotateHint, iForceStatic, true,
			mSample, mAnimChanList, mRotateOpIndex);
	}

	// now look at the rotation orientation, aka rotate axis
	rotateNames[0] = "rotateAxisX";
	rotateNames[1] = "rotateAxisY";
	rotateNames[2] = "rotateAxisZ";

	iJoint.getScaleOrientation(vals, eRotateAxisOrder);
	if (util::getRotOrder(eRotateAxisOrder, rotOrder[0], rotOrder[1], rotOrder[2]))
	{
		addRotate(iJoint, "rotateAxis", rotateNames, rotOrder,
			Alembic::AbcGeom::kRotateOrientationHint, iForceStatic, true,
			mSample, mAnimChanList, mRotateAxisOpIndex);
	}

	// inspect the scale
	addScale(iJoint, "scale", "scaleX", "scaleY", "scaleZ", false,
		iForceStatic, forceAnimated, mSample, mAnimChanList);

	// remember current rotation
	if (mFilterEulerRotations)
	{
		double xx(0), yy(0), zz(0);

		// there are 2 rotation order enum definitions:
		//	 MEulerRotation::RotationOrder = MTransformationMatrix::RotationOrder-1
		if (getSampledRotation( mSample, mJointOrientOpIndex, xx, yy, zz ))
		{
			mPrevJointOrientSolution.setValue(xx, yy, zz, (MEulerRotation::RotationOrder)(eJointOrientOrder-1));
		}

		if (getSampledRotation( mSample, mRotateOpIndex, xx, yy, zz ))
		{
			mPrevRotateSolution.setValue(xx, yy, zz, (MEulerRotation::RotationOrder)(eRotOrder-1));
		}

		if (getSampledRotation( mSample, mRotateAxisOpIndex, xx, yy, zz ))
		{
			mPrevRotateAxisSolution.setValue(xx, yy, zz, (MEulerRotation::RotationOrder)(eRotateAxisOrder-1));
		}
	}
}
void MayaTransformWriter::pushTransformStack(double iFrame,
    const MFnIkJoint & iJoint)
{
    bool forceStatic = (iFrame == DBL_MAX);

    // inspect the translate
    addTranslate(iJoint, "translate", "translateX", "translateY", "translateZ",
        Alembic::AbcGeom::kTranslateHint, false, forceStatic,
        mSample, mAnimChanList);

    // inspect the inverseParent scale
    addScale(iJoint, "inverseScale", "inverseScaleX", "inverseScaleY",
        "inverseScaleZ", forceStatic, mSample, mAnimChanList);

    MTransformationMatrix::RotationOrder order;
    double vals[3];

    // for reordering rotate names
    MString rotateNames[3];
    unsigned int rotOrder[3];

    // now look at the joint orientation
    rotateNames[0] = "jointOrientX";
    rotateNames[1] = "jointOrientY";
    rotateNames[2] = "jointOrientZ";

    iJoint.getOrientation(vals, order);
    if (util::getRotOrder(order, rotOrder[0], rotOrder[1], rotOrder[2]))
    {
        addRotate(iJoint, "jointOrient", rotateNames, rotOrder,
            Alembic::AbcGeom::kRotateHint, forceStatic, true,
            mSample, mAnimChanList);
    }

    rotateNames[0] = "rotateX";
    rotateNames[1] = "rotateY";
    rotateNames[2] = "rotateZ";

    // if this returns false then the rotation order was kInvalid or kLast
    if (util::getRotOrder(iJoint.rotationOrder(), rotOrder[0], rotOrder[1],
        rotOrder[2]))
    {
        addRotate(iJoint, "rotate", rotateNames, rotOrder,
            Alembic::AbcGeom::kRotateHint, forceStatic, true,
            mSample, mAnimChanList);
    }

    // now look at the rotation orientation, aka rotate axis
    rotateNames[0] = "rotateAxisX";
    rotateNames[1] = "rotateAxisY";
    rotateNames[2] = "rotateAxisZ";

    iJoint.getScaleOrientation(vals, order);
    if (util::getRotOrder(order, rotOrder[0], rotOrder[1], rotOrder[2]))
    {
        addRotate(iJoint, "rotateAxis", rotateNames, rotOrder,
            Alembic::AbcGeom::kRotateOrientationHint, forceStatic, true,
            mSample, mAnimChanList);
    }

    // inspect the scale
    addScale(iJoint, "scale", "scaleX", "scaleY", "scaleZ", forceStatic,
        mSample, mAnimChanList);
}