コード例 #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Gorgon.Run(new Form1());
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tmp7701/Gorgon
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Initialize our example.
                Initialize();

                // Start it running.
                Gorgon.Run(_formMain, Idle);
            }
            catch (Exception ex)
            {
                GorgonException.Catch(ex, () => GorgonDialogs.ErrorBox(null, ex));
            }
            finally
            {
                // Perform clean up.
                if (_renderer != null)
                {
                    _renderer.Dispose();
                }

                if (_graphics != null)
                {
                    _graphics.Dispose();
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: tmp7701/Gorgon
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                // Initialize the application.
                Initialize();

                // Now begin running the application idle loop.
                Gorgon.Run(_mainForm, Idle);
            }
            catch (Exception ex)
            {
                GorgonException.Catch(ex, () => GorgonDialogs.ErrorBox(null, ex));
            }
            finally
            {
                if (Graphics != null)
                {
                    Graphics.Dispose();
                }
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: tmp7701/Gorgon
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                Initialize();
                Gorgon.Run(_mainForm, Idle);
            }
            catch (Exception ex)
            {
                GorgonException.Catch(ex, () => GorgonDialogs.ErrorBox(null, ex));
            }
            finally
            {
                if (_wvpBufferStream != null)
                {
                    _wvpBufferStream.Dispose();
                }

                if (Graphics != null)
                {
                    Graphics.Dispose();
                }
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: tmp7701/Gorgon
		static void Main()
		{
			try
			{
				Application.EnableVisualStyles();
				Application.SetCompatibleTextRenderingDefault(false);

				_form = new formMain
				    {
				        ClientSize = new Size(640, 480)
				    };

			    // Get the initial time.
				_lastTime = GorgonTiming.MillisecondsSinceStart;

				// Run the application with an idle loop.
				//
				// The form will still control the life time of the application (i.e. the close button will end the application). 
				// However, you may specify only the idle method and use that to control the application life time, similar to 
				// standard windows application in C++.
				// Other overloads allow using only the form and assigning the idle method at another time (if at all), or setting
				// up an application context object to manage the life time of the application (with or without an idle loop 
				// method).
				Gorgon.Run(_form, Idle);
			}
			catch (Exception ex)
			{
				// Catch all exceptions here.  If we had logging for the application enabled, then this 
				// would record the exception in the log.
				GorgonException.Catch(ex, () => GorgonDialogs.ErrorBox(null, ex));
			}
		}
コード例 #6
0
ファイル: Text.cs プロジェクト: tmp7701/Gorgon
        public void TestText()
        {
            _form.Show();
            _form.ClientSize = new Size(1280, 800);
            _form.Location   = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - 640, Screen.PrimaryScreen.WorkingArea.Height / 2 - 400);
            _form.BringToFront();
            _form.WindowState = FormWindowState.Minimized;
            _form.WindowState = FormWindowState.Normal;

            GorgonText text = _renderer.Renderables.CreateText("Test",
                                                               _graphics.Fonts.DefaultFont,
                                                               "The quick brown fox jumps over the lazy dog.\n1234567890 !@#$%^&*() ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz");

            Gorgon.Run(_form, () =>
            {
                _renderer.Clear(Color.Black);

                text.Draw();

                _renderer.Render();

                return(true);
            });

            Assert.IsTrue(_form.TestResult == DialogResult.Yes);
        }
コード例 #7
0
ファイル: GraphicsFramework.cs プロジェクト: tmp7701/Gorgon
        /// <summary>
        /// Function to run the test.
        /// </summary>
        /// <returns>The test result for manual testing.</returns>
        public DialogResult Run()
        {
            _form.WindowState = FormWindowState.Minimized;
            _form.Show();
            _form.WindowState = FormWindowState.Normal;

            //_form.TopMost = true;

            Gorgon.Run(_form, Idle);

            return(_form.TestResult);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: tmp7701/Gorgon
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Settings.Load();

                Gorgon.PlugIns.AssemblyResolver = (appDomain, e) => appDomain.GetAssemblies()
                                                  .FirstOrDefault(assembly => assembly.FullName == e.Name);

                Gorgon.Run(new AppContext());
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(null, ex);
            }
            finally
            {
                Gorgon.PlugIns.AssemblyResolver = null;

                ContentManagement.UnloadCurrentContent();

                // Clean up the plug-ins.
                foreach (var plugInItem in PlugIns.ContentPlugIns)
                {
                    plugInItem.Value.Dispose();
                }

                foreach (var plugInItem in PlugIns.WriterPlugIns)
                {
                    plugInItem.Value.Dispose();
                }

                // Shut down the graphics interface.
                if (ContentObject.Graphics != null)
                {
                    ContentObject.Graphics.Dispose();
                    ContentObject.Graphics = null;
                }

                // Clean up temporary files in scratch area.
                if (Settings != null)
                {
                    ScratchArea.DestroyScratchArea();
                }

                EditorLogging.Close();
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: tmp7701/Gorgon
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Gorgon.Run(new FormMain());
            }
            catch (Exception ex)
            {
                GorgonDialogs.ErrorBox(null, ex);
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: tmp7701/Gorgon
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Initialize();

                Gorgon.Run(_form, Idle);
            }
            catch (Exception ex)
            {
                GorgonException.Catch(ex, () => GorgonDialogs.ErrorBox(null, ex));
            }
            finally
            {
                CleanUp();
            }
        }
