当前位置: 首页>>代码示例>>C#>>正文


C# Root.CreateRenderWindow方法代码示例

本文整理汇总了C#中Root.CreateRenderWindow方法的典型用法代码示例。如果您正苦于以下问题:C# Root.CreateRenderWindow方法的具体用法?C# Root.CreateRenderWindow怎么用?C# Root.CreateRenderWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Root的用法示例。


在下文中一共展示了Root.CreateRenderWindow方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public void Init()
        {
            // Create root object
             mRoot = new Root();

             // Define Resources
             ConfigFile cf = new ConfigFile();
             cf.Load("resources.cfg", "\t:=", true);
             ConfigFile.SectionIterator seci = cf.GetSectionIterator();
             String secName, typeName, archName;

             while (seci.MoveNext())
             {
            secName = seci.CurrentKey;
            ConfigFile.SettingsMultiMap settings = seci.Current;
            foreach (KeyValuePair<string, string> pair in settings)
            {
               typeName = pair.Key;
               archName = pair.Value;
               ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
            }
             }

             // Setup RenderSystem
             RenderSystem rs = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
             // or use "OpenGL Rendering Subsystem"
             mRoot.RenderSystem = rs;
             rs.SetConfigOption("Full Screen", "No");
             rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

             // Create Render Window
             mRoot.Initialise(false, "Main Ogre Window");
             NameValuePairList misc = new NameValuePairList();
             misc["externalWindowHandle"] = Handle.ToString();
             mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

             // Init resources
             TextureManager.Singleton.DefaultNumMipmaps = 5;
             ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

             // Create a Simple Scene
             SceneManager mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
             Camera cam = mgr.CreateCamera("Camera");
             cam.AutoAspectRatio = true;
             mWindow.AddViewport(cam);

             Entity ent = mgr.CreateEntity("ninja", "ninja.mesh");
             mgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent);

             cam.Position = new Vector3(0, 200, -400);
             cam.LookAt(ent.BoundingBox.Center);
        }
开发者ID:andyhebear,项目名称:mogresdk,代码行数:52,代码来源:Form1.cs

