using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Emergent.Gamebryo.SceneDesigner.Framework; using Emergent.Gamebryo.SceneDesigner.PluginAPI; using Emergent.Gamebryo.SceneDesigner.PluginAPI.StandardServices; using Emergent.Gamebryo.SceneDesigner.StdPluginsCs.Dialogs; namespace Emergent.Gamebryo.SceneDesigner.StdPluginsCs.Panels { public partial class ShadowPanel : Form { public ShadowPanel() { InitializeComponent(); } private void InitChunkList() { m_listBoxAllChunks.Items.Clear(); int iNumChunksX = MFramework.Instance.Scene.GetTerrainNumChunkX(); int iNumChunksY = MFramework.Instance.Scene.GetTerrainNumChunkY(); int iNumChunks = iNumChunksX * iNumChunksY; for (int i=0; i=0 && iSelectedIdx1.0f) { m_textBoxTerrAOMaxShadowed.Text = "0.5f"; } } catch(Exception e2) { m_textBoxTerrAOMaxShadowed.Text = "0.5f"; } } private void m_textBoxTerrainAffectFactor_TextChanged(object sender, EventArgs e) { try { float fValue = float.Parse(m_textBoxTerrainAffectFactor.Text); if (fValue < 0.0f || fValue > 100.0f) { m_textBoxTerrainAffectFactor.Text = "20.0f"; } } catch (Exception e2) { m_textBoxTerrainAffectFactor.Text = "20.0f"; } } private void m_btnProjectionShadow_Click(object sender, EventArgs e) { try { MPoint3 sunDir = MFramework.Instance.Scene.GetSunDirection(); if (sunDir == null) { m_textBoxMessage.Text += "在场景中没有找到名为 sun 的方向光. 阴影生成中断。\r\n"; m_textBoxMessage.Update(); m_textBoxMessage.ScrollToCaret(); return; } int iNumChunks = m_listBoxShadowedChunks.Items.Count; float fMaxShadow = float.Parse(m_textBoxDirMaxShadowed.Text); float fBlur = float.Parse(m_tbBlurParam.Text); m_textBoxMessage.Text += "开始计算方向光阴影.请耐心的等待.\r\n"; m_textBoxMessage.Update(); System.DateTime beginTim = System.DateTime.Now; MFramework.Instance.Scene.ProjectionShadow(sunDir, fMaxShadow, fBlur); System.DateTime endTim = System.DateTime.Now; System.TimeSpan dTime = endTim - beginTim; m_textBoxMessage.Text += "方向光阴影计算完毕.共耗时 " + dTime.TotalSeconds + " 秒.\r\n"; m_textBoxMessage.Update(); m_textBoxMessage.ScrollToCaret(); } catch (Exception e2) { MessageBox.Show(e2.ToString()); } } private void m_btnGenerateEntityAOShadow_Click(object sender, EventArgs e) { try { float fMaxShadow = float.Parse(m_tbEntityAOMaxShadow.Text); float fBlur = float.Parse(m_tbBlurEntityAO.Text); float fBlurTexSize = float.Parse(m_tbBlurTexSize.Text); MFramework.Instance.Scene.FakeEntityAmbientOcclusion(fMaxShadow, fBlur, fBlurTexSize); } catch(Exception e2) { MessageBox.Show(e2.ToString()); } } private void m_btnClear_Click(object sender, EventArgs e) { m_listBoxShadowedChunks.Items.Clear(); m_listBoxAllChunks.SelectedItems.Clear(); } private void m_btnSelectAll_Click(object sender, EventArgs e) { for (int i = 0; i < m_listBoxAllChunks.Items.Count; i++) { m_listBoxAllChunks.SetSelected(i, true); } m_listBoxAllChunks.Update(); } private void ShadowPanel_Load(object sender, EventArgs e) { } private void m_cbViewStaticShadow_CheckedChanged(object sender, EventArgs e) { MTerrain.Instance.SetShadowPreview(m_cbViewStaticShadow.Checked, m_cbViewDynamicShadow.Checked); } private void m_cbViewDynamicShadow_CheckedChanged(object sender, EventArgs e) { MTerrain.Instance.SetShadowPreview(m_cbViewStaticShadow.Checked, m_cbViewDynamicShadow.Checked); } } }