示例#1
0
        private static void FlingTick(Viewport viewport, AnimationEntry <Viewport> entry, double value)
        {
            var timeAmount = 16 / 1000d; // 16 milliseconds

            var(velocityX, velocityY) = ((double, double))entry.Start;

            var xMovement = velocityX * (1d - entry.Easing.Ease(value)) * timeAmount;
            var yMovement = velocityY * (1d - entry.Easing.Ease(value)) * timeAmount;

            if (xMovement.IsNanOrInfOrZero())
            {
                xMovement = 0;
            }
            if (yMovement.IsNanOrInfOrZero())
            {
                yMovement = 0;
            }

            if (xMovement == 0 && yMovement == 0)
            {
                return;
            }

            var previous = viewport.ScreenToWorld(0, 0);
            var current  = viewport.ScreenToWorld(xMovement, yMovement);

            var xDiff = current.X - previous.X;
            var yDiff = current.Y - previous.Y;

            viewport.CenterX = viewport.CenterX + xDiff;
            viewport.CenterY = viewport.CenterY + yDiff;
        }
示例#2
0
        private static Feature CreatePoint(double x, double y)
        {
            var result = new Feature();
            var style  = new SymbolStyle()
            {
                Fill = new Brush(Color.Red), SymbolScale = 1,
            };

            result.Geometry = new Point(x, y);
            result.Styles.Add(style);

            var animations = new List <AnimationEntry>();

            var entry1 = new AnimationEntry(
                start: style.SymbolScale,
                end: style.SymbolScale * 2,
                animationStart: 0,
                animationEnd: .5,
                easing: Easing.SinInOut,
                tick: (entry, value) => { style.SymbolScale = (double)((double)entry.Start + ((double)entry.End - (double)entry.Start) * entry.Easing.Ease(value)); },
                final: (entry) => { style.SymbolScale = (double)entry.End; }
                );

            animations.Add(entry1);

            var entry2 = new AnimationEntry(
                start: style.SymbolScale * 2,
                end: style.SymbolScale,
                animationStart: .5,
                animationEnd: 1,
                easing: Easing.SinInOut,
                tick: (entry, value) => { style.SymbolScale = (double)((double)entry.Start + ((double)entry.End - (double)entry.Start) * entry.Easing.Ease(value)); },
                final: (entry) => { style.SymbolScale = (double)entry.End; }
                );

            animations.Add(entry2);

            var entry3 = new AnimationEntry(
                start: style.Outline.Color,
                end: style.Outline.Color,
                animationStart: 0,
                animationEnd: 1,
                easing: Easing.Linear,
                tick: (entry, value) => {
                var color        = (Color)entry.Start;
                style.Fill.Color = new Color(color.R, color.G, (int)(value < 0.5 ? (1.0 - 2.0 * value) * 255 : ((value - 0.5) * 2.0) * 255));
            },
                final: (entry) => { style.Fill.Color = (Color)entry.End; }
                );

            animations.Add(entry3);

            var animation = new Animation(1000);

            animation.Loop = true;
            animation.Entries.AddRange(animations);
            animation.Start();

            return(result);
        }
示例#3
0
 private static void CenterTick(Viewport viewport, AnimationEntry <Viewport> entry, double value)
 {
     var(startX, startY) = ((double, double))entry.Start;
     var(endX, endY)     = ((double, double))entry.End;
     viewport.CenterX    = startX + (endX - startX) * entry.Easing.Ease(value);
     viewport.CenterY    = startY + (endY - startY) * entry.Easing.Ease(value);
 }
示例#4
0
        private static void CenterAndResolutionFinal(Viewport viewport, AnimationEntry <Viewport> entry)
        {
            var end = ((double CenterX, double CenterY, double Resolution))entry.End;

            viewport.CenterX    = end.CenterX;
            viewport.CenterY    = end.CenterY;
            viewport.Resolution = end.Resolution;
        }
示例#5
0
        /// <summary>
        /// Navigate to center and change resolution with animation
        /// </summary>
        /// <param name="center">New center to move to</param>
        /// <param name="resolution">New resolution to use</param>
        /// <param name="duration">Duration of animation in milliseconds</param>
        public void NavigateTo(Point center, double resolution, long duration = 300)
        {
            // Stop any old animation if there is one
            if (_animation != null)
            {
                _animation.Stop(false);
                _animation = null;
            }

            if (duration == 0)
            {
                _viewport.SetCenter(center);
                _viewport.SetResolution(resolution);

                Navigated?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                var animations = new List <AnimationEntry>();

                if (!_viewport.Center.Equals(center))
                {
                    var entry = new AnimationEntry(
                        start: _viewport.Center,
                        end: (ReadOnlyPoint)center,
                        animationStart: 0,
                        animationEnd: 1,
                        easing: Easing.Linear,
                        tick: CenterTick,
                        final: CenterFinal
                        );
                    animations.Add(entry);
                }

                if (_viewport.Resolution != resolution)
                {
                    var entry = new AnimationEntry(
                        start: _viewport.Resolution,
                        end: resolution,
                        animationStart: 0,
                        animationEnd: 1,
                        easing: Easing.Linear,
                        tick: ResolutionTick,
                        final: ResolutionFinal
                        );
                    animations.Add(entry);
                }

                if (animations.Count == 0)
                {
                    return;
                }

                _animation = new Animation(duration);
                _animation.Entries.AddRange(animations);
                _animation.Start();
            }
        }
