Exemplo n.º 1
0
 public void Begin(SpriteSortMode sortMode, SpriteBlendMode blendMode,  SaveStateMode stateMode)
 {
     _blendMode = blendMode;
     _sortMode = sortMode;
     _saveMode = stateMode;
     _matrix = Matrix.Identity;
 }
Exemplo n.º 2
0
 public void Begin(SpriteSortMode sortMode, SpriteBlendMode blendMode, SaveStateMode stateMode, Matrix transformMatrix)
 {
     _blendMode = blendMode;
     _sortMode = sortMode;
     _saveMode = stateMode;
     _matrix = transformMatrix;
 }
Exemplo n.º 3
0
        public void StartSpriteBatch(SpriteBlendMode blendMode, SpriteSortMode sortMode)
        {
            if (_sprites.Count > 0)
            {
                throw new InvalidOperationException("SpriteBatch is in incorrect state");
            }

            _actualBlendMode = blendMode;
            _actualSortMode  = sortMode;

            Initialise2DOpenGL();

            // Set the current blend mode
            switch (_actualBlendMode)
            {
            case SpriteBlendMode.Additive:
                GL.Enable(All.Blend);
                GL.BlendFunc(All.SrcAlpha, All.One);
                break;

            case SpriteBlendMode.AlphaBlend:
                GL.Enable(All.Blend);
                GL.BlendFunc(All.SrcAlpha, All.OneMinusSrcAlpha);
                break;

            case SpriteBlendMode.PreMultiplied:
                GL.Enable(All.Blend);
                GL.BlendFunc(All.One, All.OneMinusSrcAlpha);
                break;

            case SpriteBlendMode.None:
                break;
            }
        }
Exemplo n.º 4
0
 //* -----------------------------------------------------------------------*
 /// <summary>描画処理を予約します。</summary>
 ///
 /// <param name="tex">テクスチャ</param>
 /// <param name="pos">描画先座標</param>
 /// <param name="halign">位置揃え(横)</param>
 /// <param name="valign">位置揃え(縦)</param>
 /// <param name="srcRect">描画元矩形</param>
 /// <param name="color">色</param>
 /// <param name="fLayer">レイヤ番号</param>
 /// <param name="blend">合成モード</param>
 public void add(
     Texture2D tex, Vector2 pos, EAlign halign, EAlign valign, Rectangle srcRect,
     Color color, float fLayer, SpriteBlendMode blend
     )
 {
     add(tex, pos, halign, valign, srcRect, color, 0, Vector2.One, SpriteEffects.None, fLayer, blend);
 }
Exemplo n.º 5
0
 public void Begin(SpriteSortMode sortMode, SpriteBlendMode blendMode, SaveStateMode stateMode)
 {
     _blendMode = blendMode;
     _sortMode  = sortMode;
     _saveMode  = stateMode;
     _matrix    = Matrix.Identity;
 }
Exemplo n.º 6
0
 public void Begin(SpriteSortMode sortMode, SpriteBlendMode blendMode, SaveStateMode stateMode, Matrix transformMatrix)
 {
     _blendMode = blendMode;
     _sortMode  = sortMode;
     _saveMode  = stateMode;
     _matrix    = transformMatrix;
 }
Exemplo n.º 7
0
        //* -----------------------------------------------------------------------*
        /// <summary>描画処理を予約します。</summary>
        ///
        /// <param name="spriteFont">スプライトフォント テクスチャ</param>
        /// <param name="text">描画したいテキスト</param>
        /// <param name="pos">座標</param>
        /// <param name="color">色</param>
        /// <param name="fRotate">回転(ラジアン)</param>
        /// <param name="origin">原点座標</param>
        /// <param name="scale">拡大率</param>
        /// <param name="effects">反転効果</param>
        /// <param name="fLayer">レイヤ番号</param>
        /// <param name="blend">合成モード</param>
        public void add(
            SpriteFont spriteFont, string text, Vector2 pos, Color color, float fRotate,
            Vector2 origin, Vector2 scale, SpriteEffects effects, float fLayer,
            SpriteBlendMode blend
            )
        {
            SSpriteDrawInfo info = SSpriteDrawInfo.initialized;

            info.spriteFont = spriteFont;
            info.text       = text;
            info.position   = resolution == null ? pos : resolution.resizeFromVGA(pos);
            info.color      = color;
            info.fRotation  = fRotate;
            info.origin     = origin;
            info.blendMode  = blend;
            if (resolution == null)
            {
                info.scale = scale;
            }
            else
            {
                if (resolution.GetType() == typeResAF || resolution.GetType().IsSubclassOf(typeResAF))
                {
                    CResolutionAspectFix res = (CResolutionAspectFix)resolution;
                    info.scale = scale * res.scaleGapFromVGA;
                }
                else
                {
                    info.scale = scale * resolution.scaleGapFromVGA;
                }
            }
            info.effects     = effects;
            info.fLayerDepth = fLayer;
            setReserve(info);
        }
Exemplo n.º 8
0
 public override void Begin(GraphicsDevice device, SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode, Local.Matrix transformMatrix)
 {
     _childRenderer = GetCurrentRenderer();
     _childRenderer.Begin(device, blendMode, sortMode, stateMode, transformMatrix);
     currentSortMode = sortMode;
     base.Begin(device, blendMode, sortMode, stateMode, transformMatrix);
 }
