Ejemplo n.º 1
0
        /// <summary>
        /// Loads the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TileSetForm_Load(object sender, EventArgs e)
        {
            GLTileControl.MakeCurrent();
            Display.RenderState.Blending = true;
            Display.BlendingFunction(BlendingFactorSource.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GLTextureControl.MakeCurrent();
            Display.RenderState.Blending = true;
            Display.BlendingFunction(BlendingFactorSource.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);


            Batch = new SpriteBatch();

            CheckerBoard = new Texture2D(ResourceManager.GetInternalResource("ArcEngine.Resources.checkerboard.png"));
            CheckerBoard.HorizontalWrap = TextureWrapFilter.Repeat;
            CheckerBoard.VerticalWrap   = TextureWrapFilter.Repeat;

            TileSet.Load(Node);

            TextureNameBox.Text = TileSet.TextureName;

            BMFont = BitmapFont.CreateFromTTF(@"c:\windows\fonts\verdana.ttf", 12, FontStyle.Bold);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Timer Tick
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void RenderTimer_Tick(object sender, EventArgs e)
 {
     GLTextureControl.Invalidate();
     GLTileControl.Invalidate();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// OnPaint event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GLTileControl_Paint(object sender, PaintEventArgs e)
        {
            GLTileControl.MakeCurrent();
            Display.ClearBuffers();


            Batch.Begin();


            // Background texture
            Rectangle dst = new Rectangle(Point.Empty, GLTileControl.Size);

            Batch.Draw(CheckerBoard, dst, dst, Color.White);


            // No tiles, no draw !
            if (CurrentTile != null)
            {
                // Get zoom value
                float zoomvalue = float.Parse((string)ZoomBox.SelectedItem);

                // Draw the tile
                Vector4 zoom = new Vector4();
                zoom.X = TileOffset.X;
                zoom.Y = TileOffset.Y;
                zoom.Z = CurrentTile.Rectangle.Width * zoomvalue;
                zoom.W = CurrentTile.Rectangle.Height * zoomvalue;

                // Texture source
                Vector4 src = new Vector4(
                    CurrentTile.Rectangle.X, CurrentTile.Rectangle.Y,
                    CurrentTile.Size.Width, CurrentTile.Size.Height);

                Batch.Draw(TileSet.Texture, zoom, src, Color.White);


                // Draw Collision box
                if (CollisionSelection != null && ColisionBox.Checked)
                {
                    CollisionSelection.Zoom   = zoomvalue;
                    CollisionSelection.Offset = TileOffset;
                    CurrentTile.CollisionBox  = CollisionSelection.Rectangle;
                    CollisionSelection.Draw(Batch);
                }

                // Draw origin
                if (HotSpotBox.Checked)
                {
                    Point pos = Point.Empty;
                    pos.X = (int)(CurrentTile.Pivot.X * zoomvalue + TileOffset.X);
                    pos.Y = (int)(CurrentTile.Pivot.Y * zoomvalue + TileOffset.Y);

                    Rectangle rect = new Rectangle(pos, new Size((int)zoomvalue, (int)zoomvalue));
                    Batch.FillRectangle(rect, Color.Red);
                }
            }


            Batch.End();
            GLTileControl.SwapBuffers();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// OnResize event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GLTileControl_Resize(object sender, EventArgs e)
 {
     GLTileControl.MakeCurrent();
     Display.ViewPort = new Rectangle(Point.Empty, GLTileControl.Size);
 }