public void Render(Graphics.BoundingVolumesRenderer bvRenderer, View view, Scene scene, Common.Pathing.NavMesh navMesh, int activeFrame) { if (Settings.VisualBoundings) { foreach (var v in scene.AllEntities) { if (v.ActiveInMain == activeFrame) { bvRenderer.Draw(Matrix.Identity, v.VisibilityWorldBounding, Color.Orange); } } } if (Settings.PhysicsBoundings) { bvRenderer.DrawFullChains = Settings.PhysicsBoundingsFullChains; foreach (var v in scene.AllEntities) { if (v is Client.Game.Map.GameEntity && v.ActiveInMain == activeFrame && (!Settings.PhysicsBoundingsHideGround || !(v is Client.Game.Map.GroundPiece))) { bvRenderer.Draw(Matrix.Identity, ((Client.Game.Map.GameEntity)v).PhysicsLocalBounding != null ? Common.Boundings.Transform(((Client.Game.Map.GameEntity)v).PhysicsLocalBounding, v.WorldMatrix) : null, Color.Blue); } } bvRenderer.DrawFullChains = true; } if (Settings.PathMesh) { bvRenderer.Draw(Matrix.Identity, navMesh.BoundingRegion, Color.White); } if (Settings.AggroRange) { foreach (var v in scene.AllEntities) { if (v.ActiveInMain == activeFrame && v is Map.NPC) { view.DrawCircle(scene.Camera, Matrix.Identity, ((Map.NPC)v).Position, ((Map.NPC)v).InRangeRadius, 12, Color.Red); } } } }
public override void Init() { Application.Log("Program.Init"); ClientXmlFormatterBinder.Instance.BindClientTypes(); LoadControls(); SignalEvent(ProgramEventType.ProgramStarted); #if DEBUG RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Init start"); #endif Content.ContentPath = Program.DataPath; Game.Map.GameEntity.ContentPool = Content; Bitmap b = new Bitmap(Common.FileSystem.Instance.OpenRead(Content.ContentPath + "/Interface/Cursors/MenuCursor1.png")); Graphics.Cursors.Arrow = NeutralCursor = Cursor = new System.Windows.Forms.Cursor(b.GetHicon()); Graphics.Interface.InterfaceScene.DefaultFont = Fonts.Default; if (Settings.DeveloperMainMenu) { MainMenuDefault = MainMenuType.DeveloperMainMenu; ProfileMenuDefault = ProfileMenuType.DeveloperMainMenu; } else if (Settings.ChallengeMapMode) { MainMenuDefault = MainMenuType.ChallengeMap; ProfileMenuDefault = ProfileMenuType.ChallengeMap; } else { MainMenuDefault = MainMenuType.MainMenu; ProfileMenuDefault = ProfileMenuType.ProfileMenu; } if (Settings.DisplaySettingsForm) { OpenDeveloperSettings(); } //Graphics.Content.DefaultModels.Load(Content, Device9); InterfaceScene = new Graphics.Interface.InterfaceScene(); InterfaceScene.View = this; ((Graphics.Interface.Control)InterfaceScene.Root).Size = new Vector2(Program.Settings.GraphicsDeviceSettings.Resolution.Width, Program.Settings.GraphicsDeviceSettings.Resolution.Height); InterfaceScene.Add(Interface); InterfaceScene.Add(AchievementsContainer); InterfaceScene.Add(PopupContainer); InterfaceScene.Add(FeedackOnlineControl); if (!String.IsNullOrEmpty(Program.Settings.BetaSurveyLink)) { var u = new Uri(Program.Settings.BetaSurveyLink); var s = u.ToString(); if (!u.IsFile) { Button survey = new Button { Text = "Beta survey", Anchor = Orientation.BottomRight, Position = new Vector2(10, 50), Size = new Vector2(110, 30) }; survey.Click += new EventHandler((o, e) => { Util.StartBrowser(s); }); InterfaceScene.Add(survey); } } InterfaceScene.Add(Tooltip); InterfaceScene.Add(MouseCursor); InputHandler = InterfaceManager = new Graphics.Interface.InterfaceManager { Scene = InterfaceScene }; // Adjust the main char skin mesh; remove the dummy weapons var mainCharSkinMesh = Program.Instance.Content.Acquire<SkinnedMesh>( new SkinnedMeshFromFile("Models/Units/MainCharacter1.x")); mainCharSkinMesh.RemoveMeshContainerByFrameName("sword1"); mainCharSkinMesh.RemoveMeshContainerByFrameName("sword2"); mainCharSkinMesh.RemoveMeshContainerByFrameName("rifle"); try { SoundManager = new Client.Sound.SoundManager(Settings.SoundSettings.AudioDevice, Settings.SoundSettings.Engine, Settings.SoundSettings.MinMaxDistance.X, Settings.SoundSettings.MinMaxDistance.Y, Common.FileSystem.Instance.OpenRead); SoundManager.Settings = Settings.SoundSettings; SoundManager.ContentPath = Program.DataPath + "/Sound/"; SoundManager.Muted = Settings.SoundSettings.Muted; SoundManager.LoadSounds(!Settings.ChallengeMapMode); if (SoundLoaded != null) SoundLoaded(SoundManager, null); SoundManager.Volume = Settings.SoundSettings.MasterVolume; SoundManager.GetSoundGroup(Client.Sound.SoundGroups.Ambient).Volume = Settings.SoundSettings.AmbientVolume; SoundManager.GetSoundGroup(Client.Sound.SoundGroups.Music).Volume = Settings.SoundSettings.MusicVolume; SoundManager.GetSoundGroup(Client.Sound.SoundGroups.SoundEffects).Volume = Settings.SoundSettings.SoundVolume; SoundManager.GetSoundGroup(Client.Sound.SoundGroups.Interface).Volume = Settings.SoundSettings.SoundVolume; } catch (Client.Sound.SoundManagerException ex) { SendSoundFailureLog(ex); SoundManager = new Client.Sound.DummySoundManager(); System.Windows.Forms.MessageBox.Show( Locale.Resource.ErrorFailInitSoundDevice, Locale.Resource.ErrorFailInitSoundDeviceTitle, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } //StateManager = new DummyDevice9StateManager(Device9); StateManager = new Device9StateManager(Device9); InterfaceRenderer = new Graphics.Interface.InterfaceRenderer9(Device9) { Scene = InterfaceScene, StateManager = StateManager, #if PROFILE_INTERFACERENDERER PeekStart = () => ClientProfilers.IRPeek.Start(), PeekEnd = () => ClientProfilers.IRPeek.Stop() #endif }; InterfaceRenderer.Initialize(this); BoundingVolumesRenderer = new BoundingVolumesRenderer { StateManager = Program.Instance.StateManager, View = Program.Instance }; #if BETA_RELEASE Client.Settings defaultSettings = new Settings(); ValidateSettings("", defaultSettings, Settings); #endif if (Settings.QuickStartMap != null && Settings.QuickStartMap != "" && Common.FileSystem.Instance.FileExists("Maps/" + Settings.QuickStartMap + ".map")) { LoadNewState(new Game.Game("Maps/" + Settings.QuickStartMap)); return; } UpdateFeedbackOnlineControl(); System.Net.NetworkInformation.Ping p = new System.Net.NetworkInformation.Ping(); p.PingCompleted += new System.Net.NetworkInformation.PingCompletedEventHandler((o, e) => { FeedbackOnline = e.Reply != null && e.Reply.Status == System.Net.NetworkInformation.IPStatus.Success; UpdateFeedbackOnlineControl(); }); var statsUri = new Uri(Settings.StatisticsURI); p.SendAsync(statsUri.DnsSafeHost, null); if (Settings.DeveloperMainMenu) InitDeveloperMenu(); else if (Settings.ChallengeMapMode) InitChallengeMapMode(); else InitFullGame(); EnterMainMenuState(false); if(WindowMode == WindowMode.Fullscreen) MouseCursor.BringToFront(); AskAboutUpdate(); if (!String.IsNullOrEmpty(Program.Settings.StartupMessage)) { Dialog.Show(Program.Settings.StartupMessageTitle ?? "", Program.Settings.StartupMessage); } fixedFrameStepSW.Start(); Application.Log("Program.Init completed"); #if DEBUG RedGate.Profiler.UserEvents.ProfilerEvent.SignalEvent("Init end"); #endif }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(-5, 5, 5), AspectRatio = AspectRatio }; foreach (var v in scene.AllEntities) v.VisibilityLocalBounding = Vector3.Zero; Device9StateManager sm = new Device9StateManager(Device9); renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = sm }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = scene, Renderer = renderer }; sceneRendererConnector.Initialize(); bvr = new BoundingVolumesRenderer { View = this, StateManager = sm }; BVEntity t; scene.Add(t = new BVEntity { MainGraphic = new MetaModel { XMesh = new MeshFromFile("Models/Props/Barrel1.x"), Texture = new TextureFromFile("Models/Props/Barrel1.png"), World = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya, }, WorldMatrix = Matrix.Translation(1, 0, 0) }); t.BoundingVolume = Graphics.Boundings.Transform(new Graphics.MetaBoundingBox { Mesh = ((MetaModel)t.MainGraphic).XMesh }, ((MetaModel)t.MainGraphic).World); scene.Add(t = new BVEntity { MainGraphic = new MetaModel { SkinnedMesh = new SkinnedMeshFromFile("Models/Props/Bridge1.x"), Texture = new TextureFromFile("Models/Props/Bridge1.png"), World = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya }, WorldMatrix = Matrix.Translation(3, 0, 0) }); scene.Add(t = new BVEntity { MainGraphic = new MetaModel { SkinnedMesh = new SkinnedMeshFromFile("Models/Props/Bridge1.x"), Texture = new TextureFromFile("Models/Props/Bridge1.png"), World = Matrix.Scaling(0.1f, 0.1f, 0.1f) * SkinnedMesh.InitSkinnedMeshFromMaya }, WorldMatrix = Matrix.Translation(-3, -3, 0) }); t.BoundingVolume = Vector3.Zero; }
public override void Init() { if (DesignMode) return; Content.ContentPath = "Data(.kel)"; Client.Game.Map.GameEntity.ContentPool = Content; Scene.View = this; Scene.Camera = new LookatSphericalCamera() { FOV = 0.5f, ZFar = 50, SphericalCoordinates = Program.ClientDefaultSettings.CameraSphericalCoordinates, AspectRatio = this.AspectRatio }; Controller = new InteractiveSceneManager { Scene = Scene }; StateManager = new DummyDevice9StateManager(Device9); InputHandler = inputHandlersRoot; cameraInputHandler = new CameraInputHandler { Camera = (LookatSphericalCamera)Scene.Camera, View = this, }; Scene.Camera.ZFar = 50; inputHandlersRoot.InputHandlers.Add(cameraInputHandler); cameraInputHandler.InputHandler = Controller; if (Program.Settings.UseDummyRenderer) { throw new NotSupportedException("Dummy renderer is no longer supported."); //Renderer = new Graphics.DummyRenderer.Renderer { Scene = Scene, StateManager = StateManager }; } else { Renderer = new Graphics.Renderer.Renderer(Device9) { Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings { ShadowQuality = Graphics.Renderer.Settings.ShadowQualities.Medium, LightingQuality = Graphics.Renderer.Settings.LightingQualities.High } }; SceneRendererConnector = new SortedTestSceneRendererConnector { Scene = Scene, Renderer = Renderer }; } Renderer.Settings.TerrainQuality = Graphics.Renderer.Settings.TerrainQualities.High; Renderer.Settings.LightingQuality = Graphics.Renderer.Settings.LightingQualities.High; Renderer.Settings.ShadowQuality = Graphics.Renderer.Settings.ShadowQualities.Low; SceneRendererConnector.Initialize(); Renderer.Initialize(Scene.View); if (Program.Settings.DeveloperSettings) { p1 = new System.Windows.Forms.PropertyGrid { SelectedObject = Renderer.Settings, Dock = System.Windows.Forms.DockStyle.Fill }; form1.Controls.Add(p1); form1.Show(); } bvRenderer = new BoundingVolumesRenderer { StateManager = StateManager, View = this }; tooltip = new System.Windows.Forms.ToolTip(); StartDefaultMode(); }