コード例 #11
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Get the initial time.
                _lastTime = GorgonTiming.MillisecondsSinceStart;

                // Run the application context with an idle loop.
                //
                // Here we specify that we want to run an application context and an idle loop.  The idle loop
                // will kick in after the main form displays.
                Gorgon.Run(new Context(), Idle);
            }
            catch (Exception ex)
            {
                // Catch all exceptions here.  If we had logging for the application enabled, then this
                // would record the exception in the log.
                GorgonException.Catch(ex, () => GorgonDialogs.ErrorBox(null, ex));
            }
        }
コード例 #12
0
ファイル: Primitives.cs プロジェクト: tmp7701/Gorgon
        public void TestEllipse()
        {
            _form.Show();
            _form.ClientSize = new Size(1280, 800);
            _form.Location   = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - 640, Screen.PrimaryScreen.WorkingArea.Height / 2 - 400);
            _form.BringToFront();
            _form.WindowState = FormWindowState.Minimized;
            _form.WindowState = FormWindowState.Normal;

            GorgonEllipse ellipse = _renderer.Renderables.CreateEllipse("Test",
                                                                        new Vector2(320, 400),
                                                                        new Vector2(100, 100),
                                                                        Color.Blue,
                                                                        true,
                                                                        32);

            Gorgon.Run(_form, () =>
            {
                _renderer.Clear(Color.Black);

                ellipse.Color    = Color.Blue;
                ellipse.IsFilled = true;
                ellipse.Position = new Vector2(480, 400);
                ellipse.Draw();

                ellipse.Color    = Color.Green;
                ellipse.IsFilled = false;
                ellipse.Position = new Vector2(800, 400);
                ellipse.Draw();

                _renderer.Render();

                return(true);
            });

            Assert.IsTrue(_form.TestResult == DialogResult.Yes);
        }
