Ejemplo n.º 1
0
        public void ImportAnimations(IEnumerable <animation> anims, Root root, Skeleton skeleton)
        {
            var animation = new Animation();

            animation.Name             = "Default";
            animation.TimeStep         = 0.016667f; // 60 FPS
            animation.Oversampling     = 1;
            animation.DefaultLoopCount = 1;
            animation.Flags            = 1;

            var trackGroup = new TrackGroup();

            trackGroup.Name              = skeleton.Name;
            trackGroup.TransformTracks   = new List <TransformTrack>();
            trackGroup.InitialPlacement  = new Transform();
            trackGroup.AccumulationFlags = 2;
            trackGroup.LoopTranslation   = new float[] { 0, 0, 0 };
            foreach (var colladaTrack in anims)
            {
                ImportAnimation(colladaTrack, trackGroup, skeleton);
            }

            if (trackGroup.TransformTracks.Count > 0)
            {
                // Reorder transform tracks in lexicographic order
                // This is needed by Granny; otherwise it'll fail to find animation tracks
                trackGroup.TransformTracks.Sort((t1, t2) => t1.Name.CompareTo(t2.Name));

                animation.Duration =
                    Math.Max(
                        trackGroup.TransformTracks.Max(t => t.OrientationCurve.CurveData.Duration()),
                        Math.Max(
                            trackGroup.TransformTracks.Max(t => t.PositionCurve.CurveData.Duration()),
                            trackGroup.TransformTracks.Max(t => t.ScaleShearCurve.CurveData.Duration())
                            )
                        );
                animation.TrackGroups = new List <TrackGroup> {
                    trackGroup
                };

                root.TrackGroups.Add(trackGroup);
                root.Animations.Add(animation);
            }
        }
Ejemplo n.º 2
0
        public void ImportAnimations(IEnumerable <animation> anims)
        {
            var animation = new Animation();

            animation.Name             = "Default";
            animation.TimeStep         = 0.016667f; // 60 FPS
            animation.Oversampling     = 1;
            animation.DefaultLoopCount = 1;
            animation.Flags            = 1;

            var trackGroup = new TrackGroup();

            trackGroup.Name              = Skeletons[0].Name;
            trackGroup.TransformTracks   = new List <TransformTrack>();
            trackGroup.InitialPlacement  = new Transform();
            trackGroup.AccumulationFlags = 2;
            trackGroup.LoopTranslation   = new float[] { 0, 0, 0 };
            foreach (var colladaTrack in anims)
            {
                ImportAnimation(colladaTrack, trackGroup);
            }

            if (trackGroup.TransformTracks.Count > 0)
            {
                animation.Duration =
                    Math.Max(
                        trackGroup.TransformTracks.Max(t => t.OrientationCurve.CurveData.Duration()),
                        Math.Max(
                            trackGroup.TransformTracks.Max(t => t.PositionCurve.CurveData.Duration()),
                            trackGroup.TransformTracks.Max(t => t.ScaleShearCurve.CurveData.Duration())
                            )
                        );
                animation.TrackGroups = new List <TrackGroup> {
                    trackGroup
                };

                TrackGroups.Add(trackGroup);
                Animations.Add(animation);
            }
        }
Ejemplo n.º 3
0
        public void ImportAnimations(IEnumerable <animation> anims, Root root, Skeleton skeleton)
        {
            var trackGroup = new TrackGroup
            {
                Name              = (skeleton != null) ? skeleton.Name : "Dummy_Root",
                TransformTracks   = new List <TransformTrack>(),
                InitialPlacement  = new Transform(),
                AccumulationFlags = 2,
                LoopTranslation   = new float[] { 0, 0, 0 }
            };

            var animation = new Animation
            {
                Name             = "Default",
                TimeStep         = 0.016667f, // 60 FPS
                Oversampling     = 1,
                DefaultLoopCount = 1,
                Flags            = 1,
                Duration         = .0f,
                TrackGroups      = new List <TrackGroup> {
                    trackGroup
                }
            };

            foreach (var colladaTrack in anims)
            {
                ImportAnimation(colladaTrack, animation, trackGroup, skeleton);
            }

            if (trackGroup.TransformTracks.Count > 0)
            {
                // Reorder transform tracks in lexicographic order
                // This is needed by Granny; otherwise it'll fail to find animation tracks
                trackGroup.TransformTracks.Sort((t1, t2) => String.Compare(t1.Name, t2.Name, StringComparison.Ordinal));

                root.TrackGroups.Add(trackGroup);
                root.Animations.Add(animation);
            }
        }
Ejemplo n.º 4
0
        public void ImportAnimation(animation anim, TrackGroup trackGroup)
        {
            var childAnims = 0;

            foreach (var item in anim.Items)
            {
                if (item is animation)
                {
                    ImportAnimation(item as animation, trackGroup);
                    childAnims++;
                }
            }

            if (childAnims < anim.Items.Length)
            {
                ColladaAnimation collada = new ColladaAnimation();
                if (collada.ImportFromCollada(anim, Skeletons[0]))
                {
                    var track = collada.MakeTrack();
                    trackGroup.TransformTracks.Add(track);
                }
            }
        }