public override void SetupForDevice(OutputSettings settings)
 {
     // pick techniques required
     string noiseType = "Turbulence";
     string techStr = string.Format("noise{0}", noiseType);
     technique = effect.GetTechnique(techStr);
 }
        public CommonDeviceInterface(int adapter, OutputRequirements baseReq, OutputRequirements minReq,
                                     string base_path)
        {
            this.adapter = adapter;
            this.outCaps = OutputCaps.GetAdapterCaps(adapter, baseReq.DeviceType, baseReq.DeviceFormat);
            this.minSettings = OutputSettings.CreateFromRequirements(baseReq, outCaps, minReq);
            rzManager = new NuGenSVisualLib.Resources.ResourceManager();
            rzManager.AddSet(new NuGenSVisualLib.Resources.ResourceSet(GlobalResources));

            log = new DirectFileLog(base_path + "general.log");

            rzLoader = new RzLoader();
            rzLoader.RegisterContentLoader(new ImageContentLoader());
        }
        public override void SetupForDevice(OutputSettings settings)
        {
            if (Manager.GetDeviceCaps(settings.Adapter, settings.DeviceType).NumberSimultaneousRts < 2)
                //{
                nPasses = 2;
            nRtUsed = 1;
            //}
            //else
            //{
            //    nPasses = 1;
            //    nRtUsed = 2;
            //}
            if (!Manager.CheckDeviceFormat(settings.Adapter, settings.DeviceType, Format.R16F,
                Usage.RenderTarget, ResourceType.Surface, DepthFormat.D16))
                blobTexFormat = Format.R32F;
            else
                blobTexFormat = Format.R16F;

            OnReset();
        }
 public override void CheckDeviceCompatibility(OutputSettings settings)
 {
 }
 public abstract void SetupForDevice(OutputSettings settings);
 public abstract void CheckDeviceCompatibility(OutputSettings settings);
示例#7
0
 public override void SetupForDevice(OutputSettings settings)
 {
 }
示例#8
0
 public override void SetupForDevice(OutputSettings settings)
 {
     technique = effect.GetTechnique("outlinePerPixel");
 }
示例#9
0
        public static OutputSettings CreateFromRequirements(OutputRequirements requirements, OutputCaps caps,
                                                            OutputRequirements fallbacks)
        {
            if (caps == null)
                caps = OutputCaps.GetDefaultAdapterCaps(requirements);

            OutputSettings settings = new OutputSettings();
            settings.adapter = caps.Adapter;

            Type type = typeof(OutputSettings);

            OutputCaps.OutputCapsCompatibility reqComp = caps.CheckCompatibility(requirements);
            OutputCaps.OutputCapsCompatibility fallbackComp = caps.CheckCompatibility(fallbacks);

            // check reqs against caps
            if (reqComp.SupportDeviceType)
                settings.devType = requirements.DeviceType;
            else if (fallbackComp.SupportDeviceType)
                settings.devType = fallbacks.DeviceType;
            else
                throw new OutputSettingsException(type.GetProperty("DeviceType"),
                                                  requirements.DeviceType, null);

            if (reqComp.SupportDeviceFormat)
                settings.devFormat = requirements.DeviceFormat;
            else if (fallbackComp.SupportDeviceFormat)
                settings.devFormat = fallbacks.DeviceFormat;
            else
                throw new OutputSettingsException(type.GetProperty("DeviceFormat"),
                                                  requirements.DeviceFormat, null);

            if (reqComp.SupportDepthFormat)
                settings.depthFormat = requirements.DepthFormat;
            else if (fallbackComp.SupportDepthFormat)
                settings.depthFormat = fallbacks.DepthFormat;
            else
                throw new OutputSettingsException(type.GetProperty("DepthFormat"),
                                                  requirements.DepthFormat, null);

            if (caps.HardwareTnL && requirements.HardwareTnL)
                settings.createFlags = CreateFlags.HardwareVertexProcessing;
            else if (!requirements.HardwareTnL)
                settings.createFlags = CreateFlags.SoftwareVertexProcessing;
            else if (!fallbacks.HardwareTnL)
                settings.createFlags = CreateFlags.SoftwareVertexProcessing;
            else
                throw new OutputSettingsException(type.GetProperty("CreateFlags"),
                                                  requirements.HardwareTnL, null);

            if (requirements.AntiAliasing <= caps.AntiAliasing.MaxSupported)
                settings.antiAliasing = requirements.AntiAliasing;
            else if (fallbacks.AntiAliasing <= caps.AntiAliasing.MaxSupported)
                settings.antiAliasing = fallbacks.AntiAliasing;
            else
                throw new OutputSettingsException(type.GetProperty("AntiAliasing"),
                                                  requirements.AntiAliasing, caps.AntiAliasing.MaxSupported);

            return settings;
        }