コード例 #13
0
        public void BouncyBalls3D()
        {
            Gorgon.Run(_form, () =>
            {
                _swap.Clear(Color.Black);
                for (int i = 0; i < Count; i++)
                {
                    _balls[i].Angle += _balls[i].AngleDelta * GorgonTiming.Delta;

                    if (_balls[i].Angle > 360.0f)
                    {
                        _balls[i].Angle      = _balls[i].Angle - 360.0f;
                        _balls[i].AngleDelta = GorgonRandom.RandomSingle() * 90.0f;
                    }

                    if ((_balls[i].ScaleBouce) || (!_balls[i].ZBounce))
                    {
                        _balls[i].Color.W -= _balls[i].Velocity.Z * GorgonTiming.Delta;
                    }
                    else
                    {
                        _balls[i].Color.W += _balls[i].Velocity.Z * GorgonTiming.Delta;
                    }

                    if (_balls[i].Color.W > 1.0f)
                    {
                        _balls[i].Color.W = 1.0f;
                    }

                    if (_balls[i].Color.W < 0.0f)
                    {
                        _balls[i].Color.W = 0.0f;
                        _balls[i].Color   = new Vector4((GorgonRandom.RandomSingle() * 0.961f) + 0.039f,
                                                        (GorgonRandom.RandomSingle() * 0.961f) + 0.039f,
                                                        (GorgonRandom.RandomSingle() * 0.961f) + 0.039f, 0.0f);
                    }

                    if (_balls[i].YBounce)
                    {
                        _balls[i].Position.Y -= (_balls[i].Velocity.Y * GorgonTiming.Delta);
                    }
                    else
                    {
                        _balls[i].Position.Y += (_balls[i].Velocity.Y * GorgonTiming.Delta);
                    }

                    if (_balls[i].XBounce)
                    {
                        _balls[i].Position.X -= (_balls[i].Velocity.X * GorgonTiming.Delta);
                    }
                    else
                    {
                        _balls[i].Position.X += (_balls[i].Velocity.X * GorgonTiming.Delta);
                    }
                    if (_balls[i].ZBounce)
                    {
                        _balls[i].Position.Z -= (_balls[i].Velocity.Z * GorgonTiming.Delta);
                    }
                    else
                    {
                        _balls[i].Position.Z += (_balls[i].Velocity.Z * GorgonTiming.Delta);
                    }

                    if (_balls[i].Position.X > (1.0f * _aspect))
                    {
                        _balls[i].Position.X = (1.0f * _aspect);
                        _balls[i].Velocity.X = (GorgonRandom.RandomSingle() * 0.5f);
                        _balls[i].XBounce    = !_balls[i].XBounce;
                    }
                    if (_balls[i].Position.Y > (1.0f * _aspect))
                    {
                        _balls[i].Position.Y = (1.0f * _aspect);
                        _balls[i].Velocity.Y = (GorgonRandom.RandomSingle() * 0.5f);
                        _balls[i].YBounce    = !_balls[i].YBounce;
                    }

                    if (_balls[i].Position.X < (-1.0f * _aspect))
                    {
                        _balls[i].Position.X = (-1.0f * _aspect);
                        _balls[i].Velocity.X = GorgonRandom.RandomSingle() * 0.5f;
                        _balls[i].XBounce    = !_balls[i].XBounce;
                    }
                    if (_balls[i].Position.Y < (-1.0f * _aspect))
                    {
                        _balls[i].Position.Y = (-1.0f * _aspect);
                        _balls[i].Velocity.Y = GorgonRandom.RandomSingle() * 0.5f;
                        _balls[i].YBounce    = !_balls[i].YBounce;
                    }


                    if (_balls[i].Position.Z < -1.0f)
                    {
                        _balls[i].Position.Z = -1.0f;
                        _balls[i].Velocity.Z = GorgonRandom.RandomSingle() * 0.5f;
                        _balls[i].ZBounce    = !_balls[i].ZBounce;
                    }

                    if (!(_balls[i].Position.Z > 1.0f))
                    {
                        continue;
                    }

                    _balls[i].Position.Z = 1.0f;
                    _balls[i].Velocity.Z = GorgonRandom.RandomSingle() * 0.5f;
                    _balls[i].ZBounce    = !_balls[i].ZBounce;
                }

                var sortPos = _balls.OrderByDescending(item => item.Position.Z).ToArray();

                for (int i = 0; i < Count * 4; i += 4)
                {
                    int arrayindex = i / 4;

                    Matrix world;
                    if (_3d)
                    {
                        Quaternion rot = Quaternion.RotationYawPitchRoll(sortPos[arrayindex].Angle.Cos(), -sortPos[arrayindex].Angle.Sin() * 2.0f, -sortPos[arrayindex].Angle);
                        Matrix.RotationQuaternion(ref rot, out world);
                    }
                    else
                    {
                        world = Matrix.RotationZ(-sortPos[arrayindex].Angle);
                    }
                    world = world * (Matrix.Scaling(sortPos[arrayindex].Scale, sortPos[arrayindex].Scale, 1.0f)) *
                            Matrix.Translation(sortPos[arrayindex].Position.X, sortPos[arrayindex].Position.Y,
                                               sortPos[arrayindex].Position.Z);
                    Matrix trans;
                    Matrix.Multiply(ref world, ref pvw, out trans);

                    _sprite[i].Color = new GorgonColor(sortPos[arrayindex].Color);

                    _sprite[i + 1].Color = _sprite[i].Color;
                    _sprite[i + 2].Color = _sprite[i].Color;
                    _sprite[i + 3].Color = _sprite[i].Color;

                    _sprite[i].Position     = Vector3.Transform(new Vector3(-0.1401f, 0.1401f, 0.0f), trans);
                    _sprite[i + 1].Position = Vector3.Transform(new Vector3(0.1401f, 0.1401f, 0.0f), trans);
                    _sprite[i + 2].Position = Vector3.Transform(new Vector3(-0.1401f, -0.1401f, 0.0f), trans);
                    _sprite[i + 3].Position = Vector3.Transform(new Vector3(0.1401f, -0.1401f, 0.0f), trans);

                    if (sortPos[arrayindex].Checkered)
                    {
                        _sprite[i].UV     = new Vector2(0.503f, 0.0f);
                        _sprite[i + 1].UV = new Vector2(1.0f, 0.0f);
                        _sprite[i + 2].UV = new Vector2(0.503f, 0.5f);
                        _sprite[i + 3].UV = new Vector2(1.0f, 0.5f);
                    }
                    else
                    {
                        _sprite[i].UV     = new Vector2(0.0f, 0.503f);
                        _sprite[i + 1].UV = new Vector2(0.5f, 0.503f);
                        _sprite[i + 2].UV = new Vector2(0.0f, 1.0f);
                        _sprite[i + 3].UV = new Vector2(0.5f, 1.0f);
                    }
                }

                using (GorgonDataStream vstream = _vertices.Lock(BufferLockFlags.Write | BufferLockFlags.Discard))
                {
                    vstream.WriteRange(_sprite);
                    _vertices.Unlock();
                }

                _graphics.Output.DrawIndexed(0, 0, 6 * Count);

                _swap.Flip();

                _form.Text = string.Format("FPS: {0:0.0}  DT: {1:0.000}ms", GorgonTiming.FPS, GorgonTiming.Delta * 1000);

                return(true);
            });

            Assert.IsTrue(_form.TestResult == DialogResult.Yes);
        }