示例#6
0
        private void RotationTick(AnimationEntry entry, double value)
        {
            var r = (double)entry.Start + _rotationDelta * entry.Easing.Ease(value);

            // Set new value
            _viewport.SetRotation(r);

            Navigated?.Invoke(this, EventArgs.Empty);
        }
示例#7
0
        private void ResolutionTick(AnimationEntry entry, double value)
        {
            var r = (double)entry.Start + ((double)entry.End - (double)entry.Start) * entry.Easing.Ease(value);

            // Set new values
            _viewport.SetResolution(r);

            Navigated?.Invoke(this, EventArgs.Empty);
        }
示例#8
0
        private static void CenterAndResolutionTick(Viewport viewport, AnimationEntry <Viewport> entry, double value)
        {
            var start = ((double CenterX, double CenterY, double Resolution))entry.Start;
            var end   = ((double CenterX, double CenterY, double Resolution))entry.End;

            viewport.CenterX    = start.CenterX + (end.CenterX - start.CenterX) * entry.Easing.Ease(value);
            viewport.CenterY    = start.CenterY + (end.CenterY - start.CenterY) * entry.Easing.Ease(value);
            viewport.Resolution = start.Resolution + (end.Resolution - start.Resolution) * entry.Easing.Ease(value);
        }
示例#9
0
        private void CenterTick(AnimationEntry entry, double value)
        {
            var x = ((ReadOnlyPoint)entry.Start).X + (((ReadOnlyPoint)entry.End).X - ((ReadOnlyPoint)entry.Start).X) * entry.Easing.Ease(value);
            var y = ((ReadOnlyPoint)entry.Start).Y + (((ReadOnlyPoint)entry.End).Y - ((ReadOnlyPoint)entry.Start).Y) * entry.Easing.Ease(value);

            // Set new values
            _viewport.SetCenter(x, y);

            Navigated?.Invoke(this, EventArgs.Empty);
        }
示例#10
0
        private static List <AnimationEntry <SymbolStyle> > CreateAnimationsForSymbolStyle(SymbolStyle style)
        {
            var animations = new List <AnimationEntry <SymbolStyle> >();

            var entry1 = new AnimationEntry <SymbolStyle>(
                start: style.SymbolScale,
                end: style.SymbolScale * 2,
                animationStart: 0,
                animationEnd: .5,
                easing: Easing.SinInOut,
                repeat: true,
                tick: (symbolStyle, e, v) => { style.SymbolScale = (double)((double)e.Start + ((double)e.End - (double)e.Start) * e.Easing.Ease(v)); },
                final: (symbolStyle, e) => { style.SymbolScale = (double)e.End; }
                );

            animations.Add(entry1);

            var entry2 = new AnimationEntry <SymbolStyle>(
                start: style.SymbolScale * 2,
                end: style.SymbolScale,
                animationStart: .5,
                animationEnd: 1,
                easing: Easing.SinInOut,
                repeat: true,
                tick: (symbolStyle, e, v) => { style.SymbolScale = (double)((double)e.Start + ((double)e.End - (double)e.Start) * e.Easing.Ease(v)); },
                final: (symbolStyle, e) => { style.SymbolScale = (double)e.End; }
                );

            animations.Add(entry2);

            var entry3 = new AnimationEntry <SymbolStyle>(
                start: Color.Black,
                end: Color.Red,
                animationStart: 0,
                animationEnd: 1,
                easing: Easing.SinInOut,
                tick: (symbolStyle, e, v) => {
                var start = (Color)e.Start;
                var end   = (Color)e.End;
                symbolStyle.Fill.Color = new Color(
                    (int)(start.R * (1.0 - v) + end.R * v),
                    (int)(start.G * (1.0 - v) + end.G * v),
                    (int)(start.B * (1.0 - v) + end.B * v));
            },
                final: (symbolStyle, e) => {
                symbolStyle.Fill.Color = (Color)e.End;
            }
                );

            animations.Add(entry3);

            Animation.Start(animations, 1000); // This should not be necessary

            return(animations);
        }