示例2: Init

        public void Init(String handle)
        {
            try
            {
                // Create root object
                mRoot = new Root();

                // Define Resources
                ConfigFile cf = new ConfigFile();
                cf.Load("./resources.cfg", "\t:=", true);
                ConfigFile.SectionIterator seci = cf.GetSectionIterator();
                String secName, typeName, archName;

                while (seci.MoveNext())
                {
                    secName = seci.CurrentKey;
                    ConfigFile.SettingsMultiMap settings = seci.Current;
                    foreach (KeyValuePair<string, string> pair in settings)
                    {
                        typeName = pair.Key;
                        archName = pair.Value;
                        ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                    }
                }

                //Load the resources from resources.cfg and selected tab (_ConfigurationPaths)
                //LoadResourceLocations(_ConfigurationPaths);

                //example of manual add: _FileSystemPaths.Add("../../Media/models");
                foreach (string foo in _ConfigurationPaths)
                {
                    AddResourceLocation(foo);
                }

                // Setup RenderSystem
                mRSys = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
                //mRSys = mRoot.GetRenderSystemByName("OpenGL Rendering Subsystem");

                // or use "OpenGL Rendering Subsystem"
                mRoot.RenderSystem = mRSys;

                mRSys.SetConfigOption("Full Screen", "No");
                mRSys.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

                // Create Render Window
                mRoot.Initialise(false, "Main Ogre Window");
                NameValuePairList misc = new NameValuePairList();
                misc["externalWindowHandle"] = handle;
                misc["FSAA"] = "4";
                // misc["VSync"] = "True"; //not sure how to enable vsync to remove those warnings in Ogre.log
                mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

                // Init resources
                MaterialManager.Singleton.SetDefaultTextureFiltering(TextureFilterOptions.TFO_ANISOTROPIC);
                TextureManager.Singleton.DefaultNumMipmaps = 5;
                ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

                // Create a Simple Scene
                //SceneNode node = null;
                // mMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC, "SceneManager");
                mMgr = mRoot.CreateSceneManager(SceneType.ST_EXTERIOR_CLOSE, "SceneManager");

                mMgr.AmbientLight = new ColourValue(0.8f, 0.8f, 0.8f);

                mCamera = mMgr.CreateCamera("Camera");
                mWindow.AddViewport(mCamera);

                mCamera.AutoAspectRatio = true;
                mCamera.Viewport.SetClearEveryFrame(false);

                //Entity ent = mMgr.CreateEntity(displayMesh, displayMesh);

                //ent.SetMaterialName(displayMaterial);
                //node = mMgr.RootSceneNode.CreateChildSceneNode(displayMesh + "node");
                //node.AttachObject(ent);

                mCamera.Position = new Vector3(0, 0, 0);
                //mCamera.Position = new Vector3(0, 0, -400);
                mCamera.LookAt(0, 0, 1);

                //Create a single point light source
                Light light2 = mMgr.CreateLight("MainLight");
                light2.Position = new Vector3(0, 10, -25);
                light2.Type = Light.LightTypes.LT_POINT;
                light2.SetDiffuseColour(1.0f, 1.0f, 1.0f);
                light2.SetSpecularColour(0.1f, 0.1f, 0.1f);

                mWindow.WindowMovedOrResized();

                IsInitialized = true;

                // Create the camera's top node (which will only handle position).
                cameraNode = mMgr.RootSceneNode.CreateChildSceneNode();
                cameraNode.Position = new Vector3(0, 0, 0);

                //cameraNode = mMgr->getRootSceneNode()->createChildSceneNode();
                //cameraNode->setPosition(0, 0, 500);

                // Create the camera's yaw node as a child of camera's top node.
                cameraYawNode = cameraNode.CreateChildSceneNode();
//.........这里部分代码省略.........
开发者ID:zinick,项目名称:Ogre3D-Level-Editor,代码行数:101,代码来源:OgreForm.cs

示例3: InitMogre

        public void InitMogre()
        {
            //-----------------------------------------------------
            // 1 enter ogre
            //-----------------------------------------------------
            root = new Root();

            //-----------------------------------------------------
            // 2 configure resource paths
            //-----------------------------------------------------
            ConfigFile cf = new ConfigFile();
            cf.Load("resources.cfg", "\t:=", true);

            // Go through all sections & settings in the file
            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            String secName, typeName, archName;

            // Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
            while (seci.MoveNext()) {
                secName = seci.CurrentKey;
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings) {
                    typeName = pair.Key;
                    archName = pair.Value;
                    ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                }
            }

            //-----------------------------------------------------
            // 3 Configures the application and creates the window
            //-----------------------------------------------------
            bool foundit = false;
            foreach (RenderSystem rs in root.GetAvailableRenderers()) {
                root.RenderSystem = rs;
                String rname = root.RenderSystem.Name;
                if (rname == "Direct3D9 Rendering Subsystem") {
                    foundit = true;
                    break;
                }
            }

            if (!foundit)
                return; //we didn't find it... Raise exception?

            //we found it, we might as well use it!
            root.RenderSystem.SetConfigOption("Full Screen", "No");
            root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour");

            root.Initialise(false);
            NameValuePairList misc = new NameValuePairList();
            misc["externalWindowHandle"] = hWnd.ToString();
            window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);
            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            //-----------------------------------------------------
            // 4 Create the SceneManager
            //
            //		ST_GENERIC = octree
            //		ST_EXTERIOR_CLOSE = simple terrain
            //		ST_EXTERIOR_FAR = nature terrain (depreciated)
            //		ST_EXTERIOR_REAL_FAR = paging landscape
            //		ST_INTERIOR = Quake3 BSP
            //-----------------------------------------------------
            sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
            sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);

            //-----------------------------------------------------
            // 5 Create the camera
            //-----------------------------------------------------
            camera = sceneMgr.CreateCamera("SimpleCamera");
            camera.Position = new Vector3(0f, 0f, 100f);
            // Look back along -Z
            camera.LookAt(new Vector3(0f, 0f, -300f));
            camera.NearClipDistance = 5;

            viewport = window.AddViewport(camera);
            viewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 1.0f);

            Entity ent = sceneMgr.CreateEntity("ogre", "ogrehead.mesh");
            SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("ogreNode");
            node.AttachObject(ent);
        }
