示例#1
0
        private static void AddCurveToBone(AnimatedBone[] bones, int boneId, Curves.CurveBase curve)
        {
            if (boneId < 0 || boneId >= bones.Length)
            {
                throw new ArgumentOutOfRangeException("boneId");
            }

            AnimatedBone bone = bones[boneId];
            if (bone == null)
            {
                bone = new AnimatedBone();
                bone.BoneId = boneId;
                bones[boneId] = bone;
            }

            switch (curve.AnimatedComponent)
            {
                case AnimatedComponent.Quaternion:
                    {
                        if (bone.RotationCurve != null)
                        {
                            throw new InvalidOperationException("Two rotation curves for a bone?");
                        }

                        var qCurve = curve as Curves.QuaternionCurve;
                        if (qCurve == null)
                        {
                            throw new InvalidOperationException("Curve is not a quaternion curve?");
                        }

                        bone.RotationCurve = qCurve;
                    }
                    break;
                case AnimatedComponent.TranslationX:
                    {
                        if (bone.TranslationX != null)
                        {
                            throw new InvalidOperationException("Two TranslationX curves for a bone?");
                        }

                        var fCurve = curve as Curves.Curve<float>;
                        if (fCurve == null)
                        {
                            throw new InvalidOperationException("Curve is not a Curve<float>");
                        }

                        bone.TranslationX = fCurve;
                    }
                    break;
                case AnimatedComponent.TranslationY:
                    {
                        if (bone.TranslationY != null)
                        {
                            throw new InvalidOperationException("Two TranslationY curves for a bone?");
                        }

                        var fCurve = curve as Curves.Curve<float>;
                        if (fCurve == null)
                        {
                            throw new InvalidOperationException("Curve is not a Curve<float>");
                        }

                        bone.TranslationY = fCurve;
                    }
                    break;
                case AnimatedComponent.TranslationZ:
                    {
                        if (bone.TranslationZ != null)
                        {
                            throw new InvalidOperationException("Two TranslationZ curves for a bone?");
                        }

                        var fCurve = curve as Curves.Curve<float>;
                        if (fCurve == null)
                        {
                            throw new InvalidOperationException("Curve is not a Curve<float>");
                        }

                        bone.TranslationZ = fCurve;
                    }
                    break;
                case AnimatedComponent.ScaleX:
                    {
                        if (bone.ScaleX != null)
                        {
                            throw new InvalidOperationException("Two ScaleX curves for a bone?");
                        }

                        var fCurve = curve as Curves.Curve<float>;
                        if (fCurve == null)
                        {
                            throw new InvalidOperationException("Curve is not a Curve<float>");
                        }

                        bone.ScaleX = fCurve;
                    }
                    break;
                case AnimatedComponent.ScaleY:
                    {
                        if (bone.ScaleY != null)
                        {
                            throw new InvalidOperationException("Two ScaleY curves for a bone?");
                        }

                        var fCurve = curve as Curves.Curve<float>;
                        if (fCurve == null)
                        {
                            throw new InvalidOperationException("Curve is not a Curve<float>");
                        }

                        bone.ScaleY = fCurve;
                    }
                    break;
                case AnimatedComponent.ScaleZ:
                    {
                        if (bone.ScaleZ != null)
                        {
                            throw new InvalidOperationException("Two ScaleZ curves for a bone?");
                        }

                        var fCurve = curve as Curves.Curve<float>;
                        if (fCurve == null)
                        {
                            throw new InvalidOperationException("Curve is not a Curve<float>");
                        }

                        bone.ScaleZ = fCurve;
                    }
                    break;
            }
        }
示例#2
0
        private static AnimatedBone[] CreateBoneArray(int numBones)
        {
            var result = new AnimatedBone[numBones];

            return(result);
        }
示例#3
0
        private static AnimatedBone[] CreateBoneArray(int numBones)
        {
            var result = new AnimatedBone[numBones];

            return result;
        }
示例#4
0
        private static void AddCurveToBone(AnimatedBone[] bones, int boneId, Curves.CurveBase curve)
        {
            if (boneId < 0 || boneId >= bones.Length)
            {
                throw new ArgumentOutOfRangeException("boneId");
            }

            AnimatedBone bone = bones[boneId];

            if (bone == null)
            {
                bone          = new AnimatedBone();
                bone.BoneId   = boneId;
                bones[boneId] = bone;
            }

            switch (curve.AnimatedComponent)
            {
            case AnimatedComponent.Quaternion:
            {
                if (bone.RotationCurve != null)
                {
                    throw new InvalidOperationException("Two rotation curves for a bone?");
                }

                var qCurve = curve as Curves.QuaternionCurve;
                if (qCurve == null)
                {
                    throw new InvalidOperationException("Curve is not a quaternion curve?");
                }

                bone.RotationCurve = qCurve;
            }
            break;

            case AnimatedComponent.TranslationX:
            {
                if (bone.TranslationX != null)
                {
                    throw new InvalidOperationException("Two TranslationX curves for a bone?");
                }

                var fCurve = curve as Curves.Curve <float>;
                if (fCurve == null)
                {
                    throw new InvalidOperationException("Curve is not a Curve<float>");
                }

                bone.TranslationX = fCurve;
            }
            break;

            case AnimatedComponent.TranslationY:
            {
                if (bone.TranslationY != null)
                {
                    throw new InvalidOperationException("Two TranslationY curves for a bone?");
                }

                var fCurve = curve as Curves.Curve <float>;
                if (fCurve == null)
                {
                    throw new InvalidOperationException("Curve is not a Curve<float>");
                }

                bone.TranslationY = fCurve;
            }
            break;

            case AnimatedComponent.TranslationZ:
            {
                if (bone.TranslationZ != null)
                {
                    throw new InvalidOperationException("Two TranslationZ curves for a bone?");
                }

                var fCurve = curve as Curves.Curve <float>;
                if (fCurve == null)
                {
                    throw new InvalidOperationException("Curve is not a Curve<float>");
                }

                bone.TranslationZ = fCurve;
            }
            break;

            case AnimatedComponent.ScaleX:
            {
                if (bone.ScaleX != null)
                {
                    throw new InvalidOperationException("Two ScaleX curves for a bone?");
                }

                var fCurve = curve as Curves.Curve <float>;
                if (fCurve == null)
                {
                    throw new InvalidOperationException("Curve is not a Curve<float>");
                }

                bone.ScaleX = fCurve;
            }
            break;

            case AnimatedComponent.ScaleY:
            {
                if (bone.ScaleY != null)
                {
                    throw new InvalidOperationException("Two ScaleY curves for a bone?");
                }

                var fCurve = curve as Curves.Curve <float>;
                if (fCurve == null)
                {
                    throw new InvalidOperationException("Curve is not a Curve<float>");
                }

                bone.ScaleY = fCurve;
            }
            break;

            case AnimatedComponent.ScaleZ:
            {
                if (bone.ScaleZ != null)
                {
                    throw new InvalidOperationException("Two ScaleZ curves for a bone?");
                }

                var fCurve = curve as Curves.Curve <float>;
                if (fCurve == null)
                {
                    throw new InvalidOperationException("Curve is not a Curve<float>");
                }

                bone.ScaleZ = fCurve;
            }
            break;
            }
        }