コード例 #1
0
        /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.SpriteEditor.SpriteVertexOffsetRenderer"/> class.</summary>
        /// <param name="sprite">The sprite view model.</param>
        /// <param name="graphics">The graphics interface for the application.</param>
        /// <param name="swapChain">The swap chain for the render area.</param>
        /// <param name="renderer">The 2D renderer for the application.</param>
        /// <param name="vertexEditor">The editor used to modify the sprite vertices.</param>
        /// <param name="initialZoom">The initial zoom scale value.</param>
        public SpriteVertexOffsetRenderer(ISpriteContent sprite, GorgonGraphics graphics, GorgonSwapChain swapChain, Gorgon2D renderer, ISpriteVertexEditService vertexEditor, float initialZoom)
            : base(sprite, graphics, swapChain, renderer, initialZoom)
        {
            InitialTextureAlpha           = 0;
            _vertexEditor                 = vertexEditor;
            _vertexEditor.RectToClient    = r => ToClient(r).Truncate();
            _vertexEditor.PointToClient   = p => ToClient(p).Truncate();
            _vertexEditor.PointFromClient = p => FromClient(p).Truncate();

            _workingSprite = new GorgonSprite
            {
                Texture           = sprite.Texture,
                TextureRegion     = sprite.TextureCoordinates,
                TextureArrayIndex = TextureArrayIndex,
                Size   = sprite.Size,
                Scale  = DX.Vector2.One,
                Anchor = DX.Vector2.Zero,
                Color  = GorgonColor.White,
                Depth  = 0.1f
            };

            UpdateWorkingSprite();

            _vertexEditor.VerticesChanged     += VertexEditor_VerticesChanged;
            _vertexEditor.KeyboardIconClicked += VertexEditor_KeyboardIconClicked;
            _vertexEditor.VertexSelected      += VertexEditor_VertexSelected;

            _camera = new Gorgon2DPerspectiveCamera(renderer, new DX.Size2F(swapChain.Width, swapChain.Height));
        }
コード例 #2
0
ファイル: SpriteClipRenderer.cs プロジェクト: ishkang/Gorgon
        /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.SpriteEditor.SpriteContentRenderer"/> class.</summary>
        /// <param name="sprite">The sprite view model.</param>
        /// <param name="graphics">The graphics interface for the application.</param>
        /// <param name="swapChain">The swap chain for the render area.</param>
        /// <param name="renderer">The 2D renderer for the application.</param>
        /// <param name="rectClipper">The rectangle clipper used to clip out sprite data.</param>
        /// <param name="initialZoom">The initial zoom scale value.</param>
        public SpriteClipRenderer(ISpriteContent sprite, GorgonGraphics graphics, GorgonSwapChain swapChain, Gorgon2D renderer, IRectClipperService rectClipper, float initialZoom)
            : base(sprite, graphics, swapChain, renderer, initialZoom)
        {
            _clipper = rectClipper;

            _clipper.RectToClient         = r => ToClient(r).Truncate();
            _clipper.PointFromClient      = p => FromClient(p).Truncate();
            _clipper.KeyboardIconClicked += Clipper_KeyboardIconClicked;
            _clipper.RectChanged         += Clipper_RectChanged;
        }
コード例 #3
0
 protected override void Attach(IControl control)
 {
     _isprite = control as ISpriteContent;
     _imouse  = control as IMouseInput;
     _ihitbox = control as ICustomHitBox;
     _icursor = control as ICustomCursor;
     if (_imouse != null || _ihitbox != null)
     {
         gameObject.AddComponent <BoxCollider>();
     }
 }
