/// <summary>
        /// Loads a new 3D model file into the ModelViewerControl.
        /// </summary>
        FyriTexture2d LoadTexture2dToProject(string fileName)
        {
            if (currentProject != null)
            {
                Cursor = Cursors.WaitCursor;

                FyriTexture2d loadedTexture = texture2dManager.LoadTexture2d(fileName);

                if (loadedTexture != null)
                {
                    if (!currentProject.LoadedTexture2ds.Exists(p => p.OriginalFileName == fileName))
                    {
                        currentProject.LoadedTexture2ds.Add(loadedTexture);
                    }

                    //texture2dViewerControl.Texture = loadedTexture.Texture;
                    AddTexture2dToTreeView(loadedTexture);
                }
                Cursor = Cursors.Arrow;

                return(loadedTexture);
            }

            return(null);
        }
Exemple #2
0
        public void LoadContent()
        {
            spriteBatch  = new SpriteBatch(this.GraphicsDevice);
            drawingBatch = new XnaDrawingBatch(this.GraphicsDevice);

            screen = new RenderTarget2D(
                this.GraphicsDevice,
                this.GraphicsDevice.PresentationParameters.BackBufferWidth,
                this.GraphicsDevice.PresentationParameters.BackBufferHeight,
                false,
                this.GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24);

            blank = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            blank.SetData(new[] { Color.White });

            XnaDrawing.blank        = blank;
            XnaDrawing.spriteBatch  = spriteBatch;
            XnaDrawing.drawingBatch = drawingBatch;
            XnaDrawing.defaultFont  = font;

            camera      = new XnaCamera2d(this.GraphicsDevice.Viewport);
            camera.Pos  = new Vector2(400.0f, 300.0f);
            camera.Zoom = 300;

            float rho  = 100;
            bool  blue = false;

            for (float y = -2000; y <= 2000; y += 200)
            {
                for (float x = -1000; x <= 1000; x += 200)
                {
                    blue = !blue;
                    for (float deg = 0; deg < 360; deg += 10)
                    {
                        float theta = MathHelper.ToRadians(deg);
                        float x1    = rho * (float)Math.Cos(theta);
                        float y1    = rho * (float)Math.Sin(theta);

                        if (blue)
                        {
                            blueRoundLines.Add(new RoundLine(x, y, x + x1, y + y1));
                        }
                        else
                        {
                            greenRoundLines.Add(new RoundLine(x, y, x + x1, y + y1));
                        }
                    }
                }
            }

            //Create2DViewMatrix();
            Create2DProjectionMatrix();

            if (textureManager != null)
            {
                cursorTexture = textureManager.LoadTexture2d(@"C:\Users\dovieya\Desktop\XNA 2D Editor\fyri2deditor\Xna2dEditor\Resources\Cursor.png");
            }
        }