示例#11
0
        /// <summary>
        /// Change rotation of viewport
        /// </summary>
        /// <param name="rotation">New rotation in degrees of viewport></param>
        public void RotateTo(double rotation, long duration)
        {
            // Stop any old animation if there is one
            if (_animation != null)
            {
                _animation.Stop(false);
                _animation = null;
            }

            if (duration == 0)
            {
                _viewport.SetRotation(rotation);

                Navigated?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                var            animations = new List <AnimationEntry>();
                AnimationEntry entry;

                if (_viewport.Rotation == rotation)
                {
                    return;
                }

                entry = new AnimationEntry(
                    start: _viewport.Rotation,
                    end: rotation,
                    animationStart: 0,
                    animationEnd: 1,
                    easing: Easing.Linear,
                    tick: RotationTick,
                    final: RotationFinal
                    );
                animations.Add(entry);

                _rotationDelta = (double)entry.End - (double)entry.Start;

                if (_rotationDelta < -180.0)
                {
                    _rotationDelta += 360.0;
                }

                if (_rotationDelta > 180.0)
                {
                    _rotationDelta -= 360.0;
                }

                _animation = new Animation(duration);
                _animation.Entries.AddRange(animations);
                _animation.Start();
            }
        }
示例#12
0
        void InitWith(AnimationEntry entry, Action onEnd, int direction = 1)
        {
            _direction   = direction;
            _currentTime = 0f;

            _loop    = entry.loop;
            _onEnd   = onEnd;
            _current = entry.data;

            _index = GetStartIndex();

            Refresh();
        }
示例#13
0
        public void SetAnimationByIndex(uint index)
        {
            if (index >= mAnimations.Length)
            {
                Log.Warning("Tried to access animation by index outside of valid animation range. Ignoring animation");
                return;
            }

            mAnimation = mAnimations[index];
            mAnimationId = (int)index;
            mHasAnimation = true;
            ResetAnimationTimes();
        }
示例#14
0
        private static List <AnimationEntry> CreateAnimationsForSymbolStyle(SymbolStyle style)
        {
            var animations = new List <AnimationEntry>();

            var entry1 = new AnimationEntry(
                start: style.SymbolScale,
                end: style.SymbolScale * 2,
                animationStart: 0,
                animationEnd: .5,
                easing: Easing.SinInOut,
                tick: (entry, value) => { style.SymbolScale = (double)((double)entry.Start + ((double)entry.End - (double)entry.Start) * entry.Easing.Ease(value)); },
                final: (entry) => { style.SymbolScale = (double)entry.End; }
                );

            animations.Add(entry1);

            var entry2 = new AnimationEntry(
                start: style.SymbolScale * 2,
                end: style.SymbolScale,
                animationStart: .5,
                animationEnd: 1,
                easing: Easing.SinInOut,
                tick: (entry, value) => { style.SymbolScale = (double)((double)entry.Start + ((double)entry.End - (double)entry.Start) * entry.Easing.Ease(value)); },
                final: (entry) => { style.SymbolScale = (double)entry.End; }
                );

            animations.Add(entry2);

            var entry3 = new AnimationEntry(
                start: style.Outline.Color,
                end: style.Outline.Color,
                animationStart: 0,
                animationEnd: 1,
                easing: Easing.Linear,
                tick: (entry, value) =>
            {
                var color        = (Color)entry.Start;
                style.Fill.Color = new Color(color.R, color.G, (int)(value < 0.5 ? (1.0 - 2.0 * value) * 255 : ((value - 0.5) * 2.0) * 255));
            },
                final: (entry) => { style.Fill.Color = (Color)entry.End; }
                );

            animations.Add(entry3);

            return(animations);
        }
示例#15
0
        public void CloneAnimation(int anim)
        {
            AnimationEntry a = new AnimationEntry();

            byte FrameAmount = (byte)Animations[anim].Frames.Count;

            a.LoopIndex       = Animations[anim].LoopIndex;
            a.SpeedMultiplyer = Animations[anim].SpeedMultiplyer;

            a.Frames.Clear();

            for (int i = 0; i < FrameAmount; i++)
            {
                a.Frames.Add((AnimationEntry.Frame)Animations[anim].Frames[i].Clone());
            }

            Animations.Add(a);
        }
示例#16
0
        public static List <AnimationEntry <Viewport> > Create(IViewport viewport, MPoint center, double maxResolution, long duration)
        {
            var animations = new List <AnimationEntry <Viewport> >();
            AnimationEntry <Viewport> entry;

            if (!center.Equals(viewport.Center))
            {
                entry = new AnimationEntry <Viewport>(
                    start: viewport.Center,
                    end: (MReadOnlyPoint)center,
                    animationStart: 0,
                    animationEnd: 1,
                    easing: Easing.SinInOut,
                    tick: CenterTick,
                    final: CenterFinal
                    );
                animations.Add(entry);
            }

            entry = new AnimationEntry <Viewport>(
                start: viewport.Resolution,
                end: Math.Min(maxResolution, viewport.Resolution * 2),
                animationStart: 0,
                animationEnd: 0.5,
                easing: Easing.SinIn,
                tick: ResolutionTick,
                final: ResolutionFinal
                );
            animations.Add(entry);

            entry = new AnimationEntry <Viewport>(
                start: Math.Min(maxResolution, viewport.Resolution * 2),
                end: viewport.Resolution,
                animationStart: 0.5,
                animationEnd: 1,
                easing: Easing.SinIn,
                tick: ResolutionTick,
                final: ResolutionFinal
                );
            animations.Add(entry);

            Animation.Start(animations, duration);
            return(animations);
        }