コード例 #4
0
        /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.SpriteEditor.SpriteContentRenderer"/> class.</summary>
        /// <param name="sprite">The sprite view model.</param>
        /// <param name="graphics">The graphics interface for the application.</param>
        /// <param name="swapChain">The swap chain for the render area.</param>
        /// <param name="renderer">The 2D renderer for the application.</param>
        /// <param name="pickClipper">The sprite picker used to automatically clip sprite data.</param>
        /// <param name="ants">The marching ants rectangle used to draw selection rectangles.</param>
        /// <param name="initialZoom">The initial zoom value.</param>
        public SpritePickRenderer(ISpriteContent sprite, GorgonGraphics graphics, GorgonSwapChain swapChain, Gorgon2D renderer, IPickClipperService pickClipper, IMarchingAnts ants, float initialZoom)
            : base(sprite, graphics, swapChain, renderer, initialZoom)
        {
            _marchAnts = ants;
            _picker    = pickClipper;

            _picker.PointFromClient = p =>
            {
                DX.Vector2 pos = FromClient(p);
                return(new DX.Vector2((int)pos.X, (int)pos.Y));
            };
        }
コード例 #5
0
        /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.SpriteEditor.SpriteContentRenderer"/> class.</summary>
        /// <param name="sprite">The sprite view model.</param>
        /// <param name="graphics">The graphics interface for the application.</param>
        /// <param name="swapChain">The swap chain for the render area.</param>
        /// <param name="renderer">The 2D renderer for the application.</param>
        /// <param name="anchorEditor">The editor for the anchor position.</param>
        /// <param name="initialZoom">The initial zoom scale value.</param>
        public SpriteAnchorRenderer(ISpriteContent sprite, GorgonGraphics graphics, GorgonSwapChain swapChain, Gorgon2D renderer, IAnchorEditService anchorEditor, float initialZoom)
            : base(sprite, graphics, swapChain, renderer, initialZoom)
        {
            _anchorEdit = anchorEditor;

            _anchorEdit.PointToClient   = r => ToClient(r);
            _anchorEdit.PointFromClient = p =>
            {
                DX.Vector2 pos = FromClient(p);
                return(new DX.Vector2((int)pos.X, (int)pos.Y));
            };

            _anchorEdit.AnchorChanged += AnchorEdit_AnchorChanged;
            _anchorEdit.BoundsChanged += AnchorEdit_BoundsChanged;
        }
コード例 #6
0
        /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.SpriteEditor.DefaultSpriteRenderer"/> class.</summary>
        /// <param name="sprite">The sprite view model.</param>
        /// <param name="graphics">The graphics interface for the application.</param>
        /// <param name="swapChain">The swap chain for the render area.</param>
        /// <param name="renderer">The 2D renderer for the application.</param>
        /// <param name="ants">The marching ants rectangle used to draw selection rectangles.</param>
        /// <param name="initialScale">The initial scaling value to apply to the render.</param>
        public DefaultSpriteRenderer(ISpriteContent sprite, GorgonGraphics graphics, GorgonSwapChain swapChain, Gorgon2D renderer, IMarchingAnts ants, float initialScale)
            : base(sprite, graphics, swapChain, renderer, initialScale)
        {
            _marchAnts = ants;

            _workingSprite = new GorgonSprite
            {
                Texture           = sprite.Texture,
                TextureRegion     = sprite.TextureCoordinates,
                TextureArrayIndex = TextureArrayIndex,
                Size   = sprite.Size,
                Scale  = DX.Vector2.One,
                Anchor = DX.Vector2.Zero
            };

            for (int i = 0; i < 4; ++i)
            {
                _workingSprite.CornerColors[i]  = sprite.VertexColors[i];
                _workingSprite.CornerOffsets[i] = sprite.VertexOffsets[i];
            }

            UpdateWorkingSprite();
        }
コード例 #7
0
ファイル: SpriteColorRenderer.cs プロジェクト: ishkang/Gorgon
 /// <summary>Initializes a new instance of the <see cref="T:Gorgon.Editor.SpriteEditor.SpriteContentRenderer"/> class.</summary>
 /// <param name="sprite">The sprite view model.</param>
 /// <param name="graphics">The graphics interface for the application.</param>
 /// <param name="swapChain">The swap chain for the render area.</param>
 /// <param name="renderer">The 2D renderer for the application.</param>
 /// <param name="initialZoom">The initial zoom scale value.</param>
 public SpriteColorRenderer(ISpriteContent sprite, GorgonGraphics graphics, GorgonSwapChain swapChain, Gorgon2D renderer, float initialZoom)
     : base(sprite, graphics, swapChain, renderer, initialZoom)
 {
 }