コード例 #1
0
        private V2DInstance GetV2DInstance(Instance2D inst)
        {
            V2DInstance result = new V2DInstance();

            result.DefinitionName = inst.DefinitionName;
            result.Density        = inst.Density;
            result.Depth          = inst.Depth;
            result.Friction       = inst.Friction;
            result.InstanceName   = inst.InstanceName;
            //result.Joints = inst.Joints;
            DDW.Vex.Matrix m = inst.Matrix;
            //result.Matrix = new V2DMatrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, m.TranslateX, m.TranslateY);
            result.Restitution = inst.Restitution;
            result.StartFrame  = inst.StartFrame;
            result.EndFrame    = inst.TotalFrames + inst.StartFrame;
            result.Visible     = inst.Visible;

            result.Alpha      = inst.Alpha;
            result.X          = inst.X;
            result.Y          = inst.Y;
            result.Rotation   = inst.Rotation;
            result.ScaleX     = inst.ScaleX;
            result.ScaleY     = inst.ScaleY;
            result.Transforms = TransformsConversion(result, inst.Transforms);

            return(result);

            //Dictionary<string, string> dict = null;
            //if (v2d.codeData.ContainsKey(inst.InstanceName))
            //{
            //    dict = v2d.codeData[inst.InstanceName];
            //}
            //return inst.GetV2DInstance(dict);
        }
コード例 #2
0
ファイル: GdiRenderer.cs プロジェクト: lardratboy/it3rate
 public Bitmap RenderFirstFrame(Vex.IDefinition def, Vex.Matrix m)
 {
     using (Matrix sm = new Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, 0, 0))
     {
         return(RenderDefinitionFrames(def, 0, 1, sm)[0]);
     }
 }
コード例 #3
0
ファイル: GdiRenderer.cs プロジェクト: yzqlwt/Swf2XNA
 private System.Drawing.Drawing2D.Matrix GetMatrix(Vex.Matrix m)
 {
     return(new System.Drawing.Drawing2D.Matrix(
                m.ScaleX, m.Rotate0,
                m.Rotate1, m.ScaleY,
                m.TranslateX, m.TranslateY));
 }
コード例 #4
0
        public void DrawDebugInto(Graphics g, PointF location)
        {
            Matrix orgM = g.Transform;
            Matrix newM = orgM.Clone();

            newM.Translate(location.X, location.Y, MatrixOrder.Append);
            g.Transform = newM;

            Vex.Matrix m    = GetMatrix();
            string     text = "i: " + instance.InstanceHash + " d: " + instance.DefinitionId + " dp: " + instance.Depth + "\n";

            text += "loc: " + Location.X.ToString("F2") + " : " + Location.Y.ToString("F2") + "\n";
            text += "mx: " +
                    m.ScaleX.ToString("F2") + ", " +
                    m.Rotate0.ToString("F2") + ", " +
                    m.Rotate1.ToString("F2") + ", " +
                    m.ScaleY.ToString("F2") + "\n";

            SizeF sz = g.MeasureString(text, SystemFonts.DefaultFont);

            Point loc = new Point((int)(-sz.Width / 2), (int)(-sz.Height / 2));

            g.FillRectangle(debugBkg, new Rectangle(loc, Size.Ceiling(sz)));
            g.DrawString(text, SystemFonts.DefaultFont, Brushes.DarkRed, loc);

            g.Transform = orgM;
            newM.Dispose();
        }
コード例 #5
0
        public void UnExecute()
        {
            StageView     stage = MainForm.CurrentStage;
            InstanceGroup sel   = MainForm.CurrentStage.Selection;

            uint[] ids = sel.SelectedIds;

            foreach (Bond b in addedBonds)
            {
                stage.CurrentEditItem.BondStore.RemoveBond(b);
            }

            for (int i = 0; i < ids.Length; i++)
            {
                DesignInstance di = MainForm.CurrentInstanceManager[ids[i]];

                Vex.Matrix m      = di.GetMatrix();
                Vex.Point  offset = new Vex.Point(-offsets[i].X, -offsets[i].Y);
                m.Translate(offset);
                stage.SetDesignInstanceMatrix(di, m);
            }

            if (useSmartBonds)
            {
                foreach (Bond b in previousBonds)
                {
                    stage.CurrentEditItem.BondStore.AddBond(b);
                }
            }

            sel.Update();
            MainForm.CurrentStage.ResetTransformHandles();
            MainForm.CurrentStage.InvalidateTransformedSelection();
        }