コード例 #14
0
ファイル: PerspectiveTest.cs プロジェクト: tmp7701/Gorgon
        public void TestOrthoCamera()
        {
            _form.Show();
            _form.ClientSize = new Size(1280, 800);
            _form.Location   = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - 640, Screen.PrimaryScreen.WorkingArea.Height / 2 - 400);
            _form.BringToFront();
            _form.WindowState = FormWindowState.Minimized;
            _form.WindowState = FormWindowState.Normal;

            var camera = _renderer.CreateCamera <Gorgon2DOrthoCamera>("TestCam",
                                                                      new RectangleF(Vector2.Zero, _form.ClientSize),
                                                                      0.0f,
                                                                      1.0f);

            var camera2 = _renderer.CreateCamera <Gorgon2DPerspectiveCamera>("TestCam2",
                                                                             new RectangleF(-1, -1, 2, 2),
                                                                             0.01f,
                                                                             100.0f);

            using (var texture = _graphics.Textures.FromFile <GorgonTexture2D>("Test", @"..\..\..\..\Resources\Images\Ship.png", new GorgonCodecPNG()))
            {
                //camera.ViewDimensions = new RectangleF(0, 0, 1, 1);
                camera.ViewDimensions = new RectangleF(-1, -1, 2, 2);

                /*camera.ViewDimensions = new RectangleF(
                 *      new Vector2(_screen.Settings.Width / -2.0f, _screen.Settings.Height / -2.0f),
                 *      new Vector2(_screen.Settings.Width / 2.0f, _screen.Settings.Height / 2.0f));*/
                //camera.Anchor = new Vector2(0.5f, 0.5f);
                //camera.Zoom = new Vector2(2);
                //camera.Anchor = new Vector2(640, 400);
                //camera.Angle = 45.0f;

                var size = new Vector2(texture.Settings.Width * (camera.ViewDimensions.Width / _screen.Settings.Width),
                                       texture.Settings.Height * (camera.ViewDimensions.Height / _screen.Settings.Height));

                //size = size * 4.0f;

                var sprite = _renderer.Renderables.CreateSprite("Test",
                                                                new GorgonSpriteSettings
                {
                    Texture       = texture,
                    Size          = size,
                    TextureRegion =
                        new RectangleF(Vector2.Zero,
                                       texture.ToTexel(texture.Settings.Width, texture.Settings.Height))
                });

                _renderer.Camera = camera;

                sprite.Depth = 0.0f;

                sprite.Position = (Vector2)camera.Project(new Vector2(320, 200));

                Gorgon.Run(_form, () =>
                {
                    var projectedSpace       = -(Vector2)camera.Project(new Vector3(_form.PointToClient(Cursor.Position), 0), false);
                    var projectedViewSpace   = (Vector2)camera.Project(new Vector2(320, 200));
                    var unprojectedSpace     = (Vector2)camera.Unproject(projectedSpace, false);
                    var unprojectedViewSpace = (Vector2)camera.Unproject(projectedViewSpace);

                    _renderer.Clear(Color.Black);

                    _renderer.Camera = camera;

                    sprite.Draw();

                    //Vector2 projectedSpace = camera.Project(new Vector2(320, 200));

                    camera.Position = projectedSpace;
                    camera2.Draw();
                    camera.Draw();

                    _renderer.DefaultCamera.Draw();

                    _renderer.Camera = null;
                    _renderer.Drawing.DrawEllipse(new RectangleF(310, 190, 20, 20), Color.Firebrick, 64, new Vector2(1));
                    _renderer.Drawing.DrawString(_graphics.Fonts.DefaultFont,
                                                 string.Format("X:{0:0.00}, Y:{1:0.00}\nU:{2:0.00}, V:{3:0.00}\nI:{4:0.00}, J:{5:0.00}\nK:{8:0.00}, L:{9:00}\nSize X:{6:0.00}, Size Y:{7:0.00}", projectedSpace.X, projectedSpace.Y, unprojectedSpace.X, unprojectedSpace.Y, projectedViewSpace.X, projectedViewSpace.Y, size.X, size.Y, unprojectedViewSpace.X, unprojectedViewSpace.Y),
                                                 Vector2.Zero,
                                                 Color.Yellow);


                    _renderer.Render();

                    return(true);
                });

                Assert.IsTrue(_form.TestResult == DialogResult.Yes);
            }
        }
