Exemplo n.º 1
0
bool util::isDrivenBySplineIK(const MFnIkJoint & iJoint)
{
    // spline IK can drive the starting joint's translate channel but
    // it has no connection to the translate plug.
    // we treat the joint as animated in this case.
    // find the ikHandle node.
    MPlug msgPlug = iJoint.findPlug("message", false);
    MPlugArray msgPlugDst;
    msgPlug.connectedTo(msgPlugDst, false, true);
    for (unsigned int i = 0; i < msgPlugDst.length(); i++) {
        MFnDependencyNode ikHandle(msgPlugDst[i].node());
        if (!ikHandle.object().hasFn(MFn::kIkHandle)) continue;

        // find the ikSolver node.
        MPlug ikSolverPlug = ikHandle.findPlug("ikSolver");
        MPlugArray ikSolverDst;
        ikSolverPlug.connectedTo(ikSolverDst, true, false);
        for (unsigned int j = 0; j < ikSolverDst.length(); j++) {

            // return true if the ikSolver is a spline solver.
            if (ikSolverDst[j].node().hasFn(MFn::kSplineSolver)) {
                return true;
            }
        }
    }
    
    return false;
}
Exemplo n.º 2
0
    // getBindPoseMatrix.
    // should be a relatively harmless function.
    // well you're wrong: this is one of the most stupid/difficult things in
    // Maya:
    //   1st try: just get the "bindPose"-plug, and use it as matrix:
    //             MFnIkJoint joint(jointPath.node());
    //             MPlug bindMatrixPlug = joint.findPlug("bindPose");
    //             MObject bindMatrixObject;
    //             bindMatrixPlug.getValue(bindMatrixObject);
    //             MFnMatrixData matrixData(bindMatrixObject);
    //             MMatrix bindMatrix = matrixData.matrix();
    //      Looks correct. But isn't. Not only, that we want the local
    //      transform (but that wouldn't be difficult (just look at the
    //      parent...), the bindPose plug seems
    //      to be shared between instances. If a joint is instanced, the
    //      bindMatrix would be the same as for the other instance. Bad luck :(
    //   2nd try: extract the local-transform out of the bindPose-plug. That's
    //      what is done here. (at least for now. (seen first in
    //      MS' xporttranslator).
    //      Still not the really correct way: it's possible to break the
    //      bindPose-plug. Maya still works, but our exporter doesn't.
    //   3rd (and correct way):
    //        http://www.greggman.com/pages/mayastuff.htm
    //
    // again: not yet very much error-checking...
    MMatrix
    BindPoseTool::getBindPoseMatrix(MFnIkJoint joint) const
    {
        // get bindPose-plug on joint
        MPlug tempBindPosePlug = joint.findPlug("bindPose");

        MPlugArray mapConnections;
        tempBindPosePlug.connectedTo(mapConnections, false, true);

        if (mapConnections.length() != 1)
        {
            //cout << "returning currentMatrix" << endl;
            // certainly not the most correct way of dealing with the problem...
            return joint.transformation().asMatrix();
        }

        // find the other end. actually we shouldn't call it "bindPosePlug",
        // but worldTransformPlug (as that's where it enters).

        // theoretically someone could bind the bindPose to other nodes,
        // than the bindPose-node. in this case there's a problem.
        MPlug bindPosePlug = mapConnections[0];

        // this node should be a "dagPose"-node (in case you want to look it
        // up in the help)
        MFnDependencyNode bindPoseNode(bindPosePlug.node());

        // and as such, has the "xformMatrix"-attribute.
        MObject xformMatrixAttribute = bindPoseNode.attribute("xformMatrix");

        MPlug localTransformPlug(bindPosePlug.node(), xformMatrixAttribute);
        // xformMatrix is an array. to get our localmatrix we need to select
        // the same index, as our bindPosePlug (logicalIndex()).
        localTransformPlug.selectAncestorLogicalIndex(
                            bindPosePlug.logicalIndex(), xformMatrixAttribute);

        MObject localMatrixObject;
        localTransformPlug.getValue(localMatrixObject);
        // extract the matrix out of the object.
        return MFnMatrixData(localMatrixObject).matrix();
    }
