示例#1
0
文件: fbxRNode.cpp 项目: crimzon/osg
void readRotationElement(KFbxTypedProperty<fbxDouble3>& prop,
                         ERotationOrder fbxRotOrder,
                         bool quatInterpolate,
                         osgAnimation::UpdateMatrixTransform* pUpdate,
                         osg::Matrix& staticTransform)
{
    if (prop.GetKFCurve(KFCURVENODE_R_X) ||
        prop.GetKFCurve(KFCURVENODE_R_Y) ||
        prop.GetKFCurve(KFCURVENODE_R_Z))
    {
        if (quatInterpolate)
        {
            if (!staticTransform.isIdentity())
            {
                pUpdate->getStackedTransforms().push_back(
                    new osgAnimation::StackedMatrixElement(staticTransform));
                staticTransform.makeIdentity();
            }
            pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedQuaternionElement(
                "quaternion", makeQuat(prop.Get(), fbxRotOrder)));
        }
        else
        {
            char* curveNames[3] = {KFCURVENODE_R_X, KFCURVENODE_R_Y, KFCURVENODE_R_Z};
            osg::Vec3 axes[3] = {osg::Vec3(1,0,0), osg::Vec3(0,1,0), osg::Vec3(0,0,1)};

            fbxDouble3 fbxPropValue = prop.Get();
            fbxPropValue[0] = osg::DegreesToRadians(fbxPropValue[0]);
            fbxPropValue[1] = osg::DegreesToRadians(fbxPropValue[1]);
            fbxPropValue[2] = osg::DegreesToRadians(fbxPropValue[2]);

            int order[3] = {0, 1, 2};
            getRotationOrder(fbxRotOrder, order);

            for (int i = 0; i < 3; ++i)
            {
                int j = order[2-i];
                if (prop.GetKFCurve(curveNames[j]))
                {
                    if (!staticTransform.isIdentity())
                    {
                        pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedMatrixElement(staticTransform));
                        staticTransform.makeIdentity();
                    }

                    pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedRotateAxisElement(
                        std::string("rotate") + curveNames[j], axes[j], fbxPropValue[j]));
                }
                else
                {
                    staticTransform.preMultRotate(osg::Quat(fbxPropValue[j], axes[j]));
                }
            }
        }
    }
    else
    {
        staticTransform.preMultRotate(makeQuat(prop.Get(), fbxRotOrder));
    }
}
示例#2
0
文件: fbxRNode.cpp 项目: Jeff885/osg
void readScaleElement(FbxPropertyT<FbxDouble3>& prop,
                      osgAnimation::UpdateMatrixTransform* pUpdate,
                      osg::Matrix& staticTransform,
                      FbxScene& fbxScene)
{
    FbxDouble3 fbxPropValue = prop.Get();
    osg::Vec3d val(
        fbxPropValue[0],
        fbxPropValue[1],
        fbxPropValue[2]);

    if (isAnimated(prop, fbxScene))
    {
        if (!staticTransform.isIdentity())
        {
            pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedMatrixElement(staticTransform));
            staticTransform.makeIdentity();
        }
        pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedScaleElement("scale", val));
    }
    else
    {
        staticTransform.preMultScale(val);
    }
}
示例#3
0
文件: fbxRNode.cpp 项目: crimzon/osg
void readScaleElement(KFbxTypedProperty<fbxDouble3>& prop,
                      osgAnimation::UpdateMatrixTransform* pUpdate,
                      osg::Matrix& staticTransform)
{
    fbxDouble3 fbxPropValue = prop.Get();
    osg::Vec3d val(
        fbxPropValue[0],
        fbxPropValue[1],
        fbxPropValue[2]);

    if (prop.GetKFCurve(KFCURVENODE_S_X) ||
        prop.GetKFCurve(KFCURVENODE_S_Y) ||
        prop.GetKFCurve(KFCURVENODE_S_Z))
    {
        if (!staticTransform.isIdentity())
        {
            pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedMatrixElement(staticTransform));
            staticTransform.makeIdentity();
        }
        pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedScaleElement("scale", val));
    }
    else
    {
        staticTransform.preMultScale(val);
    }
}
示例#4
0
void Node::calculate_world_matrix(osg::Matrix& trans, int frame_num) {
	Node* node = this;
	trans.makeIdentity();
	while (node != NULL) {
		trans = trans * osg::Matrix::rotate(node->quat_arr.at(frame_num))
				* osg::Matrix::translate(
						node->offset + node->froset->at(frame_num));
		node = node->parent;
	}
}
示例#5
0
void Node::get_parent_to_bone_end_matrix(int frame_num, osg::Matrix& m) {

	m.makeIdentity();

	if (parent == NULL) {
		return;
	}

	//Calculate the transformation from the parent
	//to the end of this bone end position
	m = osg::Matrix::translate(local_end)
			* osg::Matrix::rotate(quat_arr.at(frame_num))
			* osg::Matrix::translate(parent->local_end)
			* osg::Matrix::rotate(parent->quat_arr.at(frame_num));
}