示例#17
0
        public void SetAnimation(uint animation)
        {
            if (animation >= mAnimationLookup.Length)
            {
                Log.Warning("Tried to access animation by id outside of the lookup array. Ignoring animation");
                return;
            }

            if (mAnimationLookup[animation] < 0)
            {
                Log.Warning("Animation not found in model. Skipping");
                return;
            }

            mAnimationId = mAnimationLookup[animation];
            mAnimation = mAnimations[mAnimationId];
            mHasAnimation = true;
            ResetAnimationTimes();
        }
示例#18
0
        public static List <AnimationEntry <Viewport> > Create(Viewport viewport, double resolution, long duration, Easing?easing)
        {
            var animations = new List <AnimationEntry <Viewport> >();

            var entry = new AnimationEntry <Viewport>(
                start: viewport.Resolution,
                end: resolution,
                animationStart: 0,
                animationEnd: 1,
                easing: easing ?? Easing.SinInOut,
                tick: ResolutionTick,
                final: ResolutionFinal
                );

            animations.Add(entry);

            Animation.Start(animations, duration);
            return(animations);
        }
示例#19
0
        public void CancelAniamtion()
        {
            bool fireEvent = this.currentlyRunningAnimations.Count > 0;

            while (this.currentlyRunningAnimations.Count > 0)
            {
                AnimationEntry animation = this.currentlyRunningAnimations[0];
                animation.PropertySetting.Stop(animation.Element);
            }

#if DEBUG
            if (this.currentlyRunningAnimations.Count > 0)
            {
                throw new InvalidOperationException("Animation list should be empty.");
            }
#endif
            if (fireEvent)
            {
                this.Owner.OnAnimationFinished();
            }
        }
示例#20
0
        /// <summary>
        /// Change resolution of viewport
        /// </summary>
        /// <param name="resolution">New resolution to use</param>
        /// <param name="duration">Duration of animation in milliseconds</param>
        public void ZoomTo(double resolution, long duration = 300)
        {
            // Stop any old animation if there is one
            if (_animation != null)
            {
                _animation.Stop(false);
                _animation = null;
            }

            if (duration == 0)
            {
                _viewport.SetResolution(resolution);

                Navigated?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                var animations = new List <AnimationEntry>();

                if (_viewport.Resolution == resolution)
                {
                    return;
                }

                var entry = new AnimationEntry(
                    start: _viewport.Resolution,
                    end: resolution,
                    animationStart: 0,
                    animationEnd: 1,
                    easing: Easing.Linear,
                    tick: ResolutionTick,
                    final: ResolutionFinal
                    );
                animations.Add(entry);

                _animation = new Animation(duration);
                _animation.Entries.AddRange(animations);
                _animation.Start();
            }
        }
示例#21
0
        private void CurrentAnimation_AnimationFinished(object sender, AnimationStatusEventArgs e)
        {
            AnimationEntry animationEntry = new AnimationEntry((AnimatedPropertySetting)sender, e.Element);
            int            index          = this.currentlyRunningAnimations.IndexOf(animationEntry);

            if (index > -1)
            {
                this.currentlyRunningAnimations.RemoveAt(index);
            }
            else
            {
                int count = this.currentlyRunningAnimations.Count;
                if (count > 0)
                {
                    this.currentlyRunningAnimations.RemoveAt(count - 1);
                }
            }

            if (this.currentlyRunningAnimations.Count == 0)
            {
                this.Owner.OnAnimationFinished();
            }
        }
示例#22
0
        private void CenterFinal(AnimationEntry entry)
        {
            _viewport.SetCenter((ReadOnlyPoint)entry.End);

            Navigated?.Invoke(this, EventArgs.Empty);
        }
示例#23
0
        /// <summary>
        /// Fly to the given center with zooming out to given resolution and in again
        /// </summary>
        /// <param name="center">Point to fly to</param>
        /// <param name="maxResolution">Maximum resolution to zoom out</param>
        /// <param name="duration">Duration for animation in milliseconds</param>
        public void FlyTo(Point center, double maxResolution, long duration = 2000)
        {
            // Stop any old animation if there is one
            if (_animation != null)
            {
                _animation.Stop(false);
                _animation = null;
            }

            var halfCenter = new Point(_viewport.Center.X + (center.X - _viewport.Center.X) / 2.0, _viewport.Center.Y + (center.Y - _viewport.Center.Y) / 2.0);
            var resolution = _viewport.Resolution;

            if (duration == 0)
            {
                _viewport.SetCenter(center);

                Navigated?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                var            animations = new List <AnimationEntry>();
                AnimationEntry entry;

                if (!_viewport.Center.Equals(center))
                {
                    entry = new AnimationEntry(
                        start: _viewport.Center,
                        end: (ReadOnlyPoint)center,
                        animationStart: 0,
                        animationEnd: 1,
                        easing: Easing.Linear,
                        tick: CenterTick,
                        final: CenterFinal
                        );
                    animations.Add(entry);
                }

                entry = new AnimationEntry(
                    start: _viewport.Resolution,
                    end: maxResolution,
                    animationStart: 0,
                    animationEnd: 0.5,
                    easing: Easing.SinOut,
                    tick: ResolutionTick,
                    final: ResolutionFinal
                    );
                animations.Add(entry);

                entry = new AnimationEntry(
                    start: maxResolution,
                    end: _viewport.Resolution,
                    animationStart: 0.5,
                    animationEnd: 1,
                    easing: Easing.SinIn,
                    tick: ResolutionTick,
                    final: ResolutionFinal
                    );
                animations.Add(entry);

                _animation = new Animation(duration);
                _animation.Entries.AddRange(animations);
                _animation.Start();
            }
        }
