예제 #1
0
        public bool HasKeyOnFrame(FBXAnimCurveNode attrNode, int frame)
        {
            var x = IsKeyExistOnFrame(attrNode.Curves["x"], frame);
            var y = IsKeyExistOnFrame(attrNode.Curves["y"], frame);
            var z = IsKeyExistOnFrame(attrNode.Curves["z"], frame);

            return(x && y && z);
        }
예제 #2
0
        public bool HasCurve(Dictionary <string, FBXAnimCurveNode> animNode, string attr)
        {
            FBXAnimCurveNode attrNode = null;

            switch (attr)
            {
            case "S":
                if (!animNode.ContainsKey("S"))
                {
                    return(false);
                }
                attrNode = animNode["S"];
                break;

            case "R":
                if (!animNode.ContainsKey("R"))
                {
                    return(false);
                }
                attrNode = animNode["R"];
                break;

            case "T":
                if (!animNode.ContainsKey("T"))
                {
                    return(false);
                }
                attrNode = animNode["T"];
                break;
            }

            if (!attrNode.Curves.ContainsKey("x"))
            {
                return(false);
            }

            if (!attrNode.Curves.ContainsKey("y"))
            {
                return(false);
            }

            if (!attrNode.Curves.ContainsKey("z"))
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        private void ExportGroupAnimation(CSGGroup group, FBXAnimLayer animationLayer, float keyFramesPerSecond, FBXNode node)
        {
            CSGAnimationKey[] animationKeyList = null;
            int keyListCount = 0;

            group.GetAnimationKeys(0, 999999, ref animationKeyList, ref keyListCount);
            int translationAnimationKeyCount = 0;
            int rotationAnimationKeyCount    = 0;

            foreach (var animationKey in animationKeyList)
            {
                if (animationKey.Type == CSGAnimationKeyType.CSGAnimationPositionKey)
                {
                    translationAnimationKeyCount++;
                }

                if (animationKey.Type == CSGAnimationKeyType.CSGAnimationOrientationKey)
                {
                    rotationAnimationKeyCount++;
                }
            }

            if (translationAnimationKeyCount > 1)
            {
                FBXAnimCurveNode myTranslationAnimCurveNode = node.LclTranslationGetCurveNode(animationLayer);

                FBXAnimCurve myTranXCurve = node.LclTranslationGetCurve(animationLayer, "X");
                FBXAnimCurve myTranYCurve = node.LclTranslationGetCurve(animationLayer, "Y");
                FBXAnimCurve myTranZCurve = node.LclTranslationGetCurve(animationLayer, "Z");

                myTranXCurve.KeyModifyBegin();
                myTranYCurve.KeyModifyBegin();
                myTranZCurve.KeyModifyBegin();

                foreach (var animationKey in animationKeyList)
                {
                    if (animationKey.Type == CSGAnimationKeyType.CSGAnimationPositionKey)
                    {
                        myTranXCurve.KeyAddSet(animationKey.Time / keyFramesPerSecond, animationKey.V.X);  // , ArcManagedFBX.Types.EInterpolationType.eInterpolationConstant);
                        myTranYCurve.KeyAddSet(animationKey.Time / keyFramesPerSecond, animationKey.V.Y);  // , ArcManagedFBX.Types.EInterpolationType.eInterpolationConstant);
                        myTranZCurve.KeyAddSet(animationKey.Time / keyFramesPerSecond, -animationKey.V.Z); // , ArcManagedFBX.Types.EInterpolationType.eInterpolationConstant);
                    }
                }

                myTranXCurve.KeyModifyEnd();
                myTranYCurve.KeyModifyEnd();
                myTranZCurve.KeyModifyEnd();
            }

            if (rotationAnimationKeyCount > 1)
            {
                FBXAnimCurveNode myRotationAnimCurveNode = node.LclRotationGetCurveNode(animationLayer);

                FBXAnimCurve myRotXCurve = node.LclRotationGetCurve(animationLayer, "X");
                FBXAnimCurve myRotYCurve = node.LclRotationGetCurve(animationLayer, "Y");
                FBXAnimCurve myRotZCurve = node.LclRotationGetCurve(animationLayer, "Z");

                myRotXCurve.KeyModifyBegin();
                myRotYCurve.KeyModifyBegin();
                myRotZCurve.KeyModifyBegin();

                foreach (var animationKey in animationKeyList)
                {
                    if (animationKey.Type == CSGAnimationKeyType.CSGAnimationOrientationKey)
                    {
                        FBXVector eulerXYZ = this.GetEulerXYZ(group, animationKey.Time);

                        myRotXCurve.KeyAddSet(animationKey.Time / keyFramesPerSecond, (float)eulerXYZ.x); // , ArcManagedFBX.Types.EInterpolationType.eInterpolationLinear);
                        myRotYCurve.KeyAddSet(animationKey.Time / keyFramesPerSecond, (float)eulerXYZ.y); // , ArcManagedFBX.Types.EInterpolationType.eInterpolationLinear);
                        myRotZCurve.KeyAddSet(animationKey.Time / keyFramesPerSecond, (float)eulerXYZ.z); // , ArcManagedFBX.Types.EInterpolationType.eInterpolationLinear);
                    }
                }

                myRotXCurve.KeyModifyEnd();
                myRotYCurve.KeyModifyEnd();
                myRotZCurve.KeyModifyEnd();
            }
        }