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(); } }
public DirectXScene GetDirectXScene() { if(_scene != null) return _scene; lock(_sync) { return _scene ?? (_scene = new DirectXScene(_root)); } }
/// <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));*/ }
public DirectXScene GetDirectXScene() { if (_scene != null) { return(_scene); } lock (_sync) { return(_scene ?? (_scene = new DirectXScene(_root))); } }
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); }
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) { }
public DirectXFormDrawer(DirectXScene directXScene) : this(directXScene, new DrawerSettings()) { }
public abstract void DrawScene(DirectXScene scene);