示例#24
0
 private static void CenterFinal(Viewport viewport, AnimationEntry <Viewport> entry)
 {
     var(centerX, centerY) = ((double, double))entry.End;
     viewport.CenterX      = centerX;
     viewport.CenterY      = centerY;
 }
        /// <summary>
        /// Creates a managed animation entry given a native entry.
        /// </summary>
        /// <param name="mtpFileAddress">Address of the first byte of the MTP file in memory.</param>
        /// <param name="entry">The native animation entry.</param>
        public static unsafe ManagedAnimationEntry FromAnimationEntry(byte *mtpFileAddress, AnimationEntry entry)
        {
            var managedAnimationEntry = new ManagedAnimationEntry();

            byte *         fileNamePtr = entry.FileNamePtr + mtpFileAddress;
            byte *         fileDataPtr = entry.FileDataPtr + mtpFileAddress;
            PropertyTuple *tuplePtr    = (PropertyTuple *)(entry.PropertyTuplePtr + mtpFileAddress);

            // Get File Name
            managedAnimationEntry.FileName = String.Win1252Encoder.GetString(fileNamePtr, String.Strlen(fileNamePtr));

            // Get File Data
            var header = MotionHeader.FromPointer(fileDataPtr);

            Memory.CurrentProcess.ReadRaw((IntPtr)fileDataPtr, out managedAnimationEntry._fileData, header.FileSize);

            // Get File Tuples
            if (entry.HasProperties)
            {
                var           tuples = new List <PropertyTuple>(32);
                PropertyTuple tuple;

                void AddTuple()
                {
                    tuple = *tuplePtr;
                    tuple.SwapEndian();
                    tuples.Add(tuple);
                }

                while (!tuplePtr->Equals(PropertyTuple.Terminator))
                {
                    AddTuple();
                    tuplePtr++;
                }

                AddTuple();
                managedAnimationEntry.Tuples = tuples.ToArray();
            }

            return(managedAnimationEntry);
        }
示例#26
0
 private static void CenterTick(Viewport viewport, AnimationEntry <Viewport> entry, double value)
 {
     viewport.CenterX = ((MReadOnlyPoint)entry.Start).X + (((MReadOnlyPoint)entry.End).X - ((MReadOnlyPoint)entry.Start).X) * entry.Easing.Ease(value);
     viewport.CenterY = ((MReadOnlyPoint)entry.Start).Y + (((MReadOnlyPoint)entry.End).Y - ((MReadOnlyPoint)entry.Start).Y) * entry.Easing.Ease(value);
 }
示例#27
0
 private static void CenterFinal(Viewport viewport, AnimationEntry <Viewport> entry)
 {
     viewport.CenterX = ((MReadOnlyPoint)entry.End).X;
     viewport.CenterY = ((MReadOnlyPoint)entry.End).Y;
 }