コード例 #15
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                Initialize();

                Gorgon.Run(_form, Idle);
            }
            catch (Exception ex)
            {
                GorgonException.Catch(ex, () => GorgonDialogs.ErrorBox(null, ex));
            }
            finally
            {
                if (_materialBuffer != null)
                {
                    _materialBuffer.Dispose();
                }

                if (_normalEarfMap != null)
                {
                    _normalEarfMap.Dispose();
                }

                if (_normalMap != null)
                {
                    _normalMap.Dispose();
                }

                if (_specEarfMap != null)
                {
                    _specEarfMap.Dispose();
                }

                if (_specMap != null)
                {
                    _specMap.Dispose();
                }

                if (_cloudMap != null)
                {
                    _cloudMap.Dispose();
                }

                if (_clouds != null)
                {
                    _clouds.Dispose();
                }

                if (_sphere != null)
                {
                    _sphere.Dispose();
                }

                if (_light != null)
                {
                    _light.Dispose();
                }

                if (_cube != null)
                {
                    _cube.Dispose();
                }

                if (_plane != null)
                {
                    _plane.Dispose();
                }

                if (_triangle != null)
                {
                    _triangle.Dispose();
                }

                if (_wvp != null)
                {
                    _wvp.Dispose();
                }

                if (_renderer2D != null)
                {
                    _renderer2D.Dispose();
                }

                if (_swapChain != null)
                {
                    _swapChain.Dispose();
                }

                if (_graphics != null)
                {
                    _graphics.Dispose();
                }
            }
        }