示例#10
0
        public MoleculeSceneManager(Device device, OutputSettings outSettings)
            : base(device)
        {
            
            screenEntities = new List<IScreenSpaceEntity>();
            postSceneWorldEntities = new List<IEntity>();
            postSceneViewEntities = new List<ViewSpaceEntity>();
            zCompareViewEntities = new SortedList<float, ViewSpaceEntity>();

            //effect = new ShadowMappingEffect(device, HashTableSettings.Instance, 1);//PPixelLightEffect(device, HashTableSettings.Instance, 1);
            effect = new PPixelLightEffect(device, HashTableSettings.Instance, 1);
            effect.LoadResources();

            LightingSetup setup = new LightingSetup();
            DirectionalLight light = new DirectionalLight();
            light.Clr = Color.White;
            light.Direction = new Vector3(1, -1, -1);
            light.Enabled = true;
            setup.lights.Add(light);

            effect.SetupWithLights(setup);
            effect.SetupForDevice(this.outSettings = outSettings);
            
            /*ppEffect = new BloomEffect(device, HashTableSettings.Instance);
            ppEffect.LoadResources();
            ppEffect.SetupWithLights(setup);*/
            effect.SetupForDevice(this.outSettings);
        }
 public override void SetupForDevice(OutputSettings settings)
 {
     // pick techniques required
     bool texture = true;
     bool spec = true;
     string lightType = "Dir";
     string techStr = string.Format("std_basic{0}Light{1}Spec{2}Texture", lightType, spec ? "" : "No", texture ? "" : "No");
     if (lod == 0)
     {
         technique = effect1.GetTechnique(techStr);
         lineTechnique = effect1.GetTechnique(techStr + "Line");
         alphaTechnique = effect1.GetTechnique("std_basicAlphaTexture");
     }
     else if (lod == 1)
     {
         technique = effect2.GetTechnique(techStr);
         lineTechnique = effect2.GetTechnique(techStr + "Line");
         alphaTechnique = effect2.GetTechnique("std_basicAlphaTexture");
     }
 }