示例#28
0
 public void ProcessArgs( string[] args )
 {
     for( int i = 0; i < args.Length; ++i )
     {
         switch( args[ i ] )
         {
             case "--transform":
                 for( int j = 0; j < 16; ++j )
                     if( i + 1 < args.Length )
                         transform[ j ] = float.Parse( args[ ++i ] );
                     else
                         Console.WriteLine( "Invalid transform" );
                 break;
             case "--build_skeleton":
                 build_skeleton = true;
                 break;
             case "--base_skeleton":
                 // This is overloaded.  It is used for adding multiple animations
                 // into a single skeleton, but it is also used to specify the name
                 // of the skeleton that will be referenced by the mesh file.
                 skeleton_file = args[ ++i ];
                 break;
             case "--build_tangents":
                 build_tangents = true;
                 break;
             case "--out_skeleton":
                 out_skeleton_file = args[ ++i ];
                 break;
             case "--optimize_mesh":
             case "--optimise_mesh":
                 optimize_mesh = true;
                 break;
             case "--animation":
                 {
                     AnimationEntry entry = new AnimationEntry();
                     entry.animation_name = args[ ++i ];
                     entry.animation_file = args[ ++i ];
                     animations.Add( entry );
                     break;
                 }
             case "--manual_lod":
                 {
                     LodEntry entry = new LodEntry();
                     entry.distance = float.Parse( args[ ++i ] );
                     entry.meshFile = args[ ++i ];
                     manualLodEntries.Add( entry );
                     break;
                 }
             case "--socket":
                 {
                     Matrix4 attachTransform = Matrix4.Identity;
                     string name = args[ ++i ];
                     string parentBone = args[ ++i ];
                     for( int j = 0; j < 16; ++j )
                         if( i + 1 < args.Length )
                             attachTransform[ j ] = float.Parse( args[ ++i ] );
                         else
                             Console.WriteLine( "Invalid transform" );
                     AttachmentPointNode ap = new AttachmentPointNode( name, parentBone, attachTransform );
                     attachPoints.Add( ap );
                     break;
                 }
             case "--test_physics":
                 {
                     test_physics = true;
                     return;
                 }
             // LOD options
             case "--lod_levels":
                 {
                     lodlevels = int.Parse( args[ ++i ] );
                     break;
                 }
             case "--lod_distance":
                 {
                     loddist = float.Parse( args[ ++i ] );
                     break;
                 }
             case "--lod_percent":
                 {
                     lodpercent = float.Parse( args[ ++i ] );
                     break;
                 }
             case "--lod_num_triangles":
                 {
                     // lodnumtris
                     break;
                 }
     #if NOT_USED
             case "--merge_animations": {
                     // Deprecated
                     string destFile = args[++i];
                     string rigFile = args[++i];
                     List<string> animFiles = new List<string>();
                     while (i + 1 < args.Length)
                         animFiles.Add(args[++i]);
                     MergeAnimations(srcDir, dstDir, destFile, rigFile, animFiles);
                     return;
                 }
             case "--merge_collada": {
                     // Deprecated
                     string destFile = args[++i];
                     string rigFile = args[++i];
                     string animFile = args[++i];
                     MergeColladaFiles(srcDir, dstDir, destFile, rigFile, animFile);
                     return;
                 }
     #endif
             case "--3ds":
                 {
                     // Convert from a right handed system where z is up to a right handed system where y is up.
                     Matrix4 yupTrans = new Matrix4( 1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1 );
                     transform = transform * yupTrans;
                     break;
                 }
             case "--src_dir":
                 srcDir = MaybeAddTrailingBackslash( args[ ++i ] );
                 break;
             case "--dst_dir":
                 dstDir = MaybeAddTrailingBackslash( args[ ++i ] );
                 break;
     #if NOT_USED
             case "--test_sockets":
                 TestSockets();
                 break;
     #endif
             case "--dont_extract_collision_volumes":
                 extract_collision_volumes = false;
                 break;
             case "--log_collision_volumes":
                 CVExtractor.InitLog( true );
                 break;
             case "--args_file":
                 ProcessArgumentFile( args[ ++i ] );
                 break;
             case "--log_file":
                 log_file = args[ ++i ];
                 break;
             case "--throw":
                 rethrow = true;
                 break;
             case "--version":
                 Console.WriteLine( string.Format( "ConversionTool version: {0}",
                                                 System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() ) );
                 break;
             case "--no_rigging_culling":
                 ColladaMeshReader.NoRiggingCulling = true;
                 break;
             case "--":
             case "--usage":
             case "--help":
                 Convert.Usage();
                 abort = true;
                 break;
             default:
                 last_arg = args[ i ];
                 break;
         }
         if( abort )
             break;
     }
 }
示例#29
0
        public void Update()
        {
            if (mHasAnimation == false)
                return;

            var now = Environment.TickCount;

            var time = (uint)(now - mBoneStart);
            if (time >= mAnimation.length && ((mAnimation.flags & 0x20) == 0 || mAnimation.nextAnimation >= 0))
            {
                if (mIsFinished)
                {
                    if (mAnimation.nextAnimation < 0 || mAnimation.nextAnimation >= mAnimations.Length) return;

                    mIsFinished = false;
                    mBoneStart = now;
                    mAnimationId = mAnimation.nextAnimation;
                    mAnimation = mAnimations[mAnimationId];
                    return;
                }

                time = mAnimation.length;
                mIsFinished = true;
            }
            else
            {
                if (mAnimation.length > 0)
                    time %= mAnimation.length;
            }

            for (var i = 0; i < mBoneCalculated.Length; ++i)
                mBoneCalculated[i] = false;

            lock (mBones)
            {
                for (var i = 0; i < mBones.Length; ++i)
                {
                    if (mBoneCalculated[i])
                        continue;

                    mBones[i].UpdateMatrix(time, mAnimationId, out BoneMatrices[i], this);
                    mBoneCalculated[i] = true;
                }
            }

            time = (uint)(now - mUvStart);
            lock (mUvAnimations)
            {
                for (var i = 0; i < mUvAnimations.Length; ++i)
                    mUvAnimations[i].UpdateMatrix(mAnimationId, time, out UvMatrices[i]);
            }

            time = (uint)(now - mTexColorStart);
            lock (mTexColorAnimations)
            {
                for (var i = 0; i < mTexColorAnimations.Length; ++i)
                    mTexColorAnimations[i].UpdateValue(mAnimationId, time, out Colors[i]);
            }

            time = (uint)(now - mAlphaStart);
            lock (mAlphaAnimations)
            {
                for (var i = 0; i < mAlphaAnimations.Length; ++i)
                    mAlphaAnimations[i].UpdateValue(mAnimationId, time, out Transparencies[i]);
            }

            mIsDirty = true;
        }
