public override void OnEnter() { oldInputHandler = view.StateInputHandler; if (regionsControl == null) { regionsControl = new RegionsEditorControl { Dock = System.Windows.Forms.DockStyle.Fill }; regionsControl.LoadRegions(MainWindow.Instance.CurrentMap); } regionsControl.RegionSelected += new EventHandler(regionsControl_RegionSelected); editor = new Graphics.Editors.BoundingRegionEditor(view, view.GroundProbe) { NodeScale = 0.1f }; editorRenderer = new Graphics.Editors.BoundingRegionEditor.Renderer9(editor) { Camera = view.Scene.Camera, StateManager = view.StateManager }; view.StateInputHandler = editor; }
public override void OnEnter() { oldInputHandler = view.StateInputHandler; editor = new Graphics.Editors.BoundingRegionEditor(view, view.GroundProbe) { NodeScale = 0.1f }; editor.Region = MainWindow.Instance.CurrentMap.NavMesh.BoundingRegion; editorRenderer = new Graphics.Editors.BoundingRegionEditor.Renderer9(editor) { Camera = view.Scene.Camera, StateManager = view.StateManager }; view.StateInputHandler = editor; }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(-5, 5, 5), ZFar = 200, AspectRatio = AspectRatio }; BinaryFormatter b = new BinaryFormatter(); string filename = "../../navmesh"; Common.Pathing.NavMesh navmesh; if (File.Exists(filename)) { FileStream f = new FileStream(filename, FileMode.Open); try { navmesh = (Common.Pathing.NavMesh)b.Deserialize(f); } catch (Exception e) { navmesh = new Common.Pathing.NavMesh(); System.Windows.Forms.MessageBox.Show(e.ToString()); } } else { navmesh = new Common.Pathing.NavMesh(); } editor = new Graphics.Editors.BoundingRegionEditor(this, new Graphics.WorldViewProbe(this, scene.Camera)); editor.Region = navmesh.BoundingRegion; editorRenderer = new Graphics.Editors.BoundingRegionEditor.Renderer9(editor) { StateManager = new Device9StateManager(Device9), Camera = scene.Camera }; InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = editor }; }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(-5, 5, 5), ZFar = 200, AspectRatio = AspectRatio }; BinaryFormatter b = new BinaryFormatter(); string filename = "../../navmesh"; Common.Pathing.NavMesh navmesh; if (File.Exists(filename)) { FileStream f = new FileStream(filename, FileMode.Open); try { navmesh = (Common.Pathing.NavMesh)b.Deserialize(f); } catch (Exception e) { navmesh = new Common.Pathing.NavMesh(); System.Windows.Forms.MessageBox.Show(e.ToString()); } } else navmesh = new Common.Pathing.NavMesh(); editor = new Graphics.Editors.BoundingRegionEditor(this, new Graphics.WorldViewProbe(this, scene.Camera)); editor.Region = navmesh.BoundingRegion; editorRenderer = new Graphics.Editors.BoundingRegionEditor.Renderer9(editor) { StateManager = new Device9StateManager(Device9), Camera = scene.Camera }; InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = editor }; }
public override void Init() { if (DesignMode) { return; } Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Lookat = Vector3.Zero, Position = new Vector3(-15, 15, 15), FOV = 0.5f, ZFar = 400, AspectRatio = AspectRatio }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, Settings = new Graphics.Renderer.Settings(), StateManager = new Graphics.GraphicsDevice.Device9StateManager(Device9) }; renderer.Initialize(this); sceneQuadtree = new Common.Quadtree <Entity>(10); sbau = new SceneBVHAutoSyncer(scene, sceneQuadtree); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = renderer, Scene = scene }; sceneRendererConnector.Initialize(); navMesh = new Common.Pathing.NavMesh(); worldViewProbe = new Graphics.WorldViewProbe(this, scene.Camera); editor = new Graphics.Editors.BoundingRegionEditor(this, worldViewProbe); editor.Region = navMesh.BoundingRegion; editorRenderer = new Graphics.Editors.BoundingRegionEditor.Renderer9(editor) { StateManager = new Graphics.GraphicsDevice.Device9StateManager(Device9), Camera = scene.Camera }; InputHandler = editor; inputHandlers.Add(editor); inputHandlers.Add(new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = new InteractiveSceneManager { Scene = scene }, //FilteredMessages = new MessageType[] { } }); var sim = new Common.Motion.Simulation(navMesh); ((Common.Motion.Simulation)sim).SetHeightMap(new float[][] { new float[] { 0.5f } }, new Vector2(400, 400), new Vector2(-200, -200)); motionSimulation = sim; //motionSimulation = new Common.Motion.ThreadSimulationProxy(sim); var ground = CreateBlock(new Vector3(-200, -200, -0.5f), new Vector3(400, 400, 1), "Models/GroundTextures/Grass1.png"); scene.Add(ground); motionSimulation.Insert(ground.MotionObject); npc = CreateNPC(new Vector2(-2, -2)); scene.Add(npc); motionSimulation.Insert(npc.MotionObject); ((Common.IMotion.IUnit)npc.MotionObject).VelocityImpulse(new Vector3(0, 0, 0.1f)); ((Common.IMotion.INPC)npc.MotionObject).Weight = 10000000f; AddCreatedGridEvent(npc); //((Common.Motion.NPC)npc.MotionObject).DebugSolidAsARock = true; int amount = 25; Vector2 offset = new Vector2(-4, -4); for (int i = 0; i < amount; i++) { int x = i / (int)System.Math.Sqrt(amount); int y = i % (int)System.Math.Sqrt(amount); var n = CreateNPC(new Vector2(x, y)); pursuers.Add(n); scene.Add(n); motionSimulation.Insert(n.MotionObject); ((Common.IMotion.IUnit)n.MotionObject).VelocityImpulse(new Vector3(0, 0, 0.1f)); AddCreatedGridEvent(n); } }