示例#12
0
        public static OutputSettings CreateFromRequirements(OutputRequirements requirements, OutputCaps caps,
                                                            OutputRequirements fallbacks)
        {
            if (caps == null)
            {
                caps = OutputCaps.GetDefaultAdapterCaps(requirements);
            }

            OutputSettings settings = new OutputSettings();

            settings.adapter = caps.Adapter;

            Type type = typeof(OutputSettings);

            OutputCaps.OutputCapsCompatibility reqComp      = caps.CheckCompatibility(requirements);
            OutputCaps.OutputCapsCompatibility fallbackComp = caps.CheckCompatibility(fallbacks);

            // check reqs against caps
            if (reqComp.SupportDeviceType)
            {
                settings.devType = requirements.DeviceType;
            }
            else if (fallbackComp.SupportDeviceType)
            {
                settings.devType = fallbacks.DeviceType;
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("DeviceType"),
                                                  requirements.DeviceType, null);
            }

            if (reqComp.SupportDeviceFormat)
            {
                settings.devFormat = requirements.DeviceFormat;
            }
            else if (fallbackComp.SupportDeviceFormat)
            {
                settings.devFormat = fallbacks.DeviceFormat;
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("DeviceFormat"),
                                                  requirements.DeviceFormat, null);
            }

            if (reqComp.SupportDepthFormat)
            {
                settings.depthFormat = requirements.DepthFormat;
            }
            else if (fallbackComp.SupportDepthFormat)
            {
                settings.depthFormat = fallbacks.DepthFormat;
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("DepthFormat"),
                                                  requirements.DepthFormat, null);
            }

            if (caps.HardwareTnL && requirements.HardwareTnL)
            {
                settings.createFlags = CreateFlags.HardwareVertexProcessing;
            }
            else if (!requirements.HardwareTnL)
            {
                settings.createFlags = CreateFlags.SoftwareVertexProcessing;
            }
            else if (!fallbacks.HardwareTnL)
            {
                settings.createFlags = CreateFlags.SoftwareVertexProcessing;
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("CreateFlags"),
                                                  requirements.HardwareTnL, null);
            }

            if (requirements.AntiAliasing <= caps.AntiAliasing.MaxSupported)
            {
                settings.antiAliasing = requirements.AntiAliasing;
            }
            else if (fallbacks.AntiAliasing <= caps.AntiAliasing.MaxSupported)
            {
                settings.antiAliasing = fallbacks.AntiAliasing;
            }
            else
            {
                throw new OutputSettingsException(type.GetProperty("AntiAliasing"),
                                                  requirements.AntiAliasing, caps.AntiAliasing.MaxSupported);
            }

            return(settings);
        }
        private void SetupEffectPreview()
        {
            OutputSettings outSettings = new OutputSettings(outCaps.Adapter, true, DeviceType.Hardware,
                                                            Format.Unknown, outCaps.AntiAliasing.MaxSupported,
                                                            DepthFormat.D16, CreateFlags.HardwareVertexProcessing);

            effectPreviewControl1.CoDesc = coDesc;
            effectPreviewControl1.Enabled = true;
            effectPreviewControl1.OutSettings = outSettings;

            uiEffectLOD.OnLODValueChanged += new EventHandler(uiEffectLOD_OnLODValueChanged);

            effectPreviewControl1.OnNewPreview += new EventHandler(effectPreviewControl1_OnNewPreview);
        }
        private void DoChangeScheme(Scheme scheme)
        {
            // setup settings
            lock (thislock)
            {
                currentScheme = null;

                //coDesc.AtomShadingDesc.MoleculeMaterials = refcoDesc.AtomShadingDesc.MoleculeMaterials;
                //coDesc.BondShadingDesc.MoleculeMaterials = refcoDesc.BondShadingDesc.MoleculeMaterials;

                // set common values
                if (scheme.scheme.HandlesAtoms)
                {
                    uiAtomsGSetGroup.Enabled = true;

                    uiAtomLODControl.SetupValues(scheme.settings.AtomLODRange, scheme.settings.AtomLOD);
                    if (!(uiAtomDDraw.Enabled = scheme.scheme.HandlesBonds))
                        coDesc.AtomShadingDesc.Draw = false;
                    uiAtomDDraw.Checked = coDesc.AtomShadingDesc.Draw;
                    uiAtomFillModeList.SelectedIndex = (int)coDesc.AtomShadingDesc.FillMode;
                    uiAtomSymbolsDraw.Checked = coDesc.AtomShadingDesc.SymbolText;
                    uiAtomSymbolsBlend.Checked = coDesc.AtomShadingDesc.BlendSymbolText;
                }
                else
                {
                    uiAtomsGSetGroup.Enabled = false;
                }

                if (scheme.scheme.HandlesBonds)
                {
                    uiBondsGSetGroup.Enabled = true;

                    uiBondSpacingList.SelectedIndex = (int)coDesc.BondShadingDesc.Spacing;
                    uiBondEndTypeList.SelectedIndex = (int)coDesc.BondShadingDesc.EndType;
                    uiBondLODControl.SetupValues(scheme.settings.BondLODRange, scheme.settings.BondLOD);
                    if (!(uiBondDDraw.Enabled = scheme.scheme.HandlesAtoms))
                        coDesc.BondShadingDesc.Draw = false;
                    uiBondDDraw.Checked = coDesc.BondShadingDesc.Draw;
                }
                else
                {
                    uiBondsGSetGroup.Enabled = false;
                }

                // add control
                if (scheme.sUI != null/* || ((scheme.sUI = scheme.settings.GetSUI()) != null)*/)
                {
                    //scheme.sUI.SetChangeEvent(new EventHandler(OnSettingsChanged));
                    scheme.sUI.UpdateValues();
                    Control control = (Control)scheme.sUI;
                    GroupBox gBox = new GroupBox();
                    gBox.MaximumSize = gBox.MinimumSize = new Size(panel2.Width, control.Height + 20);
                    control.Dock = DockStyle.Fill;
                    gBox.Text = scheme.scheme.Name;
                    gBox.Controls.Add(control);
                    gBox.Dock = DockStyle.Top;
                    panel2.Controls.Add(gBox);
                }

                // TODO: need to get these from elsewhere!
                OutputSettings outSettings = new OutputSettings(outCaps.Adapter, true, DeviceType.Hardware, Format.Unknown, outCaps.AntiAliasing.MaxSupported, DepthFormat.D16, CreateFlags.HardwareVertexProcessing);

                schemePreviewControl.Enabled = true;
                schemePreviewControl.OutSettings = outSettings;
                coDesc.SchemeSettings = scheme.settings;
                schemePreviewControl.SetScheme(scheme.scheme, coDesc);

                currentScheme = scheme;

                // update effects tab
                SetRequiredEffects(scheme.settings.GetRequiredEffects());
            }
        }
        private void SetupLightingPreview()
        {
            OutputSettings outSettings = new OutputSettings(0, true, DeviceType.Hardware, Format.Unknown, MultiSampleType.None, DepthFormat.D16, CreateFlags.HardwareVertexProcessing);
            lightPreviewControl2.OutSettings = outSettings;
            lightPreviewControl2.OnNewPreview += new EventHandler(lightPreviewControl2_OnNewPreview);

            /*lightingSetup = lightPreviewControl2.Lighting = new LightingSetup();
            DirectionalLight light = new DirectionalLight();
            light.Clr = Color.Red;
            light.Direction = new Vector3(-1, 0, 0);
            light.Direction.Normalize();
            light.Enabled = true;
            lightingSetup.lights.Add(light);

            directionalLightControl1.SetData(light);

            lightingSchemeLabel.Text = lightingSetup.name;*/
        }
        protected virtual void InitializeEnvironment(CommonDeviceInterface cdi)
        {
            // Get device settings
            if (outCaps == null)
                outCaps = OutputCaps.GetDefaultAdapterCaps(outReqs);
            outSettings = OutputSettings.CreateFromRequirements(outReqs, outCaps, outMinReqs);

            // Set up the presentation parameters
            presentParams.Windowed = outReqs.Windowed;
            presentParams.SwapEffect = SwapEffect.Discard;
            presentParams.AutoDepthStencilFormat = outSettings.DepthFormat;
            presentParams.EnableAutoDepthStencil = (outSettings.DepthFormat != DepthFormat.Unknown);

            CreateDevice();

            devIf = new DeviceInterface(device, cdi);
        }