public void TestMultiamplingTypes(MultisampleType multisampleType)
		{
			var deviceWorkerSettings = new DeviceWorker.DeviceSettings
				{
					AutoDetermineMultisampleType = false,
					MultisampleType = multisampleType
				};
			DirectXScene scene = null;
			OffscreenDirectXDrawer offscreenDrawer = null;
			try
			{
				var deviceWorker = new DeviceWorker(deviceWorkerSettings);
				using(var renderTarget = deviceWorker.Device.GetRenderTarget(0))
					Assert.AreEqual(multisampleType, renderTarget.Description.MultisampleType);
				scene = new DirectXScene(deviceWorker, _rootBody, null);
				offscreenDrawer = new OffscreenDirectXDrawer(scene, Width, Height, ImageFormat);
				_rootBody.Add(RedBox);
				var camera = new TopViewCamera(new Frame3D(0, 0, 200), Width / Height);
				byte[] bitmapBytes;
				offscreenDrawer.TryGetImage(camera, out bitmapBytes);
				var bitmap = new Bitmap(new MemoryStream(bitmapBytes));
				CheckImageSize(Width, Height, bitmap);
				CheckBitmapCenter(bitmap, Color.Red);
			}
			finally
			{
				if(offscreenDrawer != null) offscreenDrawer.Dispose();
				if(scene != null) scene.DeviceWorker.TryDispose();
			}
		}
Exemple #2
0
 public CVARCEngineCamera(Body body, DrawerFactory factory, RobotCameraSettings settings)
 {
     Settings = settings;
     this.robot = body;
     Angle viewAngle = Settings.ViewAngle;
     _camera = new FirstPersonCamera(this.robot, Settings.Location,
                                     viewAngle, DefaultWidth / (double)DefaultHeight);
     _drawer = new OffscreenDirectXDrawer(factory.GetDirectXScene(), DefaultWidth,
                                          DefaultHeight);
 }
		public void SetUp()
		{
			SceneConfig.Lights.Clear();
			SceneConfig.Lights.Add(new LightSettings
			                       	{
			                       		Type = LightSettings.MyLightType.Ambient,
			                       		ColorString = "White",
			                       	});
			_scene = new DirectXScene(_rootBody);
			_offscreenDrawer = new OffscreenDirectXDrawer(_scene,
			                                              Width, Height, ImageFormat);
		}
 public void SetUp()
 {
     SceneConfig.Lights.Clear();
     SceneConfig.Lights.Add(new LightSettings
     {
         Type        = LightSettings.MyLightType.Ambient,
         ColorString = "White",
     });
     _scene           = new DirectXScene(_rootBody);
     _offscreenDrawer = new OffscreenDirectXDrawer(_scene,
                                                   Width, Height, ImageFormat);
 }
        public void TestMultiamplingTypes(MultisampleType multisampleType)
        {
            var deviceWorkerSettings = new DeviceWorker.DeviceSettings
            {
                AutoDetermineMultisampleType = false,
                MultisampleType = multisampleType
            };
            DirectXScene           scene           = null;
            OffscreenDirectXDrawer offscreenDrawer = null;

            try
            {
                var deviceWorker = new DeviceWorker(deviceWorkerSettings);
                using (var renderTarget = deviceWorker.Device.GetRenderTarget(0))
                    Assert.AreEqual(multisampleType, renderTarget.Description.MultisampleType);
                scene           = new DirectXScene(deviceWorker, _rootBody, null);
                offscreenDrawer = new OffscreenDirectXDrawer(scene, Width, Height, ImageFormat);
                _rootBody.Add(RedBox);
                var    camera = new TopViewCamera(new Frame3D(0, 0, 200), Width / Height);
                byte[] bitmapBytes;
                offscreenDrawer.TryGetImage(camera, out bitmapBytes);
                var bitmap = new Bitmap(new MemoryStream(bitmapBytes));
                CheckImageSize(Width, Height, bitmap);
                CheckBitmapCenter(bitmap, Color.Red);
            }
            finally
            {
                if (offscreenDrawer != null)
                {
                    offscreenDrawer.Dispose();
                }
                if (scene != null)
                {
                    scene.DeviceWorker.TryDispose();
                }
            }
        }