Exemplo n.º 9
0
 /// <summary>
 /// 绘制一个标注点
 /// </summary>
 /// <param name="pos">逻辑坐标</param>
 /// <param name="scale">大小</param>
 /// <param name="color">颜色</param>
 /// <param name="layerDepth">深度,0表示最表层,1表示最深层</param>
 /// <param name="blendMode">混合模式</param>
 public void DrawPoint ( Vector2 pos, float scale, Color color, float layerDepth, SpriteBlendMode blendMode )
 {
     if (blendMode == SpriteBlendMode.Additive)
         engine.SpriteMgr.additiveSprite.Draw( pointTexture, engine.CoordinMgr.ScreenPos( pos ), null, color, 0, new Vector2( 16, 16 ), scale, SpriteEffects.None, layerDepth );
     else
         engine.SpriteMgr.alphaSprite.Draw( pointTexture, engine.CoordinMgr.ScreenPos( pos ), null, color, 0, new Vector2( 16, 16 ), scale, SpriteEffects.None, layerDepth );
 }
Exemplo n.º 10
0
        //* -----------------------------------------------------------------------*
        /// <summary>描画処理を予約します。</summary>
        ///
        /// <param name="tex">テクスチャ</param>
        /// <param name="pos">描画先座標</param>
        /// <param name="halign">位置揃え(横)</param>
        /// <param name="valign">位置揃え(縦)</param>
        /// <param name="srcRect">描画元矩形</param>
        /// <param name="color">色</param>
        /// <param name="fRotate">回転(ラジアン)</param>
        /// <param name="scale">拡大率</param>
        /// <param name="effects">反転効果</param>
        /// <param name="fLayer">レイヤ番号</param>
        /// <param name="blend">合成モード</param>
        public void add(
            Texture2D tex, Vector2 pos, EAlign halign, EAlign valign, Rectangle srcRect, Color color,
            float fRotate, Vector2 scale, SpriteEffects effects, float fLayer, SpriteBlendMode blend
            )
        {
            Vector2 origin = Vector2.Zero;

            switch (halign)
            {
            case EAlign.Center:
                origin.X = (float)(srcRect.Width) * 0.5f;
                break;

            case EAlign.RightBottom:
                origin.X = srcRect.Width;
                break;
            }
            switch (valign)
            {
            case EAlign.Center:
                origin.Y = (float)(srcRect.Height) * 0.5f;
                break;

            case EAlign.RightBottom:
                origin.Y = srcRect.Height;
                break;
            }
            add(tex, new Rectangle((int)(pos.X), (int)(pos.Y),
                                   (int)(srcRect.Width * scale.X), (int)(srcRect.Height * scale.Y)),
                srcRect, color, fRotate, origin, effects, fLayer, blend);
        }
Exemplo n.º 11
0
 //* -----------------------------------------------------------------------*
 /// <summary>描画処理を予約します。</summary>
 ///
 /// <param name="tex">テクスチャ</param>
 /// <param name="dstRect">描画先矩形</param>
 /// <param name="srcRect">描画元矩形</param>
 /// <param name="color">色</param>
 /// <param name="rotate">回転(ラジアン)</param>
 /// <param name="origin">原点座標</param>
 /// <param name="effects">反転効果</param>
 /// <param name="layer">重ね合わせ深度。</param>
 /// <param name="blend">合成モード</param>
 public void add(
     Texture2D tex, Rectangle dstRect, Rectangle srcRect, Color color, float rotate,
     Vector2 origin, SpriteEffects effects, float layer, SpriteBlendMode blend)
 {
     add(tex, dstRect, srcRect, color, rotate, origin, TextureAddressMode.Clamp,
         effects, layer, blend);
 }
Exemplo n.º 12
0
 //* -----------------------------------------------------------------------*
 /// <summary>描画処理を予約します。</summary>
 ///
 /// <param name="tex">テクスチャ</param>
 /// <param name="dstRect">描画先矩形</param>
 /// <param name="srcRect">描画元矩形</param>
 /// <param name="color">色</param>
 /// <param name="layer">重ね合わせ深度。</param>
 /// <param name="blend">合成モード</param>
 public void add(
     Texture2D tex, Rectangle dstRect, Rectangle srcRect,
     Color color, float layer, SpriteBlendMode blend)
 {
     add(tex, dstRect, srcRect, color, 0,
         Vector2.Zero, SpriteEffects.None, layer, blend);
 }
        }         // AddSpriteToRender(texture, rect, gfxRect)

        /// <summary>
        /// Add sprite to render
        /// </summary>
        /// <param name="texture">Texture</param>
        /// <param name="rect">Rectangle</param>
        /// <param name="gfxRect">Gfx rectangle</param>
        public static void AddSpriteToRender(
            Texture texture, Rectangle rect, Rectangle gfxRect, Color color,
            SpriteBlendMode blendMode)
        {
            sprites.Add(
                new SpriteToRender(texture, rect, gfxRect, color, blendMode));
        }         // AddSpriteToRender(texture, rect, gfxRect)
Exemplo n.º 14
0
 //* -----------------------------------------------------------------------*
 /// <summary>描画処理を予約します。</summary>
 ///
 /// <param name="tex">テクスチャ</param>
 /// <param name="pos">描画先座標</param>
 /// <param name="halign">位置揃え(横)</param>
 /// <param name="valign">位置揃え(縦)</param>
 /// <param name="srcRect">描画元矩形</param>
 /// <param name="color">色</param>
 /// <param name="rotate">回転(ラジアン)</param>
 /// <param name="scale">拡大率</param>
 /// <param name="effects">反転効果</param>
 /// <param name="layer">重ね合わせ深度。</param>
 /// <param name="blend">合成モード</param>
 public void add(
     Texture2D tex, Vector2 pos, EAlign halign, EAlign valign, Rectangle srcRect, Color color,
     float rotate, Vector2 scale, SpriteEffects effects, float layer, SpriteBlendMode blend)
 {
     add(tex, pos, halign, valign, srcRect, color, rotate, scale, TextureAddressMode.Clamp,
         SpriteEffects.None, layer, blend);
 }