示例#30
0
 private static void ResolutionFinal(Viewport viewport, AnimationEntry <Viewport> entry)
 {
     viewport.Resolution = (double)entry.End;
 }
示例#31
0
        private void RotationFinal(AnimationEntry entry)
        {
            _viewport.SetRotation((double)entry.End);

            Navigated?.Invoke(this, EventArgs.Empty);
        }
        public static void CreateAnimations()
        {
            /***
             *
             * IMPS
             *
             */
            {
                // Imp idle
                {
                    var anim1 = new AnimationEntry("impidle1", TimeSpan.FromMilliseconds(200));
                    var anim2 = new AnimationEntry("impidle2", TimeSpan.FromMilliseconds(200));
                    var animList = new List<AnimationEntry>() {anim1, anim2};
                    var impIdle = new ActorAnimation(animList, true, "Prototype");
                    ActorAnimationManager.RegisterAnimation("impidle", impIdle);
                }
                // Imp shoot
                {
                    var anim1 = new AnimationEntry("impshoot1", TimeSpan.FromMilliseconds(200));
                    var anim2 = new AnimationEntry("impshoot2", TimeSpan.FromMilliseconds(200));
                    var anim3 = new AnimationEntry("impshoot3", TimeSpan.FromMilliseconds(200));
                    var animList = new List<AnimationEntry>() {anim1, anim2, anim3};
                    var impShoot = new ActorAnimation(animList, false, "Prototype");
                    ActorAnimationManager.RegisterAnimation("impshoot", impShoot);
                }
                // imp pain
                {
                    var anim1 = new AnimationEntry("imppain", TimeSpan.FromMilliseconds(300));
                    var animList = new List<AnimationEntry>() {anim1};
                    var impPain = new ActorAnimation(animList, false, "Prototype");
                    ActorAnimationManager.RegisterAnimation("imppain", impPain);
                }
                // imp death
                {
                    var anim1 = new AnimationEntry("impdeath1", TimeSpan.FromMilliseconds(200));
                    var anim2 = new AnimationEntry("impdeath2", TimeSpan.FromMilliseconds(200));
                    var anim3 = new AnimationEntry("impdeath3", TimeSpan.FromMilliseconds(200));
                    var anim4 = new AnimationEntry("impdeath4", TimeSpan.FromMilliseconds(200));
                    var anim5 = new AnimationEntry("impdeath5", TimeSpan.FromMilliseconds(200));
                    var animList = new List<AnimationEntry>() {anim1, anim2, anim3, anim4, anim5};
                    var impDie = new ActorAnimation(animList, false, "Prototype");
                    ActorAnimationManager.RegisterAnimation("impdie", impDie);
                }

                // Imp fireball idle
                {
                    var anim1 = new AnimationEntry("impfireball1", TimeSpan.FromMilliseconds(125));
                    var anim2 = new AnimationEntry("impfireball2", TimeSpan.FromMilliseconds(125));
                    var animList = new List<AnimationEntry>() {anim1, anim2};
                    ActorAnimationManager.RegisterAnimation("impfireballidle", new ActorAnimation(animList, true, "Prototype"));
                }
                // Imp fireball death
                {
                    var anim1 = new AnimationEntry("impfireballdeath1", TimeSpan.FromMilliseconds(225));
                    var anim2 = new AnimationEntry("impfireballdeath2", TimeSpan.FromMilliseconds(225));
                    var anim3 = new AnimationEntry("impfireballdeath3", TimeSpan.FromMilliseconds(225));
                    var ballDeath = new ActorAnimation(new List<AnimationEntry>() {anim1, anim2, anim3}, false,
                                                       "Prototype");
                    ActorAnimationManager.RegisterAnimation("impfireballdeath", ballDeath);
                }
            }

            /**
             *
             * CACODEMON
             *
             */

            {
                // caco idle
                {
                    var anim = new AnimationEntry("cacoidle", TimeSpan.Zero);
                    var cacoIdle = new ActorAnimation(true, anim);
                    ActorAnimationManager.RegisterAnimation("cacoidle", cacoIdle);
                }

                // caco shoot fireball
                {
                    var anim1 = new AnimationEntry("cacoshoot1", TimeSpan.FromMilliseconds(125));
                    var anim2 = new AnimationEntry("cacoshoot2", TimeSpan.FromMilliseconds(125));
                    var anim3 = new AnimationEntry("cacoshoot3", TimeSpan.FromMilliseconds(350));
                    var cacoShoot = new ActorAnimation(false, anim1, anim2, anim3);
                    ActorAnimationManager.RegisterAnimation("cacoshoot", cacoShoot);
                }

                // caco pain
                {
                    var anim1 = new AnimationEntry("cacopain1", TimeSpan.FromMilliseconds(500));
                    var anim2 = new AnimationEntry("cacopain2", TimeSpan.FromMilliseconds(500));
                    var cacoPain = new ActorAnimation(false, anim1, anim2);
                    ActorAnimationManager.RegisterAnimation("cacopain", cacoPain);
                }

                // caco death
                {
                    var anim1 = new AnimationEntry("cacodeath1", TimeSpan.FromMilliseconds(120));
                    var anim2 = new AnimationEntry("cacodeath2", TimeSpan.FromMilliseconds(120));
                    var anim3 = new AnimationEntry("cacodeath3", TimeSpan.FromMilliseconds(120));
                    var anim4 = new AnimationEntry("cacodeath4", TimeSpan.FromMilliseconds(120));
                    var anim5 = new AnimationEntry("cacodeath5", TimeSpan.FromMilliseconds(120));
                    var anim6 = new AnimationEntry("cacodeath6", TimeSpan.FromMilliseconds(120));
                    var cacoDeath = new ActorAnimation(false, anim1, anim2, anim3, anim4, anim5, anim6);
                    ActorAnimationManager.RegisterAnimation("cacodie", cacoDeath);
                }

                // caco fireball idle
                {
                    var anim1 = new AnimationEntry("cacofireball1", TimeSpan.FromMilliseconds(125));
                    var anim2 = new AnimationEntry("cacofireball2", TimeSpan.FromMilliseconds(125));
                    var cacoBallIdle = new ActorAnimation(true, anim1, anim2);
                    ActorAnimationManager.RegisterAnimation("cacofireballidle", cacoBallIdle);
                }

                // caco fireball death
                {
                    var anim1 = new AnimationEntry("cacofireballdeath1", TimeSpan.FromMilliseconds(125));
                    var anim2 = new AnimationEntry("cacofireballdeath2", TimeSpan.FromMilliseconds(125));
                    var anim3 = new AnimationEntry("cacofireballdeath3", TimeSpan.FromMilliseconds(125));
                    var cacoFireballDeath = new ActorAnimation(false, anim1, anim2, anim3);
                    ActorAnimationManager.RegisterAnimation("cacofireballdeath", cacoFireballDeath);
                }

            }
        }
