static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); GraphicsDevice gd = new GraphicsDevice("Pathfinding Test Program", FeatureLevel.Level_11_0, 0.1f, 3000f); PathingForm pathForm = new PathingForm(); //set title of progress window SharedForms.ShaderCompileHelper.mTitle = "Compiling Shaders..."; //save renderform position gd.RendForm.DataBindings.Add(new Binding("Location", Properties.Settings.Default, "MainWindowPos", true, DataSourceUpdateMode.OnPropertyChanged)); pathForm.DataBindings.Add(new Binding("Location", Properties.Settings.Default, "PathWindowPos", true, DataSourceUpdateMode.OnPropertyChanged)); gd.RendForm.Location = Properties.Settings.Default.MainWindowPos; pathForm.Location = Properties.Settings.Default.PathWindowPos; int borderWidth = gd.RendForm.Size.Width - gd.RendForm.ClientSize.Width; int borderHeight = gd.RendForm.Size.Height - gd.RendForm.ClientSize.Height; gd.RendForm.Location = Properties.Settings.Default.MainWindowPos; gd.RendForm.Size = new System.Drawing.Size( 1280 + borderWidth, 720 + borderHeight); gd.CheckResize(); PlayerSteering pSteering = SetUpSteering(); Input inp = SetUpInput(); Random rand = new Random(); bool bMouseLookOn = false; EventHandler actHandler = new EventHandler( delegate(object s, EventArgs ea) { inp.ClearInputs(); }); EventHandler <EventArgs> deActHandler = new EventHandler <EventArgs>( delegate(object s, EventArgs ea) { gd.SetCapture(false); bMouseLookOn = false; }); gd.RendForm.Activated += actHandler; gd.RendForm.AppDeactivated += deActHandler; MapStuff mapStuff = new MapStuff(gd, "."); EventHandler pickedAHandler = new EventHandler( delegate(object s, EventArgs ea) { Vector3EventArgs v3ea = ea as Vector3EventArgs; pathForm.SetCoordA(v3ea.mVector); pathForm.SetNodeA((int)s); }); EventHandler pickedBHandler = new EventHandler( delegate(object s, EventArgs ea) { Vector3EventArgs v3ea = ea as Vector3EventArgs; pathForm.SetCoordB(v3ea.mVector); pathForm.SetNodeB((int)s); }); EventHandler pickReadyHandler = new EventHandler( delegate(object s, EventArgs ea) { pathForm.SetPickReady((bool)s); }); mapStuff.ePickedA += pickedAHandler; mapStuff.ePickedB += pickedBHandler; mapStuff.ePickReady += pickReadyHandler; EventHandler genHandler = new EventHandler( delegate(object s, EventArgs ea) { mapStuff.GeneratePathing(pathForm.GetGridSize(), (float)s); }); EventHandler loadHandler = new EventHandler( delegate(object s, EventArgs ea) { mapStuff.LoadPathing(s as string); }); EventHandler saveHandler = new EventHandler( delegate(object s, EventArgs ea) { mapStuff.SavePathing(s as string); }); EventHandler pickAHandler = new EventHandler( delegate(object s, EventArgs ea) { mapStuff.PickA(); gd.RendForm.Focus(); }); EventHandler pickBHandler = new EventHandler( delegate(object s, EventArgs ea) { mapStuff.PickB(); gd.RendForm.Focus(); }); EventHandler pickBlockedHandler = new EventHandler( delegate(object s, EventArgs ea) { mapStuff.PickBlocked(); gd.RendForm.Focus(); }); EventHandler pickUnBlockedHandler = new EventHandler( delegate(object s, EventArgs ea) { mapStuff.PickUnBlocked(); gd.RendForm.Focus(); }); EventHandler drawChangedHandler = new EventHandler( delegate(object s, EventArgs ea) { mapStuff.DrawSettings((int)s); }); EventHandler mobChangedHandler = new EventHandler( delegate(object s, EventArgs ea) { UInt32 box = (UInt32)s; mapStuff.AlterPathMobile((int)box & 0xFF, (int)box >> 16); }); EventHandler findPathHandler = new EventHandler( delegate(object s, EventArgs ea) { Vector3PairEventArgs v3pea = ea as Vector3PairEventArgs; mapStuff.FindPath(v3pea.mVecA, v3pea.mVecB); }); pathForm.eGenerate += genHandler; pathForm.eLoadData += loadHandler; pathForm.eSaveData += saveHandler; pathForm.ePickA += pickAHandler; pathForm.ePickB += pickBHandler; pathForm.ePickBlock += pickBlockedHandler; pathForm.ePickUnBlock += pickUnBlockedHandler; pathForm.eDrawChanged += drawChangedHandler; pathForm.eMobChanged += mobChangedHandler; pathForm.eFindPath += findPathHandler; pathForm.SetPickReady(false); pathForm.Show(); UpdateTimer time = new UpdateTimer(true, false); time.SetFixedTimeStepSeconds(1f / 60f); //60fps update rate time.SetMaxDeltaSeconds(MaxTimeDelta); List <Input.InputAction> acts = new List <Input.InputAction>(); RenderLoop.Run(gd.RendForm, () => { if (!gd.RendForm.Focused) { Thread.Sleep(33); } else if (mapStuff.Busy()) { Thread.Sleep(5); return; } gd.CheckResize(); if (bMouseLookOn && gd.RendForm.Focused) { gd.ResetCursorPos(); } //Clear views gd.ClearViews(); time.Stamp(); while (time.GetUpdateDeltaSeconds() > 0f) { acts = UpdateInput(inp, gd, time.GetUpdateDeltaSeconds(), ref bMouseLookOn); if (!gd.RendForm.Focused) { acts.Clear(); bMouseLookOn = false; gd.SetCapture(false); inp.UnMapAxisAction(Input.MoveAxis.MouseYAxis); inp.UnMapAxisAction(Input.MoveAxis.MouseXAxis); } mapStuff.Update(time, acts, pSteering); time.UpdateDone(); } mapStuff.RenderUpdate(time.GetRenderUpdateDeltaMilliSeconds()); mapStuff.Render(); gd.Present(); acts.Clear(); }, true); //true here is slow but needed for winforms events Properties.Settings.Default.Save(); gd.RendForm.Activated -= actHandler; gd.RendForm.AppDeactivated -= deActHandler; mapStuff.ePickedA -= pickedAHandler; mapStuff.ePickedB -= pickedBHandler; mapStuff.ePickReady -= pickReadyHandler; pathForm.eGenerate -= genHandler; pathForm.eLoadData -= loadHandler; pathForm.eSaveData -= saveHandler; pathForm.ePickA -= pickAHandler; pathForm.ePickB -= pickBHandler; pathForm.ePickBlock -= pickBlockedHandler; pathForm.ePickUnBlock -= pickUnBlockedHandler; pathForm.eDrawChanged -= drawChangedHandler; pathForm.eMobChanged -= mobChangedHandler; pathForm.eFindPath -= findPathHandler; mapStuff.FreeAll(); inp.FreeAll(); //Release all resources gd.ReleaseAll(); }
static void Main() { //turn this on for help with leaky stuff Configuration.EnableObjectTracking = true; GraphicsDevice gd = new GraphicsDevice("Depth of Mind", FeatureLevel.Level_11_0, 0.1f, 3000f); //save renderform position gd.RendForm.DataBindings.Add(new System.Windows.Forms.Binding("Location", Settings.Default, "MainWindowPos", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); int borderWidth = gd.RendForm.Size.Width - gd.RendForm.ClientSize.Width; int borderHeight = gd.RendForm.Size.Height - gd.RendForm.ClientSize.Height; gd.RendForm.Location = Settings.Default.MainWindowPos; gd.RendForm.Size = new System.Drawing.Size( 1280 + borderWidth, 720 + borderHeight); gd.CheckResize(); //used to have a hard coded path here for #debug //but now can just use launch.json to provide it string rootDir = "."; //set title of progress window SharedForms.ShaderCompileHelper.mTitle = "Compiling Shaders..."; //hold right click to turn, or turn anytime mouse moves? bool bRightClickToTurn = false; MapLoop mapLoop = new MapLoop(gd, rootDir); PlayerSteering pSteering = SetUpSteering(); Input inp = SetUpInput(bRightClickToTurn); Random rand = new Random(); UserSettings sets = new UserSettings(); UpdateTimer time = new UpdateTimer(true, false); time.SetFixedTimeStepSeconds(1f / 60f); //60fps update rate time.SetMaxDeltaSeconds(MaxTimeDelta); Vector3 pos = Vector3.One * 5f; Vector3 lightDir = -Vector3.UnitY; bool bMouseLookOn = false; EventHandler actHandler = new EventHandler( delegate(object s, EventArgs ea) { inp.ClearInputs(); if (!bRightClickToTurn) { bMouseLookOn = true; gd.SetCapture(true); } }); EventHandler <EventArgs> deActHandler = new EventHandler <EventArgs>( delegate(object s, EventArgs ea) { gd.SetCapture(false); bMouseLookOn = false; }); gd.RendForm.Activated += actHandler; gd.RendForm.AppDeactivated += deActHandler; List <Input.InputAction> acts = new List <Input.InputAction>(); RenderLoop.Run(gd.RendForm, () => { if (!gd.RendForm.Focused) { Thread.Sleep(33); } gd.CheckResize(); if (bMouseLookOn && gd.RendForm.Focused) { gd.ResetCursorPos(); } //Clear views gd.ClearViews(); time.Stamp(); while (time.GetUpdateDeltaSeconds() > 0f) { acts = UpdateInput(inp, sets, gd, bRightClickToTurn, time.GetUpdateDeltaSeconds(), ref bMouseLookOn); if (!gd.RendForm.Focused) { acts.Clear(); bMouseLookOn = false; gd.SetCapture(false); } mapLoop.Update(time, acts, pSteering); time.UpdateDone(); } mapLoop.RenderUpdate(time.GetRenderUpdateDeltaMilliSeconds()); mapLoop.Render(); gd.Present(); acts.Clear(); }); Settings.Default.Save(); sets.SaveSettings(); gd.RendForm.Activated -= actHandler; gd.RendForm.AppDeactivated -= deActHandler; mapLoop.FreeAll(); inp.FreeAll(); //Release all resources gd.ReleaseAll(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); GraphicsDevice gd = new GraphicsDevice("Terrain Editor", FeatureLevel.Level_11_0, 0.1f, 3000f); //save form positions gd.RendForm.DataBindings.Add(new Binding("Location", Settings.Default, "MainWindowPos", true, DataSourceUpdateMode.OnPropertyChanged)); gd.RendForm.Location = Settings.Default.MainWindowPos; //used to have a hard coded path here for #debug //but now can just use launch.json to provide it string rootDir = "."; StuffKeeper sk = new StuffKeeper(); SharedForms.ShaderCompileHelper.mTitle = "Compiling Shaders..."; sk.eCompileNeeded += SharedForms.ShaderCompileHelper.CompileNeededHandler; sk.eCompileDone += SharedForms.ShaderCompileHelper.CompileDoneHandler; sk.Init(gd, rootDir); TerrainAtlas ta = new TerrainAtlas(gd, sk); ta.DataBindings.Add(new Binding("Location", Settings.Default, "AtlasFormPos", true, DataSourceUpdateMode.OnPropertyChanged)); ta.DataBindings.Add(new Binding("Size", Settings.Default, "AtlasFormSize", true, DataSourceUpdateMode.OnPropertyChanged)); ta.Location = Settings.Default.AtlasFormPos; ta.Size = Settings.Default.AtlasFormSize; ta.Visible = true; TerrainForm tf = new TerrainForm(); tf.DataBindings.Add(new Binding("Location", Settings.Default, "TerrainFormPos", true, DataSourceUpdateMode.OnPropertyChanged)); tf.Location = Settings.Default.TerrainFormPos; tf.Visible = true; TerrainShading ts = new TerrainShading(); ts.DataBindings.Add(new Binding("Location", Settings.Default, "ShadingFormPos", true, DataSourceUpdateMode.OnPropertyChanged)); ts.Location = Settings.Default.ShadingFormPos; ts.Visible = true; PlayerSteering pSteering = SetUpSteering(); Input inp = SetUpInput(); Random rand = new Random(); Vector3 pos = Vector3.One * 5f; Vector3 lightDir = -Vector3.UnitY; bool bMouseLookOn = false; EventHandler actHandler = new EventHandler( delegate(object s, EventArgs ea) { inp.ClearInputs(); }); EventHandler <EventArgs> deActHandler = new EventHandler <EventArgs>( delegate(object s, EventArgs ea) { gd.SetCapture(false); bMouseLookOn = false; }); gd.RendForm.Activated += actHandler; gd.RendForm.AppDeactivated += deActHandler; GameLoop gLoop = new GameLoop(gd, sk, rootDir); EventHandler buildHandler = new EventHandler( delegate(object s, EventArgs ea) { ListEventArgs <HeightMap.TexData> lea = ea as ListEventArgs <HeightMap.TexData>; gLoop.Texture((TexAtlas)s, lea.mList, ta.GetTransitionHeight()); }); EventHandler applyHandler = new EventHandler( delegate(object s, EventArgs ea) { TerrainShading.ShadingInfo si = s as TerrainShading.ShadingInfo; gLoop.ApplyShadingInfo(si); }); ta.eReBuild += buildHandler; ts.eApply += applyHandler; EventHandler tBuildHandler = new EventHandler( delegate(object s, EventArgs ea) { int gridSize, chunkSize, tilingIterations, threads; int erosionIterations, polySize, smoothPasses, seed; float medianHeight, variance, borderSize; float rainFall, solubility, evaporation; tf.GetBuildData(out gridSize, out chunkSize, out medianHeight, out variance, out polySize, out tilingIterations, out borderSize, out smoothPasses, out seed, out erosionIterations, out rainFall, out solubility, out evaporation, out threads); gLoop.TBuild(gridSize, chunkSize, medianHeight, variance, polySize, tilingIterations, borderSize, smoothPasses, seed, erosionIterations, rainFall, solubility, evaporation, threads); }); EventHandler tLoadHandler = new EventHandler( delegate(object s, EventArgs ea) { gLoop.TLoad(s as string); ta.LoadAtlasInfo(s as string); }); EventHandler tSaveHandler = new EventHandler( delegate(object s, EventArgs ea) { if (gLoop.TSave(s as string)) { ta.SaveAtlasInfo(s as string); ts.SaveShadingInfo(s as string); } }); tf.eBuild += tBuildHandler; tf.eLoad += tLoadHandler; tf.eSave += tSaveHandler; UpdateTimer time = new UpdateTimer(true, false); time.SetFixedTimeStepSeconds(1f / 60f); //60fps update rate time.SetMaxDeltaSeconds(MaxTimeDelta); List <Input.InputAction> acts = new List <Input.InputAction>(); RenderLoop.Run(gd.RendForm, () => { if (!gd.RendForm.Focused) { Thread.Sleep(33); } gd.CheckResize(); if (bMouseLookOn && gd.RendForm.Focused) { gd.ResetCursorPos(); } //Clear views gd.ClearViews(); time.Stamp(); while (time.GetUpdateDeltaSeconds() > 0f) { acts = UpdateInput(inp, gd, time.GetUpdateDeltaSeconds(), ref bMouseLookOn); if (!gd.RendForm.Focused) { acts.Clear(); bMouseLookOn = false; gd.SetCapture(false); inp.UnMapAxisAction(Input.MoveAxis.MouseYAxis); inp.UnMapAxisAction(Input.MoveAxis.MouseXAxis); } gLoop.Update(time, acts, pSteering); time.UpdateDone(); } gLoop.RenderUpdate(time.GetRenderUpdateDeltaMilliSeconds()); gLoop.Render(); gd.Present(); acts.Clear(); }, true); //true here is slow but needed for winforms events Settings.Default.Save(); sk.eCompileNeeded -= SharedForms.ShaderCompileHelper.CompileNeededHandler; sk.eCompileDone -= SharedForms.ShaderCompileHelper.CompileDoneHandler; gd.RendForm.Activated -= actHandler; gd.RendForm.AppDeactivated -= deActHandler; ta.eReBuild -= buildHandler; tf.eBuild -= tBuildHandler; ts.eApply -= applyHandler; gLoop.FreeAll(); inp.FreeAll(); ta.FreeAll(); sk.FreeAll(); //Release all resources gd.ReleaseAll(); }
static void Main() { GraphicsDevice gd = new GraphicsDevice("Test Terrain", FeatureLevel.Level_11_0, 0.1f, 3000f); //save renderform position gd.RendForm.DataBindings.Add(new System.Windows.Forms.Binding("Location", Properties.Settings.Default, "MainWindowPos", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); int borderWidth = gd.RendForm.Size.Width - gd.RendForm.ClientSize.Width; int borderHeight = gd.RendForm.Size.Height - gd.RendForm.ClientSize.Height; gd.RendForm.Location = Properties.Settings.Default.MainWindowPos; gd.RendForm.Size = new System.Drawing.Size( 1280 + borderWidth, 720 + borderHeight); gd.CheckResize(); StuffKeeper sk = new StuffKeeper(); //set title of progress window SharedForms.ShaderCompileHelper.mTitle = "Compiling Shaders..."; //used to have a hard coded path here for #debug //but now can just use launch.json to provide it string rootDir = "."; sk.eCompileNeeded += SharedForms.ShaderCompileHelper.CompileNeededHandler; sk.eCompileDone += SharedForms.ShaderCompileHelper.CompileDoneHandler; sk.Init(gd, rootDir); TerrainLoop terLoop = new TerrainLoop(gd, sk, rootDir); PlayerSteering pSteering = SetUpSteering(); Input inp = SetUpInput(); Random rand = new Random(); UpdateTimer time = new UpdateTimer(true, false); time.SetFixedTimeStepSeconds(1f / 60f); //60fps update rate time.SetMaxDeltaSeconds(MaxTimeDelta); Vector3 pos = Vector3.One * 5f; Vector3 lightDir = -Vector3.UnitY; bool bMouseLookOn = false; EventHandler actHandler = new EventHandler( delegate(object s, EventArgs ea) { inp.ClearInputs(); }); EventHandler <EventArgs> deActHandler = new EventHandler <EventArgs>( delegate(object s, EventArgs ea) { gd.SetCapture(false); bMouseLookOn = false; }); gd.RendForm.Activated += actHandler; gd.RendForm.AppDeactivated += deActHandler; List <Input.InputAction> acts = new List <Input.InputAction>(); RenderLoop.Run(gd.RendForm, () => { if (!gd.RendForm.Focused) { Thread.Sleep(33); } gd.CheckResize(); if (bMouseLookOn && gd.RendForm.Focused) { gd.ResetCursorPos(); } //Clear views gd.ClearViews(); time.Stamp(); while (time.GetUpdateDeltaSeconds() > 0f) { acts = UpdateInput(inp, gd, time.GetUpdateDeltaSeconds(), ref bMouseLookOn); if (!gd.RendForm.Focused) { acts.Clear(); bMouseLookOn = false; gd.SetCapture(false); } terLoop.Update(time, acts, pSteering); time.UpdateDone(); } terLoop.RenderUpdate(time.GetRenderUpdateDeltaMilliSeconds()); terLoop.Render(); gd.Present(); acts.Clear(); }); Properties.Settings.Default.Save(); sk.eCompileNeeded -= SharedForms.ShaderCompileHelper.CompileNeededHandler; sk.eCompileDone -= SharedForms.ShaderCompileHelper.CompileDoneHandler; gd.RendForm.Activated -= actHandler; gd.RendForm.AppDeactivated -= deActHandler; terLoop.FreeAll(); inp.FreeAll(); sk.FreeAll(); //Release all resources gd.ReleaseAll(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //turn this on for help with leaky stuff Configuration.EnableObjectTracking = true; GraphicsDevice gd = new GraphicsDevice("BSP tree building tools", FeatureLevel.Level_11_0, 0.1f, 3000f); //save renderform position gd.RendForm.DataBindings.Add(new Binding("Location", Settings.Default, "MainWindowPos", true, DataSourceUpdateMode.OnPropertyChanged)); gd.RendForm.Location = Settings.Default.MainWindowPos; //set title of progress window SharedForms.ShaderCompileHelper.mTitle = "Compiling Shaders..."; PlayerSteering pSteering = SetUpSteering(); Input inp = SetUpInput(); Random rand = new Random(); Vector3 pos = Vector3.One * 5f; Vector3 lightDir = -Vector3.UnitY; bool bMouseLookOn = false; EventHandler actHandler = new EventHandler( delegate(object s, EventArgs ea) { inp.ClearInputs(); }); EventHandler <EventArgs> deActHandler = new EventHandler <EventArgs>( delegate(object s, EventArgs ea) { gd.SetCapture(false); bMouseLookOn = false; }); gd.RendForm.Activated += actHandler; gd.RendForm.AppDeactivated += deActHandler; BSPBuilder bspBuild = new BSPBuilder(gd, "."); UpdateTimer time = new UpdateTimer(true, false); time.SetFixedTimeStepSeconds(1f / 60f); //60fps update rate time.SetMaxDeltaSeconds(MaxTimeDelta); List <Input.InputAction> acts = new List <Input.InputAction>(); RenderLoop.Run(gd.RendForm, () => { if (!gd.RendForm.Focused) { Thread.Sleep(33); } else if (bspBuild.Busy()) { Thread.Sleep(5); return; } gd.CheckResize(); if (bMouseLookOn && gd.RendForm.Focused) { gd.ResetCursorPos(); } //Clear views gd.ClearViews(); time.Stamp(); while (time.GetUpdateDeltaSeconds() > 0f) { acts = UpdateInput(inp, gd, time.GetUpdateDeltaSeconds(), ref bMouseLookOn); if (!gd.RendForm.Focused) { acts.Clear(); bMouseLookOn = false; gd.SetCapture(false); inp.UnMapAxisAction(Input.MoveAxis.MouseYAxis); inp.UnMapAxisAction(Input.MoveAxis.MouseXAxis); } Vector3 moveDelta = pSteering.Update(pos, gd.GCam.Forward, gd.GCam.Left, gd.GCam.Up, acts); //scale up movement a bit moveDelta *= 200f; pos -= moveDelta; gd.GCam.Update(pos, pSteering.Pitch, pSteering.Yaw, pSteering.Roll); time.UpdateDone(); } bspBuild.Update(time.GetRenderUpdateDeltaMilliSeconds(), gd); bspBuild.Render(gd); gd.Present(); acts.Clear(); }, true); //true here is slow but needed for winforms events Settings.Default.Save(); gd.RendForm.Activated -= actHandler; gd.RendForm.AppDeactivated -= deActHandler; bspBuild.FreeAll(); inp.FreeAll(); //Release all resources gd.ReleaseAll(); }