コード例 #16
0
ファイル: PerspectiveTest.cs プロジェクト: tmp7701/Gorgon
        public void TestPerspectiveCamera()
        {
            _form.Show();
            _form.ClientSize = new Size(1280, 800);
            _form.Location   = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - 640, Screen.PrimaryScreen.WorkingArea.Height / 2 - 400);
            _form.BringToFront();
            _form.WindowState = FormWindowState.Minimized;
            _form.WindowState = FormWindowState.Normal;

            var camera = _renderer.CreateCamera <Gorgon2DPerspectiveCamera>("TestCam",
                                                                            new RectangleF(Vector2.Zero, _form.ClientSize),
                                                                            0.01f,
                                                                            1000.0f);

            var camera2 = _renderer.CreateCamera <Gorgon2DPerspectiveCamera>("TestCam2",
                                                                             new RectangleF(-1, -1, 2, 2),
                                                                             0.1f,
                                                                             1.0f);

            using (var texture = _graphics.Textures.FromFile <GorgonTexture2D>("Test", @"..\..\..\..\Resources\Images\Ship.png", new GorgonCodecPNG()))
            {
                //camera.ViewDimensions = new RectangleF(0, 0, 1, 1);
                camera.ViewDimensions = new RectangleF(-1, -1, 2, 2);
                //camera.ViewDimensions = new RectangleF(-640, -400, 1280, 800);

                var size = new Vector2(texture.Settings.Width * (camera.ViewDimensions.Width / _screen.Settings.Width) * 12.80f,
                                       texture.Settings.Height * (camera.ViewDimensions.Height / _screen.Settings.Height) * 12.80f);

                var sprite = _renderer.Renderables.CreateSprite("Test",
                                                                new GorgonSpriteSettings
                {
                    Texture       = texture,
                    Size          = size,
                    TextureRegion =
                        new RectangleF(Vector2.Zero,
                                       texture.ToTexel(texture.Settings.Width, texture.Settings.Height))
                });

                sprite.Anchor = size / 2.0f;


                _renderer.Camera = camera;

                sprite.Depth = 0.0001f;
                //sprite.Position = (Vector2)camera.Project(new Vector3(320, 200, sprite.Depth));

                //camera.Anchor = new Vector2(_screen.Settings.Width / 2.0f, _screen.Settings.Height / 2.0f);
                //_screen.AfterSwapChainResized += (sender, args) => camera.Anchor = new Vector2(_screen.Settings.Width / 2.0f, _screen.Settings.Height / 2.0f);

                _form.MouseWheel += (sender, args) =>
                {
                    sprite.Depth += args.Delta / 32000.0f;
                };


                float camDepth = 0.01f;
                _form.KeyPreview = true;
                _form.Focus();
                _form.KeyPress += (sender, args) =>
                {
                    if (args.KeyChar == 'w')
                    {
                        camDepth -= 12.0f * GorgonTiming.Delta;
                    }

                    if (args.KeyChar == 's')
                    {
                        camDepth += 12.0f * GorgonTiming.Delta;
                    }
                };

                Gorgon.Run(_form, () =>
                {
                    Vector2 cursorPos            = _form.PointToClient(Cursor.Position);
                    Vector3 projectedSpace       = camera.Project(new Vector3(cursorPos, 0), false);
                    Vector3 projectedViewSpace   = camera.Project(new Vector3(320, 200, 0.01f));
                    Vector3 unprojectedSpace     = camera.Unproject(projectedSpace, false);
                    Vector3 unprojectedViewSpace = camera.Unproject(projectedViewSpace);

                    //_renderer.DefaultCamera.Position = cursorPos;

                    _renderer.Clear(Color.Black);

                    projectedSpace.X = -projectedSpace.X;
                    projectedSpace.Y = -projectedSpace.Y;
                    projectedSpace.Z = camDepth;

                    _renderer.Camera = camera;
                    sprite.Draw();

                    camera.Position = projectedSpace;

                    camera2.Draw();
                    camera.Draw();
                    _renderer.DefaultCamera.Draw();

                    _renderer.Camera = null;
                    _renderer.Drawing.DrawEllipse(new RectangleF(310, 190, 20, 20), Color.Firebrick, 64, new Vector2(1));
                    _renderer.Drawing.DrawString(_graphics.Fonts.DefaultFont,
                                                 string.Format("X:{0:0.00}, Y:{1:0.00}\nU:{2:0.00}, V:{3:0.00}\nI:{4:0.00}, J:{5:0.00}\nK:{8:0.00}, L:{9:00}\nSize X:{6:0.00}, Size Y:{7:0.00}, Depth: {10:0.000}",
                                                               projectedSpace.X, projectedSpace.Y, unprojectedSpace.X, unprojectedSpace.Y, projectedViewSpace.X, projectedViewSpace.Y, size.X, size.Y,
                                                               unprojectedViewSpace.X, unprojectedViewSpace.Y, sprite.Depth),
                                                 Vector2.Zero,
                                                 Color.Yellow);

                    _renderer.Render();

                    return(true);
                });

                Assert.IsTrue(_form.TestResult == DialogResult.Yes);
            }
        }