示例#33
0
 private static void ResolutionTick(Viewport viewport, AnimationEntry <Viewport> entry, double value)
 {
     viewport.Resolution = (double)entry.Start + ((double)entry.End - (double)entry.Start) * entry.Easing.Ease(value);
 }
示例#34
0
        public void NewAnimation()
        {
            AnimationEntry a = new AnimationEntry();

            Animations.Add(a);
        }
        /// <summary>
        /// Converts a <see cref="MotionPackage"/> into a native .MTP file.
        /// </summary>
        public byte[] ToMtp()
        {
            var bytes = new List <byte>(1000000);

            var header = Header;

            header.SwapEndian();
            bytes.AddRange(Struct.GetBytes(ref header));

            // Write entries
            var dummyAnimationEntry      = new AnimationEntry();
            var dummyAnimationEntryBytes = Struct.GetBytes(ref dummyAnimationEntry);

            int[] entryOffsets = Entries.Select(x => AddRange(bytes, dummyAnimationEntryBytes)).ToArray();

            // Write file names.
            int[] fileNameOffsets = Entries.Select(x =>
            {
                int firstRef = AddRange(bytes, String.GetNullTerminatedBytes(String.Win1252Encoder, x.FileName));
                // Must pad to next group of 4-bytes, otherwise game will fail to parse
                while (bytes.Count % 4 > 0)
                {
                    bytes.Add(0x00);
                }
                return(firstRef);
            }).ToArray();

            // Write file data.
            int[] fileDataOffsets = Entries.Select(x => AddRange(bytes, x.FileData)).ToArray();

            // Write extra properties.
            int[] filePropertyOffsets = Entries.Select(x =>
            {
                if (x.Tuples != null)
                {
                    // Temporarily swap out the endian of all tuples before writing to array, then swap back.
                    for (int i = 0; i < x.Tuples.Length; i++)
                    {
                        x.Tuples[i].SwapEndian();
                    }

                    var result = AddRange(bytes, StructArray.GetBytes(x.Tuples));

                    for (int i = 0; i < x.Tuples.Length; i++)
                    {
                        x.Tuples[i].SwapEndian();
                    }

                    return(result);
                }

                return(0);
            }).ToArray();

            // Fix Offsets
            var byteArray = bytes.ToArray();

            fixed(byte *byteArrayPtr = byteArray)
            {
                for (int x = 0; x < Entries.Length; x++)
                {
                    ref var entry = ref Unsafe.AsRef <AnimationEntry>(byteArrayPtr + entryOffsets[x]);
                    Endian.Reverse(ref fileNameOffsets[x]);
                    Endian.Reverse(ref fileDataOffsets[x]);
                    Endian.Reverse(ref filePropertyOffsets[x]);

                    entry.FileNamePtr      = fileNameOffsets[x];
                    entry.FileDataPtr      = fileDataOffsets[x];
                    entry.PropertyTuplePtr = filePropertyOffsets[x];
                }
            }