开发者ID:andyhebear,项目名称:mogrelibrarys,代码行数:83,代码来源:MogreForm.cs

示例4: InitRenderer

        public void InitRenderer()
        {
            try
            {
                OgreRoot = new Root();

                {	//Load config file data
                    ConfigFile cf = new ConfigFile();
                    cf.Load("./resources.cfg", "\t:=", true);
                    ConfigFile.SectionIterator seci = cf.GetSectionIterator();
                    String secName, typeName, archName;

                    while (seci.MoveNext())
                    {
                        secName = seci.CurrentKey;
                        ConfigFile.SettingsMultiMap settings = seci.Current;
                        foreach (KeyValuePair<String, String> pair in settings)
                        {
                            typeName = pair.Key;
                            archName = pair.Value;
                            ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                        }
                    }
                }

                OgreRenderSystem = OgreRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
                OgreRenderSystem.SetConfigOption("Full Screen", "No");
                OgreRenderSystem.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

                OgreRoot.RenderSystem = OgreRenderSystem;
                OgreRoot.Initialise(false, "Main Ogre Window");

                NameValuePairList misc = new NameValuePairList();
                misc["externalWindowHandle"] = RenderPanel.Handle.ToString();
                misc["FSAA"] = "4";
                OgreRenderWindow = OgreRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

                OgreRenderWindow.IsActive = true;
                OgreRenderWindow.IsAutoUpdated = true;

                MaterialManager.Singleton.SetDefaultTextureFiltering(TextureFilterOptions.TFO_ANISOTROPIC);

                //Trigger background resource load
                StartResourceThread();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error during renderer initialization:" + ex.Message + "," + ex.StackTrace);
            }
        }
开发者ID:Jerdak,项目名称:OgreWpf,代码行数:50,代码来源:Window1.xaml.cs

示例5: InitMogre

        public void InitMogre()
        {
            root = new Root();
            #if DEBUG
            root.LoadPlugin("RenderSystem_Direct3D9_d");
            #else
            root.LoadPlugin("RenderSystem_Direct3D9");
            #endif

            bool foundit = false;
            foreach (RenderSystem rs in root.GetAvailableRenderers())
            {
                root.RenderSystem = rs;
                String rname = root.RenderSystem.Name;
                if (rname == "Direct3D9 Rendering Subsystem")
                {
                    foundit = true;
                    break;
                }
            }

            if (!foundit)
                return; //we didn't find it... Raise exception?

            //we found it, we might as well use it!
            root.RenderSystem.SetConfigOption("Full Screen", "No");
            root.RenderSystem.SetConfigOption("Video Mode",
                String.Format("{0} x {1} @ 32-bit colour", windowSize.Width, windowSize.Height));

            root.Initialise(false);

            // other plugins
            #if DEBUG
            root.LoadPlugin("Plugin_CgProgramManager_d");
            root.LoadPlugin("Plugin_OctreeSceneManager_d");

            #else
            root.LoadPlugin("Plugin_CgProgramManager");
            root.LoadPlugin("Plugin_OctreeSceneManager");
            #endif

            NameValuePairList misc = new NameValuePairList();
            misc["externalWindowHandle"] = hWnd.ToString();
            window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);

            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
            sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);

            camera = sceneMgr.CreateCamera("SimpleCamera");
            camera.NearClipDistance = 0.1f;
            camera.AutoAspectRatio = true;

            viewport = window.AddViewport(camera);
            viewport.BackgroundColour = new ColourValue(0.25f, 0.25f, 0.25f, 1.0f);

            root.FrameStarted += new FrameListener.FrameStartedHandler(MogreFrameStarted);
        }
开发者ID:realmzero,项目名称:RZModelViewer,代码行数:59,代码来源:OgreWindow.cs