コード例 #17
0
ファイル: Primitives.cs プロジェクト: tmp7701/Gorgon
        public void TestPolygon()
        {
            _form.Show();
            _form.ClientSize = new Size(1280, 800);
            _form.Location   = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - 640, Screen.PrimaryScreen.WorkingArea.Height / 2 - 400);
            _form.BringToFront();
            _form.WindowState = FormWindowState.Minimized;
            _form.WindowState = FormWindowState.Normal;

            GorgonPolygon polygon = _renderer.Renderables.CreatePolygon("Test", new Vector2(320, 240), Color.RosyBrown);

            polygon.SetVertexData(new GorgonPolygonPoint[]
            {
                new GorgonPolygonPoint(new Vector2(0, 20), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(20, 0), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(40, 20), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(10, 40), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(30, 40), GorgonColor.White)
            });

            polygon.SetIndexData(new []
            {
                0, 1, 2,
                2, 3, 0,
                3, 2, 4
            });

            GorgonPolygon polygon2 = _renderer.Renderables.CreatePolygon("Test", new Vector2(320, 240), Color.GreenYellow);

            polygon2.PolygonType = PolygonType.Line;
            polygon2.SetVertexData(new GorgonPolygonPoint[]
            {
                new GorgonPolygonPoint(new Vector2(0, 20), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(20, 0), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(40, 20), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(10, 40), GorgonColor.White),
                new GorgonPolygonPoint(new Vector2(30, 40), GorgonColor.White)
            });

            polygon2.SetIndexData(new[]
            {
                0, 1,
                1, 2,
                2, 4,
                4, 3,
                3, 0
            });

            Gorgon.Run(_form, () =>
            {
                _renderer.Clear(Color.Black);

                polygon.Draw();
                polygon2.Draw();

                _renderer.Render();

                return(true);
            });

            Assert.IsTrue(_form.TestResult == DialogResult.Yes);
        }