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); // Set up for picking raySceneQuery = sceneMgr.CreateRayQuery(new Ray(), SceneManager.WORLD_GEOMETRY_TYPE_MASK); if (null == raySceneQuery) return false; raySceneQuery.SetSortByDistance(true); return true; }