Exemplo n.º 15
0
 public new void Begin(
     SpriteBlendMode blendMode,
     SpriteSortMode sortMode,
     SaveStateMode stateMode)
 {
     base.Begin(blendMode, sortMode, stateMode);
     this.isbegan = true;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Begins SpriteBatch drawing, and marks the beginning of a PIX event.
 /// </summary>
 /// <param name="spriteBatch">The SpriteBatch to use</param>
 /// <param name="blendMode">Blending options to use when rendering</param>
 /// <param name="userMessage">A string to append to the PIX event name</param>
 public static void BeginPIX(this SpriteBatch spriteBatch,
                             SpriteBlendMode blendMode,
                             string userMessage)
 {
     BeginEvent(MakeName("SpriteBatch Drawing", userMessage));
     SetMarker("SpriteBatch.Begin Called");
     spriteBatch.Begin(blendMode);
 }
Exemplo n.º 17
0
        public void UIBegin(SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode)
        {
            this._BlendMode     = blendMode;
            this._SortMode      = sortMode;
            this._SaveStateMode = stateMode;

            this.Begin(blendMode, sortMode, stateMode);
        }
Exemplo n.º 18
0
 //======================================================[ Constructors & Methods ]
 public EmitterGroup(string name)
 {
     _name = name;
     _emitters = new List<Emitter>();
     _modifiers = new List<Modifier>();
     _blend = SpriteBlendMode.Additive;
     Position = Vector2.Zero;
 }
Exemplo n.º 19
0
 public new void Begin(
     SpriteBlendMode blendMode,
     SpriteSortMode sortMode,
     SaveStateMode stateMode,
     Matrix transformMatrix)
 {
     base.Begin(blendMode, sortMode, stateMode, transformMatrix);
     this.isbegan = true;
 }
Exemplo n.º 20
0
 public void Draw(SpriteBatch batch, Color color, SpriteBlendMode blendMode)
 {
     batch.Begin(blendMode, SpriteSortMode.Immediate,
                 SaveStateMode.None);
     batch.Draw(sheet.Texture, positionValue, sheet[currentFrameValue],
                color, rotationValue, originValue, scaleValue,
                SpriteEffects.None, 0f);
     batch.End();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="spriteBatchName">The string name used to access the sprite batch</param>
 /// <param name="desiredBlendMode">The blend mode to use for the sprite batch</param>
 /// <param name="desiredSortMode">The sort mode to use for the sprite batch</param>
 /// <param name="desiredSaveMode">The save mode to use for the sprite batch</param>
 /// <param name="updateCameraMatrix">The flag used to denote if the matrix needs to be updated every update cycle</param>
 public SpriteBatchDescription(string spriteBatchName, SpriteBlendMode desiredBlendMode, 
     SpriteSortMode desiredSortMode, SaveStateMode desiredSaveMode, bool updateCameraMatrix)
 {
     this.spriteBatchName = spriteBatchName;
     this.desiredBlendMode = desiredBlendMode;
     this.desiredSortMode = desiredSortMode;
     this.desiredStateMode = desiredSaveMode;
     this.updateCameraMatrix = updateCameraMatrix;
     this.currentMatrix = Matrix.Identity;
 }
 /// <summary>
 /// Draw all of the particle effects in the manager.
 /// </summary>
 /// <param name="spriteBatch">The SpriteBatch object used to draw.</param>
 /// <param name="blendMode">Filters the systems drawn in this pass.</param>
 public virtual void Draw(SpriteBatch spriteBatch, SpriteBlendMode blendMode)
 {
     for (int i = 0; i < activeParticleEffects.Count; ++i)
     {
         if (activeParticleEffects[i].Active)
         {
             activeParticleEffects[i].Draw(spriteBatch, blendMode);
         }
     }
 }
 /// <summary>
 /// Draw all of the particle effects in the manager.
 /// </summary>
 /// <param name="spriteBatch">The SpriteBatch object used to draw.</param>
 /// <param name="blendMode">Filters the systems drawn in this pass.</param>
 public virtual void Draw(SpriteBatch spriteBatch, SpriteBlendMode blendMode)
 {
     for (int i = 0; i < activeParticleEffects.Count; ++i)
     {
         if (activeParticleEffects[i].Active)
         {
             activeParticleEffects[i].Draw(spriteBatch, blendMode);
         }
     }
 }
Exemplo n.º 24
0
        internal void SetBlending(bool additive)
        {
            SpriteBlendMode thisBlend = additive ? SpriteBlendMode.Additive : SpriteBlendMode.AlphaBlend;

            if (currentBlend != thisBlend || !hasBegun)
            {
                currentBlend = thisBlend;
                startBatch(true);
            }
        }
            }             // SpriteToRender(setTexture, setRect, setSourceRect)

            /// <summary>
            /// Create sprite to render
            /// </summary>
            /// <param name="setTex">Set tex</param>
            /// <param name="setRect">Set rectangle</param>
            /// <param name="setPixelRect">Set pixel rectangle</param>
            /// <param name="setColor">Set color</param>
            /// <param name="alphaMode">Alpha mode</param>
            public SpriteToRender(Texture setTex, Rectangle setRect,
                                  Rectangle setPixelRect, Color setColor,
                                  SpriteBlendMode setBlendMode)
            {
                texture   = setTex;
                rect      = setRect;
                pixelRect = setPixelRect;
                color     = setColor;
                blendMode = setBlendMode;
            }             // SpriteToRender(setTex, setRect, setPixelRect)
Exemplo n.º 26
0
 /// <summary>
 /// 设置该精灵的绘制参数
 /// </summary>
 /// <param name="origin">贴图的中心,以贴图坐标表示</param>
 /// <param name="pos">逻辑位置</param>
 /// <param name="width">逻辑宽度</param>
 /// <param name="height">逻辑高度</param>
 /// <param name="rata">逻辑方位角</param>
 /// <param name="color">绘制颜色</param>
 /// <param name="layerDepth">深度,1为最低层,0为最表层</param>
 /// <param name="blendMode">采用的混合模式</param>
 public void SetParameters(Vector2 origin, Vector2 pos, float width, float height, float rata, Color color, float layerDepth, SpriteBlendMode blendMode)
 {
     Origin     = origin;
     Pos        = pos;
     Width      = width;
     Height     = height;
     Rata       = rata;
     Color      = color;
     LayerDepth = layerDepth;
     BlendMode  = blendMode;
 }
Exemplo n.º 27
0
 /// <summary>
 /// Begins SpriteBatch drawing, and marks the beginning of a PIX event.
 /// </summary>
 /// <param name="spriteBatch">The SpriteBatch to use</param>
 /// <param name="blendMode">Blending options to use when rendering</param>
 /// <param name="sortMode">Sorting options to use when rendering</param>
 /// <param name="stateMode">Rendering state options</param>
 /// <param name="transformMatrix">A matrix to apply to position, rotation, scale, and depth data passed to SpriteBatch.Draw</param>
 /// <param name="userMessage">A string to append to the PIX event name. Pass null for no message.</param>
 public static void BeginPIX(this SpriteBatch spriteBatch,
                             SpriteBlendMode blendMode,
                             SpriteSortMode sortMode,
                             SaveStateMode stateMode,
                             Matrix transformMatrix,
                             string userMessage)
 {
     BeginEvent(MakeName("SpriteBatch Drawing", userMessage));
     SetMarker("SpriteBatch.Begin Called");
     spriteBatch.Begin(blendMode, sortMode, stateMode, transformMatrix);
 }
Exemplo n.º 28
0
        //* -----------------------------------------------------------------------*
        /// <summary>描画処理を予約します。</summary>
        ///
        /// <param name="tex">テクスチャ</param>
        /// <param name="pos">描画先座標</param>
        /// <param name="halign">位置揃え(横)</param>
        /// <param name="valign">位置揃え(縦)</param>
        /// <param name="srcRect">描画元矩形</param>
        /// <param name="color">色</param>
        /// <param name="fRotate">回転(ラジアン)</param>
        /// <param name="scale">拡大率</param>
        /// <param name="effects">反転効果</param>
        /// <param name="fLayer">レイヤ番号</param>
        /// <param name="blend">合成モード</param>
        public void add(
            Texture2D tex, Vector2 pos, EAlign halign, EAlign valign, Rectangle srcRect, Color color,
            float fRotate, Vector2 scale, SpriteEffects effects, float fLayer, SpriteBlendMode blend
            )
        {
            Vector2 origin = new Vector2(
                halign.origin(srcRect.Width), valign.origin(srcRect.Height));

            add(tex, new Rectangle((int)(pos.X), (int)(pos.Y),
                                   (int)(srcRect.Width * scale.X), (int)(srcRect.Height * scale.Y)),
                srcRect, color, fRotate, origin, effects, fLayer, blend);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Render on screen
 /// </summary>
 /// <param name="rect">Rectangle</param>
 /// <param name="pixelRect">Pixel rectangle</param>
 /// <param name="color">Color</param>
 /// <param name="blendMode">Blend mode</param>
 public void RenderOnScreen(Rectangle rect, Rectangle pixelRect,
                            Color color, SpriteBlendMode blendMode)
 {
     if (blendMode == SpriteBlendMode.Additive)
     {
         additiveSprite.Draw(internalXnaTexture, rect, pixelRect, color);
     }
     else
     {
         alphaSprite.Draw(internalXnaTexture, rect, pixelRect, color);
     }
     //SpriteHelper.AddSpriteToRender(this, rect, pixelRect, color, blendMode);
 }
Exemplo n.º 30
0
        /// <summary>
        /// 在逻辑坐标中绘制一个填充的矩形
        /// </summary>
        /// <param name="rect">要填充的矩形</param>
        /// <param name="color">颜色</param>
        /// <param name="layerDepth">深度,0表示最表层,1表示最深层</param>
        /// <param name="blenMode">混合模式</param>
        public void FillRectangle(Rectangle rect, Color color, float layerDepth, SpriteBlendMode blenMode)
        {
            Vector2   scrnPos    = engine.CoordinMgr.ScreenPos(new Vector2(rect.X, rect.Y));
            Rectangle destinRect = new Rectangle((int)scrnPos.X, (int)scrnPos.Y, engine.CoordinMgr.ScrnLength(rect.Width), engine.CoordinMgr.ScrnLength(rect.Height));

            if (blenMode == SpriteBlendMode.Additive)
            {
                engine.SpriteMgr.additiveSprite.Draw(retangleTexture, destinRect, null, color, -engine.CoordinMgr.Rota, Vector2.Zero, SpriteEffects.None, layerDepth);
            }
            else
            {
                engine.SpriteMgr.alphaSprite.Draw(retangleTexture, destinRect, null, color, -engine.CoordinMgr.Rota, Vector2.Zero, SpriteEffects.None, layerDepth);
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// Draw the particle effect.
        /// </summary>
        /// <param name="spriteBatch">The SpriteBatch object used to draw.</param>
        /// <param name="blendMode">Filters the systems drawn in this pass.</param>
        public virtual void Draw(SpriteBatch spriteBatch, SpriteBlendMode blendMode)
        {
            if (!active)
            {
                return;
            }

            // draw each system
            for (int i = 0; i < particleSystems.Count; ++i)
            {
                if (particleSystems[i].BlendMode == blendMode)
                {
                    particleSystems[i].Draw(spriteBatch);
                }
            }
        }
Exemplo n.º 32
0
 //* -----------------------------------------------------------------------*
 /// <summary>
 /// テクスチャ向けに初期化します。
 /// </summary>
 public void initialize()
 {
     blendMode            = SpriteBlendMode.None;
     color                = Color.White;
     fRotation            = 0f;
     origin               = Vector2.Zero;
     effects              = SpriteEffects.None;
     fLayerDepth          = 0f;
     texture              = null;
     destinationRectangle = Rectangle.Empty;
     sourceRectangle      = Rectangle.Empty;
     spriteFont           = null;
     text     = null;
     position = Vector2.Zero;
     scale    = Vector2.One;
 }
Exemplo n.º 33
0
        // GG EDIT added
        public static BlendState FromSpriteBlendMode(SpriteBlendMode mode)
        {
            switch (mode)
            {
            case SpriteBlendMode.Additive:
                return(Additive);

            case SpriteBlendMode.AlphaBlend:
                return(AlphaBlend);

            case SpriteBlendMode.None:
                return(Opaque);

            case SpriteBlendMode.PreMultiplied:
                return(NonPremultiplied);    // ??? probably wrong?
            }
            return(Opaque);
        }
Exemplo n.º 34
0
        //* -----------------------------------------------------------------------*
        /// <summary>描画処理を予約します。</summary>
        ///
        /// <param name="tex">テクスチャ</param>
        /// <param name="dstRect">描画先矩形</param>
        /// <param name="srcRect">描画元矩形</param>
        /// <param name="color">色</param>
        /// <param name="fRotate">回転(ラジアン)</param>
        /// <param name="origin">原点座標</param>
        /// <param name="effects">反転効果</param>
        /// <param name="fLayer">レイヤ番号</param>
        /// <param name="blend">合成モード</param>
        public void add(
            Texture2D tex, Rectangle dstRect, Rectangle srcRect, Color color, float fRotate,
            Vector2 origin, SpriteEffects effects, float fLayer, SpriteBlendMode blend
            )
        {
            SSpriteDrawInfo info = new SSpriteDrawInfo();

            info.initialize();
            info.texture = tex;
            info.destinationRectangle = resolution.convertRectangle(dstRect);
            info.sourceRectangle      = srcRect;
            info.color       = color;
            info.fRotation   = fRotate + resolution.rotate;
            info.origin      = origin;
            info.effects     = effects;
            info.fLayerDepth = fLayer;
            info.blendMode   = blend;
            _private.drawCache.Add(info);
        }
Exemplo n.º 35
0
        public void Begin(GraphicsDevice device, SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode, Local.Matrix transformMatrix)
        {

            //transformMatrix = Matrix.Identity;


            Rect rect = new Rect(
                (device.Viewport.X),
                (device.Viewport.Y),
                device.Viewport.Width,
                device.Viewport.Height);

            if (rect != lastRect || !MatricesAreEqual(transformMatrix, lastMatrix))
            {
                transformMatrix.M41 += device.Viewport.X;
                transformMatrix.M42 += device.Viewport.Y;
                MatrixTransform matrixTransform = new MatrixTransform();
                System.Windows.Media.Matrix matrix = new System.Windows.Media.Matrix(
                   transformMatrix.M11,
                    transformMatrix.M12,
                    transformMatrix.M21,
                    transformMatrix.M22,
                    transformMatrix.M41,
                    transformMatrix.M42);
                matrixTransform.Matrix = matrix;
                System.Windows.Media.RectangleGeometry rectangleGeometry = new System.Windows.Media.RectangleGeometry();
                rectangleGeometry.Rect = rect;
                MatrixTransform inverse = matrixTransform.Inverse as MatrixTransform;

                rectangleGeometry.Transform = inverse;
                Canvas.Clip = rectangleGeometry;

                matrixTransform.Matrix = matrix;
                TransformMatrix = transformMatrix;
                lastRect = rect;
                lastMatrix = transformMatrix;
                Canvas.Width = rect.Width;
                Canvas.Height = rect.Height;
            }
            InUse = true;
            Begin();
        }
Exemplo n.º 36
0
        //* -----------------------------------------------------------------------*
        /// <summary>描画処理を予約します。</summary>
        ///
        /// <param name="tex">テクスチャ</param>
        /// <param name="dstRect">描画先矩形</param>
        /// <param name="srcRect">描画元矩形</param>
        /// <param name="color">色</param>
        /// <param name="fRotate">回転(ラジアン)</param>
        /// <param name="origin">原点座標</param>
        /// <param name="effects">反転効果</param>
        /// <param name="fLayer">レイヤ番号</param>
        /// <param name="blend">合成モード</param>
        public void add(
            Texture2D tex, Rectangle dstRect, Rectangle srcRect, Color color, float fRotate,
            Vector2 origin, SpriteEffects effects, float fLayer, SpriteBlendMode blend
            )
        {
            SSpriteDrawInfo info = SSpriteDrawInfo.initialized;

            info.texture = tex;
            info.destinationRectangle = resolution == null ?
                                        dstRect : resolution.resizeFromVGA(dstRect);
            info.sourceRectangle = srcRect;
            info.color           = color;
            info.fRotation       = fRotate -
                                   (resolution != null && resolution.vertical ? 0 : 0);
            info.origin      = origin;
            info.effects     = effects;
            info.fLayerDepth = fLayer;
            info.blendMode   = blend;
            setReserve(info);
        }
Exemplo n.º 37
0
        //* -----------------------------------------------------------------------*
        /// <summary>描画処理を予約します。</summary>
        ///
        /// <param name="tex">テクスチャ</param>
        /// <param name="dstRect">描画先矩形</param>
        /// <param name="srcRect">描画元矩形</param>
        /// <param name="color">色</param>
        /// <param name="fRotate">回転(ラジアン)</param>
        /// <param name="origin">原点座標</param>
        /// <param name="effects">反転効果</param>
        /// <param name="fLayer">レイヤ番号</param>
        /// <param name="blend">合成モード</param>
        public void add(
            Texture2D tex, Rectangle dstRect, Rectangle srcRect, Color color, float fRotate,
            Vector2 origin, SpriteEffects effects, float fLayer, SpriteBlendMode blend
            )
        {
            CDrawInfo info =
                GRAVE_DRAW.Count > 0 ? GRAVE_DRAW.Dequeue() : new CDrawInfo();

            info.texture = tex;
            info.destinationRectangle = resolution == null ?
                                        dstRect : resolution.resizeFromVGA(dstRect);
            info.sourceRectangle = srcRect;
            info.color           = color;
            info.fRotation       = fRotate;
            info.origin          = origin;
            info.effects         = effects;
            info.fLayerDepth     = fLayer;
            info.blendMode       = blend;
            LIST_DRAW.Add(info);
        }
Exemplo n.º 38
0
        //* -----------------------------------------------------------------------*
        /// <summary>描画処理を予約します。</summary>
        ///
        /// <param name="spriteFont">スプライトフォント テクスチャ</param>
        /// <param name="text">描画したいテキスト</param>
        /// <param name="pos">座標</param>
        /// <param name="color">色</param>
        /// <param name="fRotate">回転(ラジアン)</param>
        /// <param name="origin">原点座標</param>
        /// <param name="scale">拡大率</param>
        /// <param name="effects">反転効果</param>
        /// <param name="fLayer">レイヤ番号</param>
        /// <param name="blend">合成モード</param>
        public void add(
            SpriteFont spriteFont, string text, Vector2 pos, Color color, float fRotate,
            Vector2 origin, Vector2 scale, SpriteEffects effects, float fLayer,
            SpriteBlendMode blend
            )
        {
            SSpriteDrawInfo info = new SSpriteDrawInfo();

            info.initialize();
            info.spriteFont  = spriteFont;
            info.text        = text;
            info.position    = resolution.convertPosition(pos);
            info.color       = color;
            info.fRotation   = fRotate + resolution.rotate;
            info.origin      = origin;
            info.blendMode   = blend;
            info.scale       = scale * resolution.scale;
            info.effects     = effects;
            info.fLayerDepth = fLayer;
            _private.drawCache.Add(info);
        }
Exemplo n.º 39
0
        public Particle(SpriteGrid spriteGrid, float framerate, Vector2 position, Vector2 velocity, Vector2 gravity, float damping, Color color, SpriteBlendMode blend, Room.Layer layer, float scale, int timeToLive)
        {
            this.spriteGrid = spriteGrid;
            this.framerate = framerate;
            this.position = position;
            this.velocity = velocity;
            this.gravity = gravity;
            this.damping = damping;
            this.color = color;
            this.blend = blend;
            this.layer = layer;
            this.timeToLive = timeToLive;

            CleanUpOnRoomLeft = true;

            Width = (int)(scale * spriteGrid.FrameSize.X);
            Height = (int)(scale * spriteGrid.FrameSize.Y);

            this.position.X -= Width / 2.0f;
            this.position.Y -= Height / 2.0f;

            X = (int)this.position.X;
            Y = (int)this.position.Y;
        }
Exemplo n.º 40
0
        /// <summary>
        /// Draws the sprites on the screen.
        /// </summary>
        /// <param name="batch">Sprite batch to use for rendering</param>
        /// <param name="blendMode"></param>
        public void Draw(SpriteBatch batch, SpriteBlendMode blendMode)
        {
            // Draw the enemy sprites on the screen
            for (int i = 0; i < BattleEngine.EnemyCount; i++)
            {
                // TODO:  Draw actual enemy sprites and modify default positions
                // If the enemy is dead, don't draw it or draw the death sprite for enemy
                if (BattleEngine.IsEnemyAlive(i))
                {
                    //spriteBatch.Draw(blueBox, new Vector2(enemyPositions[i, 0], enemyPositions[i, 1]), Color.White);
                    BattleEngine.EnemyPartyList[i].Draw(batch, Color.White, SpriteBlendMode.None);
                }
            }

            // Draw the player sprites on the screen
            for (int i = 0; i < BattleEngine.PartyCount; i++)
            {
                BattleEngine.PlayerPartyList[i].Draw(batch, Color.White, SpriteBlendMode.None);
            }

            // Draw the selection arrow if the player is currently selecting a target
            if (selectingTarget)
            {
                batch.Begin();

                // DEBUG:  For now, draw the dummy arrow by the enemy
                batch.Draw(arrow,
                     new Vector2(BattleEngine.EnemyPartyList[currentTarget].Position.X - 10,
                                 BattleEngine.EnemyPartyList[currentTarget].Position.Y + 20),
                     Color.White);

                batch.End();
            }

            // Draw battle text
            for (int i = 0; i < ChronoConstants.cMaxPartyMembers; i++)
                battleTextList[i].Draw(batch, Fonts.BattleFont);
        }
Exemplo n.º 41
0
 /// <summary>
 /// 在逻辑坐标中绘制一个填充的矩形
 /// </summary>
 /// <param name="rect">要填充的矩形</param>
 /// <param name="color">颜色</param>
 /// <param name="layerDepth">深度,0表示最表层,1表示最深层</param>
 /// <param name="blenMode">混合模式</param>
 public void FillRectangle ( Rectangle rect, Color color, float layerDepth, SpriteBlendMode blenMode )
 {
     Vector2 scrnPos = engine.CoordinMgr.ScreenPos( new Vector2( rect.X, rect.Y ) );
     Rectangle destinRect = new Rectangle( (int)scrnPos.X, (int)scrnPos.Y, engine.CoordinMgr.ScrnLength( rect.Width ), engine.CoordinMgr.ScrnLength( rect.Height ) );
     if (blenMode == SpriteBlendMode.Additive)
         engine.SpriteMgr.additiveSprite.Draw( retangleTexture, destinRect, null, color, -engine.CoordinMgr.Rota, Vector2.Zero, SpriteEffects.None, layerDepth );
     else
         engine.SpriteMgr.alphaSprite.Draw( retangleTexture, destinRect, null, color, -engine.CoordinMgr.Rota, Vector2.Zero, SpriteEffects.None, layerDepth );
 }
Exemplo n.º 42
0
 /// <summary>
 /// 在屏幕坐标中绘制矩形
 /// </summary>
 /// <param name="rect">要绘制的矩形</param>
 /// <param name="borderWidth">矩形的边线的宽度,以像素为单位</param>
 /// <param name="color">颜色</param>
 /// <param name="layerDepth">深度,0表示最表层,1表示最深层</param>
 /// <param name="blendMode">混合模式</param>
 public void DrawRectangleInScrn ( Rectangle rect, float borderWidth, Color color, float layerDepth, SpriteBlendMode blendMode )
 {
     DrawLineInScrn( new Vector2( rect.Left, rect.Top ), new Vector2( rect.Right, rect.Top ), borderWidth, color, layerDepth, blendMode );
     DrawLineInScrn( new Vector2( rect.Left, rect.Top ), new Vector2( rect.Left, rect.Bottom ), borderWidth, color, layerDepth, blendMode );
     DrawLineInScrn( new Vector2( rect.Right, rect.Top ), new Vector2( rect.Right, rect.Bottom ), borderWidth, color, layerDepth, blendMode );
     DrawLineInScrn( new Vector2( rect.Left, rect.Bottom ), new Vector2( rect.Right, rect.Bottom ), borderWidth, color, layerDepth, blendMode );
 }
Exemplo n.º 43
0
            /// <summary>
            /// Create sprite to render
            /// </summary>
            /// <param name="setTex">Set tex</param>
            /// <param name="setRect">Set rectangle</param>
            /// <param name="setPixelRect">Set pixel rectangle</param>
            /// <param name="setColor">Set color</param>
            /// <param name="alphaMode">Alpha mode</param>
            public SpriteToRender(Texture setTex, Rectangle setRect,
				Rectangle setPixelRect, Color setColor,
				SpriteBlendMode setBlendMode)
            {
                texture = setTex;
                rect = setRect;
                pixelRect = setPixelRect;
                color = setColor;
                blendMode = setBlendMode;
            }
Exemplo n.º 44
0
 public void Begin(SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode)
 {
     Begin(blendMode, sortMode, stateMode, Local.Matrix.Identity);
 }
Exemplo n.º 45
0
 public void Begin(SpriteBlendMode blendMode)
 {
     // GG EDIT
     Begin(SpriteSortMode.Deferred, BlendState.FromSpriteBlendMode(blendMode), SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity);
 }
Exemplo n.º 46
0
 /// <summary>
 /// 设置绘制参数
 /// </summary>
 /// <param name="origin">贴图的中心,以贴图坐标表示</param>
 /// <param name="pos">逻辑位置</param>
 /// <param name="scale">逻辑大小/原图大小</param>
 /// <param name="rata">方位角</param>
 /// <param name="color">绘制颜色</param>
 /// <param name="layerDepth">绘制深度</param>
 /// <param name="blendMode">混合模式</param>
 public void SetParameters( Vector2 origin, Vector2 pos, float scale, float rata, Color color, float layerDepth, SpriteBlendMode blendMode )
 {
     SetParameters( origin, pos, (float)(cellWidth) * scale, (float)(cellHeight) * scale, rata, color, layerDepth, blendMode );
 }
Exemplo n.º 47
0
 /// <summary>
 /// Draws the character on the screen
 /// </summary>
 /// <param name="batch">Batch to use for drawing</param>
 /// <param name="color">Color tint of the character.  White is normal</param>
 /// <param name="blendMode">Any blendined required</param>
 public void Draw(SpriteBatch batch, Color color, SpriteBlendMode blendMode)
 {
     // Passes it on to the internal sprite class for drawing
     sprite.Draw(batch, color, blendMode, position);
 }
Exemplo n.º 48
0
 public virtual void Begin(GraphicsDevice device, SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode, Local.Matrix transformMatrix)
 {
     this.sortMode = sortMode;
     this.blendMode = blendMode;
     ResetCommands();
 }
        public void Begin(GraphicsDevice device, SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode, Local.Matrix transformMatrix)
        {
			_transformMatrix = transformMatrix;
			this.blendMode = blendMode;
        }
Exemplo n.º 50
0
        /// <summary>
        /// Draw the sprite onto the screen
        /// </summary>
        /// <param name="batch">Sprite Batch used for drawing</param>
        /// <param name="color">Any color tinting, White if none</param>
        /// <param name="blendMode">Type of blending to use when drawing</param>
        /// <param name="position">Where to draw the sprite</param>
        public void Draw(SpriteBatch batch, Color color, SpriteBlendMode blendMode, Vector2 position)
        {
            SpriteEffects effect = SpriteEffects.None;

            // Checks to see what to draw depending on where the character is
            if (inBattle)
            {
                batch.Begin(blendMode, SpriteSortMode.BackToFront, SaveStateMode.None);

                // NOTE: For right now, just draw the texture for battles
                batch.Draw(characterTexture, position, new Rectangle(0, 0, characterTexture.Width, characterTexture.Height),
                    color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                batch.End();
            }
            else // Overworld sprites
            {
                // TODO:  Need a safety check when accessing the dictionary since the string
                // may be invalid.
                AnimatedSprite sprite = worldSprites[worldType];
                sprite.Position = position;

                // If the sprite is mirrored, set the effect to reflect it
                if (isMirrored)
                    effect = SpriteEffects.FlipHorizontally;

                sprite.Draw(batch, color, blendMode, effect);
            }
        }
Exemplo n.º 51
0
 protected void InitializeConstants()
 {
     //DrawOrder = AdditiveDrawOrder;
     spriteBlendMode = SpriteBlendMode.AlphaBlend;
 }
Exemplo n.º 52
0
 public void Begin(SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode, Local.Matrix transformMatrix)
 {
     //TODO: Full XNA Library throws an exception if Begin is called before calling End of the previous session.
     _renderer = GetRenderer();
     _renderer.Begin(_graphicsDevice, blendMode, sortMode, stateMode, transformMatrix);
 }
Exemplo n.º 53
0
 /// <summary>
 /// 在逻辑坐标中绘制一条直线
 /// </summary>
 /// <param name="startPoint">直线的起始点</param>
 /// <param name="endPoint">直线的终点</param>
 /// <param name="width">直线的宽度,以像素为单位</param>
 /// <param name="color">颜色</param>
 /// <param name="layerDepth">深度,0表示最表层,1表示最深层</param>
 /// <param name="blendMode">混合模式</param>
 public void DrawLine ( Vector2 startPoint, Vector2 endPoint, float width, Color color, float layerDepth, SpriteBlendMode blendMode )
 {
     float lengthPix = engine.CoordinMgr.ScrnLength( Vector2.Distance( startPoint, endPoint ) );
     Vector2 midPoint = engine.CoordinMgr.ScreenPos( new Vector2( 0.5f * (startPoint.X + endPoint.X), 0.5f * (startPoint.Y + endPoint.Y) ) );
     float rota = (float)Math.Atan( (double)engine.CoordinMgr.ScrnLengthf( startPoint.Y - endPoint.Y ) / (double)engine.CoordinMgr.ScrnLengthf( startPoint.X - endPoint.X ) );
     if (blendMode == SpriteBlendMode.Additive)
         engine.SpriteMgr.additiveSprite.Draw( lineTexture, new Rectangle( (int)(midPoint.X), (int)(midPoint.Y), (int)(lengthPix), (int)width ),
             null, color, rota - engine.CoordinMgr.Rota, new Vector2( 64, 8 ), SpriteEffects.None, layerDepth );
     else
         engine.SpriteMgr.alphaSprite.Draw( lineTexture, new Rectangle( (int)(midPoint.X), (int)(midPoint.Y), (int)(lengthPix), (int)width ),
         null, color, rota - engine.CoordinMgr.Rota, new Vector2( 64, 8 ), SpriteEffects.None, layerDepth );
 }
Exemplo n.º 54
0
        public void UIBegin(SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode)
        {
            this._BlendMode = blendMode;
            this._SortMode = sortMode;
            this._SaveStateMode = stateMode;

            this.Begin(blendMode, sortMode, stateMode);
        }
Exemplo n.º 55
0
 /// <summary>
 /// 设置绘制参数
 /// </summary>
 /// <param name="origin">贴图的中心,以贴图坐标表示</param>
 /// <param name="pos">逻辑位置</param>
 /// <param name="width">逻辑宽度</param>
 /// <param name="height">逻辑高度</param>
 /// <param name="rata">方位角</param>
 /// <param name="color">绘制颜色</param>
 /// <param name="layerDepth">绘制深度</param>
 /// <param name="blendMode">混合模式</param>
 public void SetParameters( Vector2 origin, Vector2 pos, float width, float height, float rata, Color color, float layerDepth, SpriteBlendMode blendMode )
 {
     Origin = origin;
     this.pos = pos;
     Width = width;
     Height = height;
     Rata = rata;
     Color = color;
     LayerDepth = layerDepth;
     BlendMode = blendMode;
 }
Exemplo n.º 56
0
        /// <summary>
        /// Render on screen
        /// </summary>
        /// <param name="rect">Rectangle</param>
        /// <param name="pixelRect">Pixel rectangle</param>
        /// <param name="color">Color</param>
        /// <param name="blendMode">Blend mode</param>
        public void RenderOnScreen(Rectangle rect, Rectangle pixelRect,
			Color color, SpriteBlendMode blendMode)
        {
            SpriteHelper.AddSpriteToRender(this, rect, pixelRect, color, blendMode);
        }
Exemplo n.º 57
0
 // GG EDIT added
 public static BlendState FromSpriteBlendMode(SpriteBlendMode mode)
 {
     switch (mode) {
         case SpriteBlendMode.Additive:
             return Additive;
         case SpriteBlendMode.AlphaBlend:
             return AlphaBlend;
         case SpriteBlendMode.None:
             return Opaque;
         case SpriteBlendMode.PreMultiplied:
             return NonPremultiplied; // ??? probably wrong?
     }
     return Opaque;
 }
Exemplo n.º 58
0
        /// <summary>
        /// Add sprite to render
        /// </summary>
        /// <param name="texture">Texture</param>
        /// <param name="rect">Rectangle</param>
        /// <param name="gfxRect">Gfx rectangle</param>
        public static void AddSpriteToRender(
			Texture texture, Rectangle rect, Rectangle gfxRect, Color color,
			SpriteBlendMode blendMode)
        {
            sprites.Add(
                new SpriteToRender(texture, rect, gfxRect, color, blendMode));
        }
Exemplo n.º 59
0
 public void Begin(SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode saveStateMode)
 {
     // GG EDIT
     // GG TODO implement saveStateMode
     Begin(sortMode, BlendState.FromSpriteBlendMode(blendMode), SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity);
 }
Exemplo n.º 60
0
 public void Begin(SpriteBlendMode blendMode)
 {
     Begin(blendMode, SpriteSortMode.Deferred, SaveStateMode.None, Local.Matrix.Identity);
 }