示例6: CreateWindow

		/// <summary>
		/// Creates the window.
		/// </summary>
		/// <param name="root">The root.</param>
		protected virtual void CreateWindow(Root root)
		{
			Configuration config = Configuration;

			RenderWindow window;

			if (Configuration.Ogre.UseOgreConfig) {
				if (!root.RestoreConfig()) {
					if (!root.ShowConfigDialog()) {
						Console.WriteLine("Could not show the config dialog for Ogre");
						Exit();
						return;
					}

					root.SaveConfig();
				}

				window = root.Initialize(true, Configuration.Game.Name);
			} else {
				if (config.Ogre.RenderWindowParameters != null) {
					Dictionary<string, string> parameters = config.Ogre.RenderWindowParameters.ToDictionary(
						item => item.Name,
						item => item.Value);

					window = root.CreateRenderWindow(
						"OgreRoot",
						config.Screen.Width,
						config.Screen.Height,
						config.Screen.Fullscreen,
						new RenderWindowParameters(parameters));
				} else {
					window = root.CreateRenderWindow(
						"OgreRoot",
						config.Screen.Width,
						config.Screen.Height,
						config.Screen.Fullscreen);
				}
			}

			Variables.Ogre.RenderWindow = window;
		}
开发者ID:HaKDMoDz,项目名称:InVision,代码行数:45,代码来源:GameApplication.cs

