private static Sequence MockSequence(Sequence.Animation animation) { return(new Sequence { AnimationGroups = new List <Sequence.AnimationGroup>() { new Sequence.AnimationGroup { AnimationIndex = 0, Count = 1, } }, Animations = new List <Sequence.Animation>() { animation }, FrameGroups = new List <Sequence.FrameGroup>() { new Sequence.FrameGroup { Start = 0, Count = 1 } }, FramesEx = new List <Sequence.FrameEx>() { new Sequence.FrameEx { Left = 0, Top = 0, Right = 512, Bottom = 512, } }, Frames = new List <Sequence.Frame>() { new Sequence.Frame { Unknown00 = 0, Left = 0, Top = 0, Right = 512, Bottom = 512, UTranslation = 0, VTranslation = 0, ColorLeft = 0x80808080, ColorTop = 0x80808080, ColorRight = 0x80808080, ColorBottom = 0x80808080, } } }); }
private static Sequence MockSequence(Sequence.Animation animation) => new Sequence { AnimationGroups = new List <Sequence.AnimationGroup>() { new Sequence.AnimationGroup { Animations = new List <Sequence.Animation>() { animation }, DoNotLoop = 1, } }, SpriteGroups = new List <List <Sequence.SpritePart> >() { new List <Sequence.SpritePart>() { new Sequence.SpritePart { Left = 0, Top = 0, Right = 512, Bottom = 512, } } }, Sprites = new List <Sequence.Sprite>() { new Sequence.Sprite { Left = 0, Top = 0, Right = 512, Bottom = 512, UTranslation = 0, VTranslation = 0, ColorLeft = 0x80808080, ColorTop = 0x80808080, ColorRight = 0x80808080, ColorBottom = 0x80808080, } } };
public static Sequence.Animation Clone(this Sequence.Animation anim) => new Sequence.Animation { Flags = anim.Flags, SpriteGroupIndex = anim.SpriteGroupIndex, FrameStart = anim.FrameStart, FrameEnd = anim.FrameEnd, TranslateXStart = anim.TranslateXStart, TranslateXEnd = anim.TranslateXEnd, TranslateYStart = anim.TranslateYStart, TranslateYEnd = anim.TranslateYEnd, PivotXStart = anim.PivotXStart, PivotXEnd = anim.PivotXEnd, PivotYStart = anim.PivotYStart, PivotYEnd = anim.PivotYEnd, RotationXStart = anim.RotationXStart, RotationXEnd = anim.RotationXEnd, RotationYStart = anim.RotationYStart, RotationYEnd = anim.RotationYEnd, RotationZStart = anim.RotationZStart, RotationZEnd = anim.RotationZEnd, ScaleStart = anim.ScaleStart, ScaleEnd = anim.ScaleEnd, ScaleXStart = anim.ScaleXStart, ScaleXEnd = anim.ScaleXEnd, ScaleYStart = anim.ScaleYStart, ScaleYEnd = anim.ScaleYEnd, CurveXStart = anim.CurveXStart, CurveYStart = anim.CurveYStart, CurveXEnd = anim.CurveXEnd, CurveYEnd = anim.CurveYEnd, BounceXStart = anim.BounceXStart, BounceXEnd = anim.BounceXEnd, BounceYStart = anim.BounceYStart, BounceYEnd = anim.BounceYEnd, BounceXCount = anim.BounceXCount, BounceYCount = anim.BounceYCount, ColorBlend = anim.ColorBlend, ColorStart = anim.ColorStart, ColorEnd = anim.ColorEnd, };
public static Sequence.Animation Clone(this Sequence.Animation anim) => new Sequence.Animation { Flags = anim.Flags, SpriteGroupIndex = anim.SpriteGroupIndex, FrameStart = anim.FrameStart, FrameEnd = anim.FrameEnd, TranslateXStart = anim.TranslateXStart, TranslateXEnd = anim.TranslateXEnd, TranslateYStart = anim.TranslateYStart, TranslateYEnd = anim.TranslateYEnd, PivotXStart = anim.PivotXStart, PivotXEnd = anim.PivotXEnd, PivotYStart = anim.PivotYStart, PivotYEnd = anim.PivotYEnd, RotationXStart = anim.RotationXStart, RotationXEnd = anim.RotationXEnd, RotationYStart = anim.RotationYStart, RotationYEnd = anim.RotationYEnd, RotationZStart = anim.RotationZStart, RotationZEnd = anim.RotationZEnd, ScaleStart = anim.ScaleStart, ScaleEnd = anim.ScaleEnd, ScaleXStart = anim.ScaleXStart, ScaleXEnd = anim.ScaleXEnd, ScaleYStart = anim.ScaleYStart, ScaleYEnd = anim.ScaleYEnd, Unknown60 = anim.Unknown60, Unknown64 = anim.Unknown64, Unknown68 = anim.Unknown68, Unknown6c = anim.Unknown6c, BounceXStart = anim.BounceXStart, BounceXEnd = anim.BounceXEnd, BounceYStart = anim.BounceYStart, BounceYEnd = anim.BounceYEnd, BounceXSpeed = anim.BounceXSpeed, BounceYSpeed = anim.BounceYSpeed, ColorBlend = anim.ColorBlend, ColorStart = anim.ColorStart, ColorEnd = anim.ColorEnd, };
public static Rectangle GetVisibilityRectangleFromAnimation( this Sequence sequence, Sequence.Animation animation) { var rect = sequence.GetVisibilityRectangleForFrameGroup(animation.SpriteGroupIndex); var minXPos = animation.TranslateXStart; int maxXPos = animation.TranslateXEnd; var minYPos = animation.TranslateYStart; int maxYPos = animation.TranslateYEnd; var minXScale = animation.ScaleStart * animation.ScaleXStart; var maxXScale = animation.ScaleEnd * animation.ScaleXEnd; var minYScale = animation.ScaleStart * animation.ScaleYStart; var maxYScale = animation.ScaleEnd * animation.ScaleYEnd; var minRect = rect .Multiply(minXScale, minYScale) .Traslate(minXPos, minYPos); var maxRect = rect .Multiply(maxXScale, maxYScale) .Traslate(maxXPos, maxYPos); return(minRect.Union(maxRect)); }
private void DrawAnimation(Context contextParent, Sequence.Animation animation, int index) { // 0000 0001 = (0 = EASE IN/OUT INTERPOLATION, 1 = LINEAR INTERPOLATION) // 0000 0008 = (0 = BOUNCING START FROM CENTER, 1 = BOUNCING START FROM X / MOVE FROM Y) // 0000 0010 = (0 = ENABLE BOUNCING, 1 = IGNORE BOUNCING) // 0000 0020 = (0 = ENABLE ROTATION, 1 = IGNORE ROTATION) // 0000 0040 = (0 = ENABLE SCALING, 1 = IGNORE SCALING) // 0000 0080 = (0 = ENABLE COLOR FADING, 1 = IGNORE COLOR FADING) // 0000 0400 = (0 = ENABLE COLOR MASKING, 1 = IGNORE COLOR MASKING) // 0000 4000 = (0 = ENABLE XYB, 1 = IGNORE XYB) if (contextParent.FrameIndex < animation.FrameStart || contextParent.FrameIndex > animation.FrameEnd) { return; } var context = contextParent.Clone(); var delta = (double)(context.FrameIndex - animation.FrameStart) / (animation.FrameEnd - animation.FrameStart); float t; // loc_23B030 if ((animation.Flags & Sequence.LinearInterpolationFlag) != 0) { t = (float)delta; } else { t = (float)((Math.Sin(delta * Math.PI - Math.PI / 2.0) + 1.0) / 2.0); } context.ColorBlendMode = animation.ColorBlend; var translateX = Lerp(t, animation.TranslateXStart, animation.TranslateXEnd); var translateY = Lerp(t, animation.TranslateYStart, animation.TranslateYEnd); if ((animation.Flags & Sequence.TranslationFlag) == 0) { context.PositionX += translateX; context.PositionY += translateY; } else { context.PositionX += animation.TranslateXStart; context.PositionY += animation.TranslateYStart; } if ((animation.Flags & Sequence.ScalingFlag) == 0) { var scale = Lerp(t, animation.ScaleStart, animation.ScaleEnd); var scaleX = Lerp(t, animation.ScaleXStart, animation.ScaleXEnd); var scaleY = Lerp(t, animation.ScaleYStart, animation.ScaleYEnd); context.ScaleX = scale * scaleX; context.ScaleY = scale * scaleY; } else { context.ScaleX = 1.0f; context.ScaleY = 1.0f; } if ((animation.Flags & Sequence.ColorMaskingFlag) == 0) { if ((animation.Flags & Sequence.ColorInterpolationFlag) == 0) { context.Color *= Lerp(t, ConvertColor(animation.ColorStart), ConvertColor(animation.ColorEnd)); } else { context.Color *= ConvertColor(animation.ColorStart); } } else { context.Color *= new ColorF(1, 1, 1, 1); } if ((animation.Flags & Sequence.RotationFlag) == 0) { context.RotationX = Lerp(t, animation.RotationXStart, animation.RotationXEnd); context.RotationY = Lerp(t, animation.RotationYStart, animation.RotationYEnd); context.RotationZ = Lerp(t, animation.RotationZStart, animation.RotationZEnd); } if ((animation.Flags & Sequence.PivotFlag) == 0) { context.PivotX += Lerp(t, animation.PivotXStart, animation.PivotXEnd); context.PivotY += Lerp(t, animation.PivotYStart, animation.PivotYEnd); } if ((animation.Flags & Sequence.BouncingFlag) == 0) { var bounceXValue = (float)Math.Sin(Lerp(delta * animation.BounceXSpeed, 0, Math.PI)); var bounceYValue = (float)Math.Sin(Lerp(delta * animation.BounceYSpeed, 0, Math.PI)); context.PositionX += bounceXValue * Lerp(t, animation.BounceXStart, animation.BounceXEnd); context.PositionY += bounceYValue * Lerp(t, animation.BounceYStart, animation.BounceYEnd); } context.Color *= DebugSequenceRenderer.GetAnimationBlendColor(index); if ((animation.Flags & Sequence.CanHostChildFlag) != 0) { CurrentChildContext.PositionX = context.PositionX + context.PivotX; CurrentChildContext.PositionY = context.PositionY + context.PivotY; CurrentChildContext.Color = context.Color; // Horrible hack. Basically if TranslationFlag disallow to us the translation // animation, the frame group just uses Translate*Start, but the attached // child context still needs to use the animation. if ((animation.Flags & Sequence.TranslationFlag) != 0) { CurrentChildContext.PositionX += translateX - animation.TranslateXStart; CurrentChildContext.PositionY += translateY - animation.TranslateYStart; } } // CALCULATE TRANSOFRMATIONS AND INTERPOLATIONS DrawFrameGroup(context, Sequence.SpriteGroups[animation.SpriteGroupIndex]); }
private void DrawAnimation(Context contextParent, Sequence.Animation animation, int index) { // 0000 0001 = (0 = CUBIC INTERPOLATION, 1 = LINEAR INTERPOLATION) // 0000 0008 = (0 = BOUNCING START FROM CENTER, 1 = BOUNCING START FROM X / MOVE FROM Y) // 0000 0010 = (0 = ENABLE BOUNCING, 1 = IGNORE BOUNCING) // 0000 0020 = (0 = ENABLE ROTATION, 1 = IGNORE ROTATION) // 0000 0040 = (0 = ENABLE SCALING, 1 = IGNORE SCALING) // 0000 0080 = (0 = ENABLE COLOR FADING, 1 = IGNORE COLOR FADING) // 0000 0400 = (0 = ENABLE COLOR MASKING, 1 = IGNORE COLOR MASKING) // 0000 4000 = (0 = ENABLE XYB, 1 = IGNORE XYB) if (contextParent.FrameIndex < animation.FrameStart || contextParent.FrameIndex > animation.FrameEnd) { return; } var context = contextParent.Clone(); var delta = (double)(context.FrameIndex - animation.FrameStart) / (animation.FrameEnd - animation.FrameStart); float t; // loc_23B030 if ((animation.Flags & Sequence.LinearInterpolationFlag) != 0) { t = (float)delta; } else { t = (float)(delta * delta * delta); } context.PositionX += Lerp(t, animation.TranslateXStart, animation.TranslateXEnd); context.PositionY += Lerp(t, animation.TranslateYStart, animation.TranslateYEnd); context.ColorBlendMode = animation.ColorBlend; if ((animation.Flags & Sequence.ScalingFlag) == 0) { var scale = Lerp(t, animation.ScaleStart, animation.ScaleEnd); var scaleX = Lerp(t, animation.ScaleXStart, animation.ScaleXEnd); var scaleY = Lerp(t, animation.ScaleYStart, animation.ScaleYEnd); context.ScaleX = scale * scaleX; context.ScaleY = scale * scaleY; } else { context.ScaleX = 1.0f; context.ScaleY = 1.0f; } if ((animation.Flags & Sequence.ColorMaskingFlag) == 0) { if ((animation.Flags & Sequence.ColorInterpolationFlag) == 0) { context.Color = Lerp(t, ConvertColor(animation.ColorStart), ConvertColor(animation.ColorEnd)); } else { context.Color = ConvertColor(animation.ColorStart); } } else { context.Color = new ColorF(1, 1, 1, 1); } if ((animation.Flags & Sequence.RotationFlag) == 0) { context.RotationX = Lerp(t, animation.RotationXStart, animation.RotationXEnd); context.RotationY = Lerp(t, animation.RotationYStart, animation.RotationYEnd); context.RotationZ = Lerp(t, animation.RotationZStart, animation.RotationZEnd); } if ((animation.Flags & Sequence.PivotFlag) == 0) { context.PivotX += Lerp(t, animation.PivotXStart, animation.PivotXEnd); context.PivotY += Lerp(t, animation.PivotYStart, animation.PivotYEnd); } if ((animation.Flags & Sequence.BouncingFlag) == 0) { var bounceXValue = (float)Math.Sin(Lerp(delta * animation.BounceXSpeed, 0, Math.PI)); var bounceYValue = (float)Math.Sin(Lerp(delta * animation.BounceYSpeed, 0, Math.PI)); context.PositionX += bounceXValue * Lerp(t, animation.BounceXStart, animation.BounceXEnd); context.PositionY += bounceYValue * Lerp(t, animation.BounceYStart, animation.BounceYEnd); } context.Color *= DebugSequenceRenderer.GetAnimationBlendColor(index); if ((animation.Flags & Sequence.AttachTextFlag) != 0) { if (_textContext == null) { _textContext = context.Clone(); } } // CALCULATE TRANSOFRMATIONS AND INTERPOLATIONS DrawFrameGroup(context, Sequence.SpriteGroups[animation.SpriteGroupIndex]); }
private void DrawAnimation(Context contextParent, Sequence.Animation animation) { // 0000 0001 = (0 = CUBIC INTERPOLATION, 1 = LINEAR INTERPOLATION) // 0000 0008 = (0 = BOUNCING START FROM CENTER, 1 = BOUNCING START FROM X / MOVE FROM Y) // 0000 0010 = (0 = ENABLE BOUNCING, 1 = IGNORE BOUNCING) // 0000 0020 = (0 = ENABLE ROTATION, 1 = IGNORE ROTATION) // 0000 0040 = (0 = ENABLE SCALING, 1 = IGNORE SCALING) // 0000 0080 = (0 = ENABLE COLOR FADING, 1 = IGNORE COLOR FADING) // 0000 0400 = (0 = ENABLE COLOR MASKING, 1 = IGNORE COLOR MASKING) // 0000 4000 = (0 = ENABLE XYB, 1 = IGNORE XYB) if (contextParent.FrameIndex < animation.FrameStart || contextParent.FrameIndex > animation.FrameEnd) { return; } var context = contextParent.Clone(); var delta = (double)(context.FrameIndex - animation.FrameStart) / (animation.FrameEnd - animation.FrameStart); float t; // loc_23B030 if ((animation.Flags & LinearInterpolationFlag) != 0) { t = (float)delta; } else { t = (float)(delta * delta * delta); } context.PositionX += Lerp(t, animation.Xa0, animation.Xa1); context.PositionY += Lerp(t, animation.Ya0, animation.Ya1); context.ColorBlendType = animation.ColorBlend; if ((animation.Flags & ScalingFlag) == 0) { var scale = Lerp(t, animation.ScaleStart, animation.ScaleEnd); var scaleX = Lerp(t, animation.ScaleXStart, animation.ScaleXEnd); var scaleY = Lerp(t, animation.ScaleYStart, animation.ScaleYEnd); context.ScaleX = scale * scaleX; context.ScaleY = scale * scaleY; } else { context.ScaleX = 1.0f; context.ScaleY = 1.0f; } if ((animation.Flags & ColorMaskingFlag) == 0) { if ((animation.Flags & ColorInterpolationFlag) == 0) { context.Color = Lerp(t, ConvertColor(animation.ColorStart), ConvertColor(animation.ColorEnd)); } else { context.Color = ConvertColor(animation.ColorStart); } } else { context.Color = ConvertColor(animation.ColorStart); } if ((animation.Flags & TraslateFlag) == 0) { context.PositionX += Lerp(t, animation.Xb0, animation.Xb1); context.PositionY += Lerp(t, animation.Yb0, animation.Yb1); } // CALCULATE TRANSOFRMATIONS AND INTERPOLATIONS DrawFrameGroup(context, sequence.FrameGroups[animation.FrameGroupIndex]); }