Exemplo n.º 3
0
bool util::isDrivenByFBIK(const MFnIkJoint & iJoint)
{
    // 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.
    MStatus status = MS::kSuccess;
    if (iJoint.hikJointName(&status).length() > 0 && status) {
        return true;
    }
    return false;
}
Exemplo n.º 4
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));
		}
	}
}
Exemplo n.º 5
0
void addRibbonAttributes(MFnIkJoint& joint)
{
	joint.addAttribute(unCreateRibbonSystem::unRibbonEnabled);
	joint.addAttribute(unCreateRibbonSystem::unRibbonVisible);
	joint.addAttribute(unCreateRibbonSystem::unRibbonAbove);
	joint.addAttribute(unCreateRibbonSystem::unRibbonBelow);
	joint.addAttribute(unCreateRibbonSystem::unRibbonEdgesPerSecond);
	joint.addAttribute(unCreateRibbonSystem::unRibbonEdgeLife);
	joint.addAttribute(unCreateRibbonSystem::unRibbonGravity);
	joint.addAttribute(unCreateRibbonSystem::unRibbonTextureRows);
	joint.addAttribute(unCreateRibbonSystem::unRibbonTextureCols);
	joint.addAttribute(unCreateRibbonSystem::unRibbonTextureSlot);
	joint.addAttribute(unCreateRibbonSystem::unRibbonVertexColor);
	joint.addAttribute(unCreateRibbonSystem::unRibbonVertexAlpha);
	joint.addAttribute(unCreateRibbonSystem::unRibbonBlendMode);
	joint.addAttribute(unCreateRibbonSystem::unRibbonWanderMode);
	//joint.addAttribute(unCreateRibbonSystem::unRibbonBlendModeSrc);
	//joint.addAttribute(unCreateRibbonSystem::unRibbonBlendModeDst);
	joint.addAttribute(unCreateRibbonSystem::unRibbonTextureFilename);
}
Exemplo n.º 6
0
void addParticleAttributes(MFnIkJoint& joint)
{
	joint.addAttribute(unCreateParticleSystem::unParticleEnabled);
	joint.addAttribute(unCreateParticleSystem::unParticleVisible);
	joint.addAttribute(unCreateParticleSystem::unParticleSpeed);
	joint.addAttribute(unCreateParticleSystem::unParticleVariation);
	joint.addAttribute(unCreateParticleSystem::unParticleConeAngle);
	joint.addAttribute(unCreateParticleSystem::unParticleGravity);
	joint.addAttribute(unCreateParticleSystem::unParticleExplosiveForce);
	joint.addAttribute(unCreateParticleSystem::unParticleLife);
	joint.addAttribute(unCreateParticleSystem::unParticleLifeVariation);
	joint.addAttribute(unCreateParticleSystem::unParticleEmissionRate);
	joint.addAttribute(unCreateParticleSystem::unParticleInitialNum);
	joint.addAttribute(unCreateParticleSystem::unParticleLimitNum);
	joint.addAttribute(unCreateParticleSystem::unParticleAttachToEmitter);
	joint.addAttribute(unCreateParticleSystem::unParticleMoveWithEmitter);
	joint.addAttribute(unCreateParticleSystem::unParticleForTheSword);
	joint.addAttribute(unCreateParticleSystem::unParticleForTheSwordInitialAngle);
	joint.addAttribute(unCreateParticleSystem::unParticleWander);
	joint.addAttribute(unCreateParticleSystem::unParticleWanderRadius);
	joint.addAttribute(unCreateParticleSystem::unParticleWanderSpeed);
	joint.addAttribute(unCreateParticleSystem::unParticleAspectRatio);
	joint.addAttribute(unCreateParticleSystem::unParticleInitialAngleBegin);
	joint.addAttribute(unCreateParticleSystem::unParticleInitialAngleEnd);
	joint.addAttribute(unCreateParticleSystem::unParticleRotationSpeed);
	joint.addAttribute(unCreateParticleSystem::unParticleRotationSpeedVar);
	joint.addAttribute(unCreateParticleSystem::unParticleEmitterWidth);
	joint.addAttribute(unCreateParticleSystem::unParticleEmitterLength);
	joint.addAttribute(unCreateParticleSystem::unParticleEmitterHeight);
	joint.addAttribute(unCreateParticleSystem::unParticleBlendMode);
	//joint.addAttribute(unCreateParticleSystem::unParticleBlendModeSrc);
	//joint.addAttribute(unCreateParticleSystem::unParticleBlendModeDst);
	joint.addAttribute(unCreateParticleSystem::unParticleTextureFilename);
	joint.addAttribute(unCreateParticleSystem::unParticleTextureRows);
	joint.addAttribute(unCreateParticleSystem::unParticleTextureCols);
	joint.addAttribute(unCreateParticleSystem::unParticleTextureChangeStyle);
	joint.addAttribute(unCreateParticleSystem::unParticleTextureChangeInterval);
	joint.addAttribute(unCreateParticleSystem::unParticleTailLength);
	joint.addAttribute(unCreateParticleSystem::unParticleTimeMiddle);
	joint.addAttribute(unCreateParticleSystem::unParticleColorStart);
	joint.addAttribute(unCreateParticleSystem::unParticleColorMiddle);
	joint.addAttribute(unCreateParticleSystem::unParticleColorEnd);
	joint.addAttribute(unCreateParticleSystem::unParticleAlpha);
	joint.addAttribute(unCreateParticleSystem::unParticleScale);
	joint.addAttribute(unCreateParticleSystem::unParticleScaleVar);
	joint.addAttribute(unCreateParticleSystem::unParticleFixedSize);
	joint.addAttribute(unCreateParticleSystem::unParticleHeadLifeSpan);
	joint.addAttribute(unCreateParticleSystem::unParticleHeadDecay);
	joint.addAttribute(unCreateParticleSystem::unParticleTailLifeSpan);
	joint.addAttribute(unCreateParticleSystem::unParticleTailDecay);
	joint.addAttribute(unCreateParticleSystem::unParticleHead);
	joint.addAttribute(unCreateParticleSystem::unParticleTail);
	joint.addAttribute(unCreateParticleSystem::unParticleUnShaded);
	joint.addAttribute(unCreateParticleSystem::unParticleUnFogged);
	joint.addAttribute(unCreateParticleSystem::unParticleBlockByY0);
}
Exemplo n.º 7
0
void removeRibbonAttributes(MFnIkJoint& joint)
{
	joint.removeAttribute(joint.attribute("unRibbonEnabled"));
	joint.removeAttribute(joint.attribute("unRibbonVisible"));
	joint.removeAttribute(joint.attribute("unRibbonAbove"));
	joint.removeAttribute(joint.attribute("unRibbonBelow"));
	joint.removeAttribute(joint.attribute("unRibbonEdgesPerSecond"));
	joint.removeAttribute(joint.attribute("unRibbonEdgeLife"));
	joint.removeAttribute(joint.attribute("unRibbonGravity"));
	joint.removeAttribute(joint.attribute("unRibbonTextureRows"));
	joint.removeAttribute(joint.attribute("unRibbonTextureCols"));
	joint.removeAttribute(joint.attribute("unRibbonTextureSlot"));
	joint.removeAttribute(joint.attribute("unRibbonVertexColor"));
	joint.removeAttribute(joint.attribute("unRibbonVertexAlpha"));
	joint.removeAttribute(joint.attribute("unRibbonBlendMode"));
	joint.removeAttribute(joint.attribute("unRibbonWanderMode"));
	//joint.removeAttribute(joint.attribute("unRibbonBlendModeSrc"));
	//joint.removeAttribute(joint.attribute("unRibbonBlendModeDst"));
	joint.removeAttribute(joint.attribute("unRibbonTextureFilename"));
}
Exemplo n.º 8
0
void removeParticleAttributes(MFnIkJoint& joint)
{
	joint.removeAttribute(joint.attribute("unParticleEnabled"));
	joint.removeAttribute(joint.attribute("unParticleVisible"));
	joint.removeAttribute(joint.attribute("unParticleSpeed"));
	joint.removeAttribute(joint.attribute("unParticleVariation"));
	joint.removeAttribute(joint.attribute("unParticleConeAngle"));
	joint.removeAttribute(joint.attribute("unParticleGravity"));
	joint.removeAttribute(joint.attribute("unParticleExplosiveForce"));
	joint.removeAttribute(joint.attribute("unParticleLife"));
	joint.removeAttribute(joint.attribute("unParticleLifeVariation"));
	joint.removeAttribute(joint.attribute("unParticleEmissionRate"));
	joint.removeAttribute(joint.attribute("unParticleInitialNum"));
	joint.removeAttribute(joint.attribute("unParticleLimitNum"));
	joint.removeAttribute(joint.attribute("unParticleAttachToEmitter"));
	joint.removeAttribute(joint.attribute("unParticleMoveWithEmitter"));
	joint.removeAttribute(joint.attribute("unParticleForTheSword"));
	joint.removeAttribute(joint.attribute("unParticleForTheSwordInitialAngle"));
	joint.removeAttribute(joint.attribute("unParticleWander"));
	joint.removeAttribute(joint.attribute("unParticleWanderRadius"));
	joint.removeAttribute(joint.attribute("unParticleWanderSpeed"));
	joint.removeAttribute(joint.attribute("unParticleAspectRatio"));
	joint.removeAttribute(joint.attribute("unParticleInitialAngleBegin"));
	joint.removeAttribute(joint.attribute("unParticleInitialAngleEnd"));
	joint.removeAttribute(joint.attribute("unParticleRotationSpeed"));
	joint.removeAttribute(joint.attribute("unParticleRotationSpeedVar"));
	joint.removeAttribute(joint.attribute("unParticleEmitterWidth"));
	joint.removeAttribute(joint.attribute("unParticleEmitterLength"));
	joint.removeAttribute(joint.attribute("unParticleEmitterHeight"));
	joint.removeAttribute(joint.attribute("unParticleBlendMode"));
	//joint.removeAttribute(joint.attribute("unParticleBlendModeSrc"));
	//joint.removeAttribute(joint.attribute("unParticleBlendModeDst"));
	joint.removeAttribute(joint.attribute("unParticleTextureFilename"));
	joint.removeAttribute(joint.attribute("unParticleTextureRows"));
	joint.removeAttribute(joint.attribute("unParticleTextureCols"));
	joint.removeAttribute(joint.attribute("unParticleTextureChangeStyle"));
	joint.removeAttribute(joint.attribute("unParticleTextureChangeInterval"));
	joint.removeAttribute(joint.attribute("unParticleTailLength"));
	joint.removeAttribute(joint.attribute("unParticleTimeMiddle"));
	joint.removeAttribute(joint.attribute("unParticleColorStart"));
	joint.removeAttribute(joint.attribute("unParticleColorMiddle"));
	joint.removeAttribute(joint.attribute("unParticleColorEnd"));
	joint.removeAttribute(joint.attribute("unParticleAlpha"));
	joint.removeAttribute(joint.attribute("unParticleScale"));
	joint.removeAttribute(joint.attribute("unParticleScaleVar"));
	joint.removeAttribute(joint.attribute("unParticleFixedSize"));
	joint.removeAttribute(joint.attribute("unParticleHeadLifeSpan"));
	joint.removeAttribute(joint.attribute("unParticleHeadDecay"));
	joint.removeAttribute(joint.attribute("unParticleTailLifeSpan"));
	joint.removeAttribute(joint.attribute("unParticleTailDecay"));
	joint.removeAttribute(joint.attribute("unParticleHead"));
	joint.removeAttribute(joint.attribute("unParticleTail"));
	joint.removeAttribute(joint.attribute("unParticleUnShaded"));
	joint.removeAttribute(joint.attribute("unParticleUnFogged"));
	joint.removeAttribute(joint.attribute("unParticleBlockByY0"));
}
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);
}