コード例 #1
0
ファイル: V2DTransform.cs プロジェクト: Hamsand/Swf2XNA
 public static V2DTransform[] GetV2DTransformArray(V2DGenericTransform[] t)
 {
     V2DTransform[] result = new V2DTransform[t.Length];
     for (int i = 0; i < t.Length; i++)
     {
         result[i] = t[i];
     }
     return result;
 }
コード例 #2
0
ファイル: GenV2DWorld.cs プロジェクト: Hamsand/Swf2XNA
        public V2DGenericTransform[] TransformsConversion(V2DInstance obj, List<Transform> trs)
        {
            V2DGenericTransform[] result = new V2DGenericTransform[trs.Count];
            if (trs.Count > 0)
            {
                MatrixComponents firstMc = trs[0].Matrix.GetMatrixComponents();
                float firstAlpha = trs[0].Alpha;
                obj.X += firstMc.TranslateX;
                obj.Y += firstMc.TranslateY;
                obj.Rotation += (float)(firstMc.Rotation * Math.PI / 180);
                obj.ScaleX *= firstMc.ScaleX;
                obj.ScaleY *= firstMc.ScaleY;
                obj.Alpha *= firstAlpha;

                for (int i = 0; i < trs.Count; i++)
                {
                    Transform tin = trs[i];

                    uint sf = (uint)Math.Round(tin.StartTime / (1000d / v2dWorld.FrameRate));
                    uint ef = (uint)Math.Round(tin.EndTime / (1000d / v2dWorld.FrameRate)) - 1;
                    MatrixComponents mc = tin.Matrix.GetMatrixComponents();
                    V2DGenericTransform tout = new V2DGenericTransform(
                        sf,
                        ef,
                        mc.ScaleX / firstMc.ScaleX,
                        mc.ScaleY / firstMc.ScaleY,
                        (float)(mc.Rotation * Math.PI / 180) - (float)(firstMc.Rotation * Math.PI / 180),
                        mc.TranslateX - firstMc.TranslateX,
                        mc.TranslateY - firstMc.TranslateY,
                        tin.Alpha / firstAlpha);

                    //V2DTransform tout = new V2DTransform(
                    //    (uint)Math.Floor(tin.StartTime / (1000d / v2dWorld.FrameRate)),
                    //    (uint)Math.Floor(tin.EndTime / (1000d / v2dWorld.FrameRate)),
                    //    new V2DMatrix(  tin.Matrix.ScaleX, tin.Matrix.Rotate0, tin.Matrix.Rotate1, tin.Matrix.ScaleX,
                    //                    tin.Matrix.TranslateX, tin.Matrix.TranslateY),
                    //    tin.Alpha);

                    tout.IsTweening = tin.IsTweening;

                    result[i] = tout;
                }
            }
            return result;
        }