Пример #1
0
		public void CanRenderModelWithTextures()
		{
			// Arrange.
			Scene scene = MeshellatorLoader.ImportFromFile("Models/Obj/Tank.obj");
			using (var renderer = new WarpSceneRenderer(scene, 800, 600))
			{
				renderer.Options.TriangleWindingOrderReversed = true;

				Camera camera = new PerspectiveCamera
				{
					FarPlaneDistance = 100000,
					NearPlaneDistance = 1,
					FieldOfView = MathUtility.PI_OVER_4,
					LookDirection = new Vector3D(-1, -0.3f, 1),
					Position = new Point3D(300, 150, -150),
					UpDirection = Vector3D.Up
				};

				// Act.
				var bitmap = renderer.Render(camera);

				// Assert.
				Assert.IsNotNull(bitmap);
				SaveImage(bitmap, "tank.jpg");
			}
		}
Пример #2
0
        public void CanRenderModelWithTextures()
        {
            // Arrange.
            Scene scene = MeshellatorLoader.ImportFromFile("Models/Obj/Tank.obj");

            using (var renderer = new WarpSceneRenderer(scene, 800, 600))
            {
                renderer.Options.TriangleWindingOrderReversed = true;

                Camera camera = new PerspectiveCamera
                {
                    FarPlaneDistance  = 100000,
                    NearPlaneDistance = 1,
                    FieldOfView       = MathUtility.PI_OVER_4,
                    LookDirection     = new Vector3D(-1, -0.3f, 1),
                    Position          = new Point3D(300, 150, -150),
                    UpDirection       = Vector3D.Up
                };

                // Act.
                var bitmap = renderer.Render(camera);

                // Assert.
                Assert.IsNotNull(bitmap);
                SaveImage(bitmap, "tank.jpg");
            }
        }
Пример #3
0
        public void CanRenderModel()
        {
            // Arrange.
            Scene scene = MeshellatorLoader.ImportFromFile("Models/3ds/85-nissan-fairlady.3ds");

            using (var renderer = new WarpSceneRenderer(scene, 800, 600))
            {
                Camera camera = new PerspectiveCamera
                {
                    FarPlaneDistance  = 100000,
                    NearPlaneDistance = 1,
                    FieldOfView       = MathUtility.PI_OVER_4,
                    LookDirection     = new Vector3D(-1, -0.3f, 1),
                    Position          = new Point3D(3000, 1500, -1500),
                    UpDirection       = Vector3D.Up
                };

                // Act.
                var bitmap = renderer.Render(camera);

                // Assert.
                Assert.IsNotNull(bitmap);
                SaveImage(bitmap, "nissan.jpg");
            }
        }
Пример #4
0
        protected override void CreateImage(ImageGenerationContext context)
        {
            Scene scene = Source.GetScene(context);

            using (var renderer = new WarpSceneRenderer(scene, Width, Height))
            {
                renderer.Initialize();

                renderer.Options.TriangleWindingOrderReversed = ReverseWindingOrder;
                renderer.Options.BackgroundColor = new Nexus.Color(BackgroundColour.A, BackgroundColour.R, BackgroundColour.G, BackgroundColour.B);
                renderer.Options.LightingEnabled = LightingEnabled;

                Viewport viewport = new Viewport(0, 0, Width, Height);
                Nexus.Graphics.Cameras.Camera camera = (Camera != null)
                                        ? Camera.GetNexusCamera(scene, viewport)
                                        : new AutoCamera().GetNexusCamera(scene, viewport);
                BitmapSource renderedBitmap = renderer.Render(camera);
                Bitmap = new FastBitmap(renderedBitmap);
            }
        }
Пример #5
0
		public static void Main(string[] args)
		{
			string modelFileName = args[0];
			string outFileName = args[1];

			// Arrange.
			Scene scene = MeshellatorLoader.ImportFromFile(modelFileName);
			using (var renderer = new WarpSceneRenderer(scene, 800, 600))
			{
				Camera camera = PerspectiveCamera.CreateFromBounds(scene.Bounds,
					new Viewport(0, 0, 800, 600), MathUtility.PI_OVER_4, 0, 0, 1);

				// Act.
				BitmapSource bitmap = renderer.Render(camera);

				var e = new PngBitmapEncoder();
				e.Frames.Add(BitmapFrame.Create(bitmap));
				using (Stream stream = File.OpenWrite(outFileName))
					e.Save(stream);
			}
		}
Пример #6
0
		public void CanRenderPrimitive()
		{
			// Arrange.
			Scene scene = MeshellatorLoader.CreateFromTeapot(10, 10);
			using (var renderer = new WarpSceneRenderer(scene, 550, 350))
			{
				renderer.Options.BackgroundColor = Color.FromRgb(200, 200, 200);

				Camera camera = new PerspectiveCamera
				{
					LookDirection = new Vector3D(-1, -0.3f, 1),
					Position = new Point3D(50, 20, -20),
				};

				// Act.
				BitmapSource bitmap = renderer.Render(camera);

				// Assert.
				Assert.IsNotNull(bitmap);
				SaveImage(bitmap, "teapot.jpg");
			}
		}
Пример #7
0
        public static void Main(string[] args)
        {
            string modelFileName = args[0];
            string outFileName   = args[1];

            // Arrange.
            Scene scene = MeshellatorLoader.ImportFromFile(modelFileName);

            using (var renderer = new WarpSceneRenderer(scene, 800, 600))
            {
                Camera camera = PerspectiveCamera.CreateFromBounds(scene.Bounds,
                                                                   new Viewport(0, 0, 800, 600), MathUtility.PI_OVER_4, 0, 0, 1);

                // Act.
                BitmapSource bitmap = renderer.Render(camera);

                var e = new PngBitmapEncoder();
                e.Frames.Add(BitmapFrame.Create(bitmap));
                using (Stream stream = File.OpenWrite(outFileName))
                    e.Save(stream);
            }
        }
Пример #8
0
        public void CanRenderPrimitive()
        {
            // Arrange.
            Scene scene = MeshellatorLoader.CreateFromTeapot(10, 10);

            using (var renderer = new WarpSceneRenderer(scene, 550, 350))
            {
                renderer.Options.BackgroundColor = Color.FromRgb(200, 200, 200);

                Camera camera = new PerspectiveCamera
                {
                    LookDirection = new Vector3D(-1, -0.3f, 1),
                    Position      = new Point3D(50, 20, -20),
                };

                // Act.
                BitmapSource bitmap = renderer.Render(camera);

                // Assert.
                Assert.IsNotNull(bitmap);
                SaveImage(bitmap, "teapot.jpg");
            }
        }
Пример #9
0
		public void CanRenderModel()
		{
			// Arrange.
			Scene scene = MeshellatorLoader.ImportFromFile("Models/3ds/85-nissan-fairlady.3ds");
			using (var renderer = new WarpSceneRenderer(scene, 800, 600))
			{
				Camera camera = new PerspectiveCamera
				{
					FarPlaneDistance = 100000,
					NearPlaneDistance = 1,
					FieldOfView = MathUtility.PI_OVER_4,
					LookDirection = new Vector3D(-1, -0.3f, 1),
					Position = new Point3D(3000, 1500, -1500),
					UpDirection = Vector3D.Up
				};

				// Act.
				var bitmap = renderer.Render(camera);

				// Assert.
				Assert.IsNotNull(bitmap);
				SaveImage(bitmap, "nissan.jpg");
			}
		}