コード例 #1
0
        public override void InitModules(NEngineConfig engineCfg, NEditorConfig editofCfg)
        {
            base.InitModules(engineCfg, editofCfg);

            // 加载对应的程序集
            AttachAssemblyInfo(Assembly.GetExecutingAssembly());
            AttachAssemblyInfo(Assembly.GetEntryAssembly());

            LoadActorFactoryCreator();
        }
コード例 #2
0
        public override void InitModules(NEngineConfig cfg)
        {
            base.InitModules(cfg);

            // 初始化GUI系统
            InitGuiSystem();

            // 加载程序集信息
            AttachAssemblyInfo(Assembly.GetExecutingAssembly());
            AttachAssemblyInfo(Assembly.GetEntryAssembly());
        }
コード例 #3
0
        private void NEViewPort_SizeChanged(object sender, EventArgs e)
        {
            m_view.Width  = (uint)this.ClientSize.Width;
            m_view.Height = (uint)this.ClientSize.Height;

            NEngineConfig eng = NEditorEngine.Instance().Config;

            m_view.X      = (uint)(eng.ClientWidth - m_view.Width) / 2;
            m_view.Y      = (uint)(eng.ClientHeight - m_view.Height) / 2;
            m_cameraSight = m_minCameraSight * (1 - m_Sight * m_Sight) + m_maxCameraSight * (m_Sight * m_Sight);
            m_view.Camera.SetPerspective(MathConst.PI / 4, ClientSize.Width, ClientSize.Height, 20, m_cameraSight);
        }
コード例 #4
0
        protected virtual void NRenderContorl_SizeChanged(object sender, EventArgs e)
        {
            if (m_HWND == 0)
            {
                return;
            }

            m_viewport.Width  = (uint)this.ClientSize.Width;
            m_viewport.Height = (uint)this.ClientSize.Height;
            NEngineConfig cfg = NGameEngine.Instance().Config;

            m_viewport.Camera.SetPerspective(MathConst.PI / 4, ClientSize.Width, ClientSize.Height, 20, 500000);
        }
コード例 #5
0
        /// <summary>
        /// 窗口大小发生变化
        /// </summary>
        protected virtual void GameViewportControl_SizeChanged(object sender, EventArgs e)
        {
            NEngineConfig eng = NEngine.Instance().Config;

            gameViewport.Width  = (uint)Math.Min(eng.ClientWidth, this.ClientSize.Width);
            gameViewport.Height = (uint)Math.Min(eng.ClientHeight, this.ClientSize.Height);
            gameViewport.X      = (uint)(eng.ClientWidth - gameViewport.Width) / 2;
            gameViewport.Y      = (uint)(eng.ClientHeight - gameViewport.Height) / 2;
            gameViewport.Camera.SetPerspective(gameViewport.Camera.FOV,
                                               Math.Min(this.ClientSize.Width, eng.ClientWidth),
                                               Math.Min(this.ClientSize.Height, eng.ClientHeight),
                                               10, 50000);
            gameViewport.Update();

            Window rootWnd = GUISystem.Instance == null ? null : GUISystem.Instance.RootWindow;

            if (rootWnd != null)
            {
                rootWnd.AbsolutePosition = new Vector2(gameViewport.X, gameViewport.Y);
                rootWnd.AbsoluteSize     = new Vector2(gameViewport.Width, gameViewport.Height);
            }
        }
コード例 #6
0
ファイル: Game.cs プロジェクト: yf885188/My3DEngine2008
        private void InitGameEngine()
        {
            // 初始化引擎
            gameEngine = new GameEngine();
            gameEngine.InitCore();

            //-- create engine config
            CustomConfigurationSection configuration = CustomConfigurationSection.Open();

            GameWindow.ClientSize = new Size(configuration.EngineSetting.ClientWidth, configuration.EngineSetting.ClientHeight);
            NEngineConfig engineCfg = new NEngineConfig();

            engineCfg.RenderWndHandle    = GameWindow.RenderHandle;
            engineCfg.ClientWidth        = Screen.PrimaryScreen.Bounds.Width;
            engineCfg.ClientHeight       = Screen.PrimaryScreen.Bounds.Height;
            engineCfg.ColorBits          = configuration.EngineSetting.ColorBits;
            engineCfg.FullScreen         = configuration.EngineSetting.FullScreen;
            engineCfg.EnableHDR          = configuration.EngineSetting.EnableHDR;
            engineCfg.EnableSSAO         = configuration.EngineSetting.EnableSSAO;
            engineCfg.RenderClass        = configuration.EngineSetting.RenderClass;
            engineCfg.FileSystemClass    = configuration.EngineSetting.FileSystemClass;
            engineCfg.EngineDataPkg      = configuration.EngineSetting.EngineDataPkg;
            engineCfg.ResourceCacheClass = configuration.EngineSetting.ResourceCacheClass;
            engineCfg.ResourceIOClass    = configuration.EngineSetting.ResourceIOClass;
            engineCfg.FileSystemRoot     = configuration.EngineSetting.FileSystemRoot;
            if (string.IsNullOrEmpty(engineCfg.FileSystemRoot))
            {
                engineCfg.FileSystemRoot = NFileSystem.DefaultFileSystemRoot;
            }

            configuration.Save();

            //初始化引擎
            gameEngine.InitModules(engineCfg);

            //-- create editor windows
            GameWindow.ViewportControl.CreateViewport();
        }