示例7: _InitOgre

        protected bool _InitOgre()
        {
            lock (this)
            {
                IntPtr hWnd = IntPtr.Zero;

                foreach (PresentationSource source in PresentationSource.CurrentSources)
                {
                    var hwndSource = (source as HwndSource);
                    if (hwndSource != null)
                    {
                        hWnd = hwndSource.Handle;
                        break;
                    }
                }

                if (hWnd == IntPtr.Zero) return false;

                CallResourceItemLoaded(new ResourceLoadEventArgs("Engine", 0));

                // load the OGRE engine
                //
                _root = new Root();

                // configure resource paths from : "resources.cfg" file
                //
                var configFile = new ConfigFile();
                configFile.Load("resources.cfg", "\t:=", true);

                // Go through all sections & settings in the file
                //
                ConfigFile.SectionIterator seci = configFile.GetSectionIterator();

                // Normally we would use the foreach syntax, which enumerates the values,
                // but in this case we need CurrentKey too;
                while (seci.MoveNext())
                {
                    string secName = seci.CurrentKey;

                    ConfigFile.SettingsMultiMap settings = seci.Current;
                    foreach (var pair in settings)
                    {
                        string typeName = pair.Key;
                        string archName = pair.Value;
                        ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                    }
                }

                // Configures the application and creates the Window
                // A window HAS to be created, even though we'll never use it.
                //
                bool foundit = false;
                foreach (RenderSystem rs in _root.GetAvailableRenderers())
                {
                    if (rs == null) continue;

                    _root.RenderSystem = rs;
                    String rname = _root.RenderSystem.Name;
                    if (rname == "Direct3D9 Rendering Subsystem")
                    {
                        foundit = true;
                        break;
                    }
                }

                if (!foundit)
                    return false;

                _root.RenderSystem.SetConfigOption("Full Screen", "No");
                _root.RenderSystem.SetConfigOption("Video Mode", "1024 x 768 @ 32-bit colour");

                _root.Initialise(false);

                var misc = new NameValuePairList();
                misc["externalWindowHandle"] = hWnd.ToString();
                _renderWindow = _root.CreateRenderWindow("OgreImageSource Windows", 0, 0, false, misc);
                _renderWindow.IsAutoUpdated = false;

                InitResourceLoad();
                ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

                this.Dispatcher.Invoke(
                    (MethodInvoker)delegate
                                       {
                                           if (CreateDefaultScene)
                                           {
                                               //-----------------------------------------------------
                                               // 4 Create the SceneManager
                                               //
                                               //		ST_GENERIC = octree
                                               //		ST_EXTERIOR_CLOSE = simple terrain
                                               //		ST_EXTERIOR_FAR = nature terrain (depreciated)
                                               //		ST_EXTERIOR_REAL_FAR = paging landscape
                                               //		ST_INTERIOR = Quake3 BSP
                                               //-----------------------------------------------------
                                               _sceneManager = _root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
                                               _sceneManager.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);

                                               //-----------------------------------------------------
                                               // 5 Create the camera
//.........这里部分代码省略.........
开发者ID:andyhebear,项目名称:esdogre,代码行数:101,代码来源:OgreImage.cs

示例8: init

            public bool init()
            {
                // Start with a new root to get this party started
                root = new Root();

                // Configuration buisness
                ConfigFile config = new ConfigFile();
                config.Load("resources.cfg", "\t:=", true);

                // Go through all our configuration settings
                ConfigFile.SectionIterator itor = config.GetSectionIterator();
                string secName, typeName, archName;

                // Move through all of the sections
                while (itor.MoveNext())
                {
                  secName = itor.CurrentKey;
                  ConfigFile.SettingsMultiMap settings = itor.Current;
                  foreach (KeyValuePair<string, string> pair in settings)
                  {
                typeName = pair.Key;
                archName = pair.Value;
                ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                  }
                }

                // Configure our window and set up the RenderSystem
                bool found = false;
                foreach (RenderSystem rs in root.GetAvailableRenderers())
                {
                  root.RenderSystem = rs;
                  string rname = root.RenderSystem.Name;
                  if (rname == "Direct3D9 Rendering Subsystem")
                  {
                found = true;
                break;
                  }
                }

                // If we can't find the DirectX rendering system somethign is seriously wrong
                if (!found)
                  return false;

                root.RenderSystem.SetConfigOption("Full Screen", "No");
                root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour");

                root.Initialise(false);
                NameValuePairList misc = new NameValuePairList();
                misc["externalWindowHandle"] = hWnd.ToString();
                window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc);
                ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

                // Create our SceneManager
                sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
                sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);
                sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE;

                // Create the camera
                camMgr = new CamManager();
                camMgr.Initialize(ref sceneMgr);

                viewport = window.AddViewport(camMgr.mainCam);
                viewport.BackgroundColour = new ColourValue(0, 0, 0, 1);

                // Load our stick here
                LoadModel("TEStick.mesh");

                // Set up ground
                Plane plane = new Plane(Mogre.Vector3.UNIT_Y, 0);
                MeshManager.Singleton.CreatePlane("ground", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane,
                  1500, 1500, 20, 20, true, 1, 5, 5, Mogre.Vector3.UNIT_Z);
                Entity ground = sceneMgr.CreateEntity("GroundEnt", "ground");
                sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(ground);

                ground.SetMaterialName("Examples/Rockwall");
                ground.CastShadows = false;

                // Set up some lights
                Light pointLight = sceneMgr.CreateLight("pointLight");
                pointLight.Type = Light.LightTypes.LT_POINT;
                pointLight.Position = new Mogre.Vector3(0, 150, 250);
                pointLight.DiffuseColour = ColourValue.White;
                pointLight.SpecularColour = ColourValue.White;

                Light directionalLight = sceneMgr.CreateLight("directionalLight");
                directionalLight.Type = Light.LightTypes.LT_DIRECTIONAL;
                directionalLight.DiffuseColour = new ColourValue(.25f, .25f, 0);
                directionalLight.SpecularColour = new ColourValue(.25f, .25f, 0);
                directionalLight.Direction = new Mogre.Vector3(0, -1, 1);

                Light spotLight = sceneMgr.CreateLight("spotLight");
                spotLight.Type = Light.LightTypes.LT_SPOTLIGHT;
                spotLight.DiffuseColour = ColourValue.White;
                spotLight.SpecularColour = ColourValue.White;
                spotLight.Direction = new Mogre.Vector3(-1, -1, 0);
                spotLight.Position = new Mogre.Vector3(300, 300, 0);
                spotLight.SetSpotlightRange(new Degree(35), new Degree(50));

                // Set up our Input
                root.FrameRenderingQueued += new FrameListener.FrameRenderingQueuedHandler(Input);
//.........这里部分代码省略.........
开发者ID:aczarno,项目名称:StickMagik,代码行数:101,代码来源:OgreForm.cs


注:本文中的Root.CreateRenderWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。