示例#1
0
		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();
			}
		}
示例#2
0
		public DirectXScene GetDirectXScene()
		{
			if(_scene != null)
				return _scene;
			lock(_sync)
			{
				return _scene ?? (_scene = new DirectXScene(_root));
			}
		}
示例#3
0
		/// <summary>
		/// Создает новый Drawer c использованием переданных сцены, настроек
		/// и функции-инициализатора для окна, в которое следует отрисовывать
		/// </summary>
		/// <param name="scene">Сцена, которую следует отрисовывать</param>
		/// <param name="settings">Настройки</param>
		public DirectXFormDrawer(DirectXScene scene, DrawerSettings settings)
		{
			_settings = settings;
			_scene = scene;
			_effect = scene.Effect;
			_deviceWorker = scene.DeviceWorker;
			//TODO! Return camera controls.
			/*if(Settings.ShowControls)
				Control.Controls.Add(new CameraSwitchControl(_camera));*/
		}
示例#4
0
 public DirectXScene GetDirectXScene()
 {
     if (_scene != null)
     {
         return(_scene);
     }
     lock (_sync)
     {
         return(_scene ?? (_scene = new DirectXScene(_root)));
     }
 }
示例#5
0
		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 OffscreenDirectXDrawer(DirectXScene scene,
									int width, int height, ImageFileFormat imageFileFormat)
		{
			_stopwatch.Restart();
			_scene = scene;
			_effect = scene.Effect;
			_deviceWorker = scene.DeviceWorker;
			_device = _deviceWorker.Device;
			_size = new Size(width, height);
			AcquireSurfaces();
			_deviceWorker.BeforeReset += DisposeSurfaces;
			_deviceWorker.AfterReset += AcquireSurfacesUnsafe;
			_deviceWorker.Disposing += DisposeSurfaces;
			_imageFileFormat = imageFileFormat;
			_stopwatch.Stop();
			LogInfo("Created offscreen drawer in {0}", _stopwatch.ElapsedMilliseconds);
		}
示例#7
0
		public override void DrawScene(DirectXScene scene)
		{
			_device.BeginScene();
			Matrix oldWorld = WorldTransform;
			if(SceneConfig.EnableShadows)
			{
				FloorMode();
				scene.UpdateModelsBase(scene.Floor, null);
				ShadowMode();
				MultiplyWorldTransform(ShadowMatrices[_lights[0]]);
				scene.UpdateModelsBase(scene.RootBody, scene.Floor);
			}
			NormalMode();
			WorldTransform = oldWorld;
			scene.UpdateModelsBase(scene.RootBody, scene.Floor);
			_device.EndScene();
		}
		public OffscreenDirectXDrawer(DirectXScene scene, int width, int height)
			: this(scene, width, height, ImageFileFormat.Png)
		{
		}
示例#9
0
		public DirectXFormDrawer(DirectXScene directXScene)
			: this(directXScene, new DrawerSettings())

		{
		}
示例#10
0
文件: Effect.cs 项目: DmitryZyr/CVARC
		public abstract void DrawScene(DirectXScene scene);