コード例 #6
0
ファイル: GdiRenderer.cs プロジェクト: lardratboy/it3rate
 public static Vex.Point GetTransformedPoint(Vex.Point pt, Vex.Matrix m, bool invert)
 {
     PointF[] pts = new PointF[] { pt.SysPointF() };
     using (Matrix ms = m.SysMatrix())
     {
         TransformPoints(pts, ms, invert);
     }
     return(pts[0].VexPoint());
 }
コード例 #7
0
 public void SetMatrix(Vex.Matrix m)
 {
     Vex.Transform t = instance.GetTransformAtTime(0);
     t.Matrix = m;
     if (sysMatrix != null)
     {
         sysMatrix.Dispose();
     }
     sysMatrix          = m.SysMatrix();
     HasSaveableChanges = true;
 }
コード例 #8
0
ファイル: VexExtensions.cs プロジェクト: yzqlwt/Swf2XNA
 public static Matrix SysMatrix(this Vex.Matrix m)
 {
     return(new Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, m.TranslateX, m.TranslateY));
 }
コード例 #9
0
        public void Execute()
        {
            StageView     stage = MainForm.CurrentStage;
            InstanceGroup sel   = MainForm.CurrentStage.Selection;

            Vex.Rectangle bounds = sel.StrokeBounds;
            uint[]        ids    = sel.SelectedIds;
            offsets = new Vex.Point[ids.Length];

            InstanceManager im      = MainForm.CurrentInstanceManager;
            List <uint>     sortIds = new List <uint>(ids);

            im.SortIndexesByLocation(sortIds, chainType);

            Vex.Point target = Vex.Point.Empty;

            if (chainType == ChainType.DistributedHorizontal)
            {
                float firstWidth      = MainForm.CurrentInstanceManager[sortIds[0]].StrokeBounds.Width;
                float lastWidth       = MainForm.CurrentInstanceManager[sortIds[sortIds.Count - 1]].StrokeBounds.Width;
                float fillWidth       = bounds.Width - firstWidth - lastWidth;
                float remainingWidths = 0;
                for (int i = 1; i < sortIds.Count - 1; i++)
                {
                    DesignInstance di = MainForm.CurrentInstanceManager[sortIds[i]];
                    remainingWidths += di.StrokeBounds.Width;
                }

                float spacing = (fillWidth - remainingWidths) / (sortIds.Count - 1);
                float curLoc  = bounds.Left;

                for (int i = 0; i < sortIds.Count; i++)
                {
                    DesignInstance di     = MainForm.CurrentInstanceManager[sortIds[i]];
                    Vex.Point      offset = new Vex.Point(curLoc - di.StrokeBounds.Left, 0);

                    Vex.Matrix m = di.GetMatrix();
                    m.Translate(offset);
                    stage.SetDesignInstanceMatrix(di, m);

                    curLoc += spacing + di.StrokeBounds.Width;

                    int realIndex = Array.IndexOf(ids, sortIds[i]);
                    offsets[realIndex] = offset;
                }

                target = new Vex.Point(spacing, float.NaN);
            }
            else if (chainType == ChainType.DistributedVertical)
            {
                float firstHeight      = MainForm.CurrentInstanceManager[sortIds[0]].StrokeBounds.Height;
                float lastHeight       = MainForm.CurrentInstanceManager[sortIds[sortIds.Count - 1]].StrokeBounds.Height;
                float fillHeight       = bounds.Height - firstHeight - lastHeight;
                float remainingHeights = 0;
                for (int i = 1; i < sortIds.Count - 1; i++)
                {
                    DesignInstance di = MainForm.CurrentInstanceManager[sortIds[i]];
                    remainingHeights += di.StrokeBounds.Height;
                }

                float spacing = (fillHeight - remainingHeights) / (sortIds.Count - 1);
                float curLoc  = bounds.Top;

                for (int i = 0; i < sortIds.Count; i++)
                {
                    DesignInstance di     = MainForm.CurrentInstanceManager[sortIds[i]];
                    Vex.Point      offset = new Vex.Point(0, curLoc - di.StrokeBounds.Top);

                    Vex.Matrix m = di.GetMatrix();
                    m.Translate(offset);
                    stage.SetDesignInstanceMatrix(di, m);

                    curLoc += spacing + di.StrokeBounds.Height;

                    int realIndex = Array.IndexOf(ids, sortIds[i]);
                    offsets[realIndex] = offset;
                }
                target = new Vex.Point(float.NaN, spacing);
            }
            else
            {
                Vex.Rectangle contrainedBounds = bounds.Clone();
                stage.CurrentEditItem.BondStore.ConstrainBounds(sortIds, ref contrainedBounds, chainType);

                switch (chainType)
                {
                case ChainType.AlignedLeft:
                    target = new Vex.Point(contrainedBounds.Left, float.NaN);
                    break;

                case ChainType.AlignedCenterVertical:
                    target = new Vex.Point(contrainedBounds.Center.X, float.NaN);
                    break;

                case ChainType.AlignedRight:
                    target = new Vex.Point(contrainedBounds.Right, float.NaN);
                    break;

                case ChainType.AlignedTop:
                    target = new Vex.Point(float.NaN, contrainedBounds.Top);
                    break;

                case ChainType.AlignedCenterHorizontal:
                    target = new Vex.Point(float.NaN, contrainedBounds.Center.Y);
                    break;

                case ChainType.AlignedBottom:
                    target = new Vex.Point(float.NaN, contrainedBounds.Bottom);
                    break;
                }

                for (int i = 0; i < sortIds.Count; i++)
                {
                    DesignInstance di     = MainForm.CurrentInstanceManager[sortIds[i]];
                    Vex.Point      offset = Vex.Point.Zero;

                    switch (chainType)
                    {
                    case ChainType.AlignedLeft:
                        offset.X = target.X - di.StrokeBounds.Left;
                        break;

                    case ChainType.AlignedCenterVertical:
                        offset.X = target.X - (di.StrokeBounds.Left + di.StrokeBounds.Width / 2);
                        break;

                    case ChainType.AlignedRight:
                        offset.X = target.X - (di.StrokeBounds.Left + di.StrokeBounds.Width);
                        break;

                    case ChainType.AlignedTop:
                        offset.Y = target.Y - di.StrokeBounds.Top;
                        break;

                    case ChainType.AlignedCenterHorizontal:
                        offset.Y = target.Y - (di.StrokeBounds.Top + di.StrokeBounds.Height / 2);
                        break;

                    case ChainType.AlignedBottom:
                        offset.Y = target.Y - (di.StrokeBounds.Top + di.StrokeBounds.Height);
                        break;
                    }

                    Vex.Matrix m = di.GetMatrix();
                    m.Translate(offset);
                    stage.SetDesignInstanceMatrix(di, m);

                    offsets[i] = offset;
                }
            }

            if (useSmartBonds)
            {
                stage.CurrentEditItem.BondStore.Align(sortIds.ToArray(), chainType, target, addedBonds, previousBonds);
            }

            sel.Update();
            MainForm.CurrentStage.ResetTransformHandles();
            MainForm.CurrentStage.InvalidateTransformedSelection();
        }
コード例 #10
0
        public Bitmap GetImage(Vex.Matrix m)
        {
            Bitmap result = stage.Gdi.RenderFirstFrame(definition, m);

            return(result);
        }