コード例 #7
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                g_GameEngine = new NGameEngine();
                g_GameEngine.InitCore();

                form = GUITesterMainForm.App;

                //-- create engine config
                NEngineConfig engineCfg = new NEngineConfig();
                engineCfg.RenderWndHandle = form.RenderPanelHandle;
                engineCfg.ClientWidth     = Screen.PrimaryScreen.Bounds.Width;
                engineCfg.ClientHeight    = Screen.PrimaryScreen.Bounds.Height;
                engineCfg.ColorBits       = 32;
                engineCfg.FullScreen      = false;
                engineCfg.EnableHDR       = false;
                engineCfg.RenderClass     = "nrenderer_d3d9";
                engineCfg.FileSystemClass = "nstd_file_system";
                engineCfg.EngineDataPkg   = "engine_data";
                // 设置File System根目录为包含EngineDataPkg的目录
                //engineCfg.FileSystemRoot = "/work/nexus_engine";
                DirectoryInfo DirInfo = new DirectoryInfo(".");
                DirectoryInfo DirIter = DirInfo.Parent;
                while (DirIter != null && engineCfg.FileSystemRoot == null)
                {
                    foreach (DirectoryInfo SubDir in DirIter.GetDirectories())
                    {
                        if (SubDir.Name == engineCfg.EngineDataPkg)
                        {
                            // 如果该目录的子目录中包含EngineDataPkg,则取该目录为FileSystemRoot
                            engineCfg.FileSystemRoot = DirIter.FullName;
                            break;
                        }
                    }
                    DirIter = DirIter.Parent;
                }
                if (engineCfg.FileSystemRoot == null)
                {
                    // 如果没有找到则设置缺省的目录
                    engineCfg.FileSystemRoot = DirInfo.Parent.FullName;
                }

                //--
                g_GameEngine.InitModules(engineCfg);

                //-- create Viewport
                form.CreateViewport();

                Application.Run(form);
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message, e.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }


            //-- close
            g_GameEngine.Close();
            g_GameEngine.Dispose();
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: yf885188/My3DEngine2008
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // 创建log
            NLogger.Instance.AddLogOutput(new NFileLogOutput("NexusEditor.log"));

            // 读取本地化配置
            NexusEditor.Properties.Resources.Culture = new CultureInfo(ConfigurationManager.AppSettings["Localization"]);

            SplashForm.StartSplash(NexusEditor.Properties.Resources.EditorSplash);

            try
            {
                engine = new NLevelEditorEngine();
                engine.InitCore();

                mainForm = new EditorMainForm();
                mainForm.CreateLogForm();

                //-- create engine config
                CustomConfigurationSection configuration = CustomConfigurationSection.Open();
                mainForm.ClientSize = new Size(configuration.EngineSetting.ClientWidth, configuration.EngineSetting.ClientHeight);
                NEngineConfig engineCfg = new NEngineConfig();
                engineCfg.RenderWndHandle    = mainForm.RenderPanelHandle;
                engineCfg.ClientWidth        = Screen.PrimaryScreen.Bounds.Width;
                engineCfg.ClientHeight       = Screen.PrimaryScreen.Bounds.Height;
                engineCfg.ColorBits          = configuration.EngineSetting.ColorBits;
                engineCfg.FullScreen         = configuration.EngineSetting.FullScreen;
                engineCfg.EnableHDR          = configuration.EngineSetting.EnableHDR;
                engineCfg.EnableSSAO         = configuration.EngineSetting.EnableSSAO;
                engineCfg.RenderClass        = configuration.EngineSetting.RenderClass;
                engineCfg.FileSystemClass    = configuration.EngineSetting.FileSystemClass;
                engineCfg.EngineDataPkg      = configuration.EngineSetting.EngineDataPkg;
                engineCfg.ResourceCacheClass = configuration.EngineSetting.ResourceCacheClass;
                engineCfg.ResourceIOClass    = configuration.EngineSetting.ResourceIOClass;
                engineCfg.FileSystemRoot     = configuration.EngineSetting.FileSystemRoot;
                if (string.IsNullOrEmpty(engineCfg.FileSystemRoot))
                {
                    engineCfg.FileSystemRoot = NFileSystem.DefaultFileSystemRoot;
                }

                //--
                NEditorConfig editorCfg = new NEditorConfig();
                editorCfg.actorEdClassAssembly = configuration.EditorEngineSetting.ActorEdClassAssembly;
                editorCfg.actorEditorClass     = configuration.EditorEngineSetting.ActorEditorClass;

                configuration.Save();

                engine.InitModules(engineCfg, editorCfg);
            }
            catch (System.Exception e)
            {
                ShowException(e, "Nexus Engine Init FAILED!");
                engine.Dispose();
                mainForm.Dispose();
                return;
            }

            try
            {
                //-- create default level
                engine.CreateMainLevel("defaultLevel");

                //-- create editor windows
                mainForm.CreateEditorForms();
                mainForm.CreateViewport();

                //-- open resrouce
                resourceForm = new ResourceEditorForm();

                SplashForm.CloseSplash();

                //-- run
                resourceForm.Show();
                mainForm.Show();
                mainForm.BringToFront();
                Application.Run(mainForm);
            }
            catch (System.Exception e)
            {
                ShowException(e, "Nexus Engine Exception!");
            }
            //-- close
            resourceForm.Close();
            engine.Close();
            engine.Dispose();

            NLogger.Instance.Clear();

            mainForm.Dispose();
        }