/// Method which will define the source of resources (other than current folder) public virtual void SetupResources() { if (System.IO.File.Exists("resources.cfg") == false) { return; } // Load resource paths from config file 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); } } }
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); }
public bool Initiliase(bool autoCreateWindow) { root = new Root(); 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 //----------------------------------------------------- string renderSystem = "Direct3D9 Rendering Subsystem"; if (!FindRenderSystem(renderSystem)) { throw new Exception("Unable to find render system: " + renderSystem); } //we found it, we might as well use it! root.RenderSystem.SetConfigOption("VSync", "Yes"); // graphics card doesn't work so hard, physics engine should be more stable root.RenderSystem.SetConfigOption("Full Screen", "No"); root.RenderSystem.SetConfigOption("Video Mode", "1024 x 768 @ 32-bit colour"); // scene manager sceneManager = root.CreateSceneManager(SceneType.ST_GENERIC); // render window this.renderWindow = root.Initialise(autoCreateWindow, "GlueEngine"); return(true); }
protected virtual void SetupResources() { using (var configFile = new ConfigFile()) { configFile.Load(_fileSystemLayer.GetConfigFilePath("resources.cfg")); ConfigFile.SectionIterator sectionIterator = configFile.GetSectionIterator(); while (sectionIterator.MoveNext()) { string currentKey = sectionIterator.CurrentKey; foreach (var pair in sectionIterator.Current) { ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, currentKey); } } } }
protected virtual void InitResources() { ConfigFile file = new ConfigFile(); file.Load("resources.cfg", "\t:=", true); ConfigFile.SectionIterator sectionIterator = file.GetSectionIterator(); while (sectionIterator.MoveNext()) { string currentKey = sectionIterator.CurrentKey; foreach (KeyValuePair <string, string> pair in sectionIterator.Current) { string key = pair.Key; string name = pair.Value; ResourceGroupManager.Singleton.AddResourceLocation(name, key, currentKey); } } }
/// <summary> /// Initializes the resources which the program uses. /// </summary> protected virtual void InitResources() { 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); } } }
public MogreRenderer(String handle, uint width, uint height) { _root = new Root("../plugins.cfg", "../ogre.cfg", "../flexrender.log"); _root.RenderSystem = _root.GetRenderSystemByName("Direct3D9 Rendering Subsystem"); _root.Initialise(false); ConfigFile file = new ConfigFile(); file.Load("../resources.cfg", "\t:=", true); ConfigFile.SectionIterator secIter = file.GetSectionIterator(); while (secIter.MoveNext()) { String secName = secIter.CurrentKey; if (secIter.Current.IsEmpty) { continue; } foreach (var entry in secIter.Current) { ResourceGroupManager.Singleton.AddResourceLocation(entry.Value, entry.Key, secName); } ResourceGroupManager.Singleton.InitialiseResourceGroup(secName); } _timer = new Timer(); NameValuePairList config = new NameValuePairList(); config["externalWindowHandle"] = handle; /* * config["vsync"] = "False"; * config["FSAA"] = "2"; * config["Multithreaded"] = "False"; */ _renderWindow = _root.CreateRenderWindow("Mogre Window", width, height, false, config); _renderWindow.IsAutoUpdated = false; }
/// <summary> /// Process the config file and add all the proper resource locations /// </summary> private void DefineResources() { // load the configuration file ConfigFile cf = new ConfigFile(); cf.Load(RESOURCE_FILE, "\t:=", true); // process each section in the configuration file ConfigFile.SectionIterator itr = cf.GetSectionIterator(); while (itr.MoveNext()) { string sectionName = itr.CurrentKey; ConfigFile.SettingsMultiMap smm = itr.Current; // each section is set of key/value pairs // value is the resource type (FileSystem, Zip, etc) // key is the location of the resource set foreach (KeyValuePair <string, string> kv in smm) { // add the resource location to Ogre ResourceGroupManager.Singleton.AddResourceLocation(kv.Value, kv.Key, sectionName); } } }
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 //----------------------------------------------------- _camera = _sceneManager.CreateCamera("DefaultCamera"); _camera.Position = new Vector3(0f, 0f, 500f); // Look back along -Z _camera.LookAt(lockat); _camera.NearClipDistance = 5; _camera.FarClipDistance = 3000f; } //初始化平面 PublicPlane.normal = Vector3.UNIT_Z; PublicPlane.d = 0; IsFrontBufferAvailableChanged += _isFrontBufferAvailableChanged; if (Initialised != null) { Initialised(this, new RoutedEventArgs()); } ReInitRenderTarget(); AttachRenderTarget(true); OnFrameRateChanged(this.FrameRate); _currentThread = null; }); return(true); } }
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"); //RenderSystem rs = mRoot.GetRenderSystemByName("OpenGL Rendering Subsystem"); mRoot.RenderSystem = rs; rs.SetConfigOption("Full Screen", "No"); rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour"); // Create Render Window (inside PictureBox) mRoot.Initialise(false, "Main Ogre Window"); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = OgreBox.Handle.ToString(); // Handle.ToString(); misc["FSAA"] = "2"; // anti aliasing factor (0, 2, 4 ...) misc["vsync"] = "true"; // by Ogre default: false mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); // Init resources TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); // Create a Simple Scene mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC); cam = mgr.CreateCamera("Camera"); cam.AutoAspectRatio = true; cam.FarClipDistance = float.MaxValue; cam.NearClipDistance = 0.01f; mWindow.AddViewport(cam); CreateScene(); try { // Start the Camera Manager manager = new CameraMan(cam); // Start the network listener = new NetworkListener(this); } catch (Exception e) { MessageBox.Show(this, "Exception:\n\n" + e.Message + "\n\n" + e.GetBaseException().ToString()); } }
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(1f, 1f, 1f); //----------------------------------------------------- // 5 Create the camera //----------------------------------------------------- camera = sceneMgr.CreateCamera("SimpleCamera"); camera.Position = new Vector3(400f, 0f, 0f); // Look back along -Z camera.LookAt(new Vector3(-1f, 0f, 0f)); camera.NearClipDistance = 5; viewport = window.AddViewport(camera); viewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 1.0f); material = MaterialManager.Singleton.Create("front", "General"); material.GetTechnique(0).GetPass(0).CreateTextureUnitState("snow3.jpg"); material = MaterialManager.Singleton.Create("other", "General"); material.GetTechnique(0).GetPass(0).CreateTextureUnitState("snow.jpg"); material = MaterialManager.Singleton.Create("back", "General"); material.GetTechnique(0).GetPass(0).CreateTextureUnitState("back2.jpg"); Vector3 moveVector3 = new Vector3(0f, -60f, 110f); for (int i = 0; i < cubeCount; i++) { Cube cube = new Cube(); cube.CubeName = "cube" + i.ToString(); cube.BuildCube("front", ref sceneMgr); ManualObject manual = sceneMgr.GetManualObject(cube.CubeName); manual.ConvertToMesh("cubeMesh" + i.ToString()); Entity ent = sceneMgr.CreateEntity("box" + i.ToString(), "cubeMesh" + i.ToString()); SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("boxNode" + i.ToString()); ent.CastShadows = true; node.AttachObject(ent); float y = i * (Cube.cubeHeight + 10) + moveVector3.y; node.Position = new Vector3(0f, y, moveVector3.z); } Plane plane = new Plane(); plane.BuildPlane("back", ref sceneMgr); ManualObject manualPlane = sceneMgr.GetManualObject(plane.PlaneName); manualPlane.ConvertToMesh("planeMesh"); Entity planeEntity = sceneMgr.CreateEntity("planeEntity", "planeMesh"); SceneNode planeNode = sceneMgr.RootSceneNode.CreateChildSceneNode("planeNode"); planeNode.AttachObject(planeEntity); }
public void Initialise() { Root = new Root(); ConfigFile cf = new ConfigFile(); cf.Load("Resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); while (seci.MoveNext()) { ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair <string, string> pair in settings) { ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey); } } if (!Root.RestoreConfig()) { if (!Root.ShowConfigDialog()) { return; } } Root.RenderSystem.SetConfigOption("VSync", "Yes"); RenderWindow = Root.Initialise(true, "WorldCreator"); // @@@@@@@@@@@@@@@ Nazwa okna gry. ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC); Camera = SceneManager.CreateCamera("MainCamera"); Viewport = RenderWindow.AddViewport(Camera); Camera.NearClipDistance = 0.1f; Camera.FarClipDistance = 1000.0f; Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height); MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; RenderWindow.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); InputManager = MOIS.InputManager.CreateInputSystem(pl); Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false); Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, false); NewtonWorld = new World(); NewtonDebugger = new Debugger(NewtonWorld); NewtonDebugger.Init(SceneManager); ObjectManager = new ObjectManager(); MaterialManager = new MaterialManager(); MaterialManager.Initialise(); //CharacterProfileManager = new CharacterProfileManager(); Items = new Items(); //PrizeManager = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ //Quests = new Quests(); //NPCManager = new NPCManager(); Labeler = new TextLabeler(5); User = new Player(); CharacterProfileManager = new CharacterProfileManager(); NPCManager = new NPCManager(); HumanController = new HumanController(); TypedInput = new TypedInput(); //SoundManager = new SoundManager(); }
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); }
private void init3D() { Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath)); // 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"); 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"] = picRender.Handle.ToString(); mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); // Init resources TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); // Create a Simple Scene mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC, "MainMgr"); Camera cam = mgr.CreateCamera("Camera"); //cam.PolygonMode = PolygonMode.PM_WIREFRAME; cam.AutoAspectRatio = true; mWindow.AddViewport(cam); cam.Position = new Vector3(0, 0, 200); cam.LookAt(new Vector3(0, 0, 0)); cam.ProjectionType = ProjectionType.PT_ORTHOGRAPHIC; //cam.OrthoWindowHeight = 400; cam.OrthoWindowWidth = 650; ManualObject manual = mgr.CreateManualObject("canvas"); manual.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_STRIP); manual.Position(-300.0f, -200.0f, 0.0f); // start position manual.Position(300.0f, -200.0f, 0.0f); // draw first line manual.Position(300.0f, 200.0f, 0.0f); manual.Position(-300.0f, 200.0f, 0.0f); manual.Position(-300.0f, -200.0f, 0.0f); // draw fourth line manual.End(); mgr.RootSceneNode.CreateChildSceneNode().AttachObject(manual); mWindow.GetViewport(0).BackgroundColour = new ColourValue(0.5f, 0.5f, 0.5f); }
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(); // Create the camera's pitch node as a child of camera's yaw node. cameraPitchNode = cameraYawNode.CreateChildSceneNode(); // Create the camera's roll node as a child of camera's pitch node // and attach the camera to it. cameraRollNode = cameraPitchNode.CreateChildSceneNode(); cameraRollNode.AttachObject(mCamera); mRaySceneQuery = mMgr.CreateRayQuery(new Ray()); } catch (Exception ex) { Console.WriteLine("[Error,OgreForm.cs]: " + ex.Message + "," + ex.StackTrace); } }
public void Initialise() { Root = new Root(); ConfigFile cf = new ConfigFile(); cf.Load("Resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); while (seci.MoveNext()) { ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair <string, string> pair in settings) { ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey); } } if (!Root.RestoreConfig()) { if (!Root.ShowConfigDialog()) { return; } } Root.RenderSystem.SetConfigOption("VSync", "Yes"); RenderWindow = Root.Initialise(true, "Kolejny epicki erpeg"); // @@@@@@@@@@@@@@@ Nazwa okna gry. ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC); Camera = SceneManager.CreateCamera("MainCamera"); Viewport = RenderWindow.AddViewport(Camera); Camera.NearClipDistance = 0.1f; Camera.FarClipDistance = 1000.0f; Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height); MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; RenderWindow.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); InputManager = MOIS.InputManager.CreateInputSystem(pl); Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true); Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, true); NewtonWorld = new World(); NewtonDebugger = new Debugger(NewtonWorld); NewtonDebugger.Init(SceneManager); GameCamera = new GameCamera(); ObjectManager = new ObjectManager(); MaterialManager = new MaterialManager(); MaterialManager.Initialise(); Items = new Items(); PrizeManager = new PrizeManager(); //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ CharacterProfileManager = new CharacterProfileManager(); Quests = new Quests(); NPCManager = new NPCManager(); Labeler = new TextLabeler(5); Random = new Random(); HumanController = new HumanController(); TypedInput = new TypedInput(); SoundManager = new SoundManager(); Dialog = new Dialog(); Mysz = new MOIS.MouseState_NativePtr(); Conversations = new Conversations(); TriggerManager = new TriggerManager(); Engine.Singleton.Keyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(TypedInput.onKeyPressed); Mouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(MouseReleased); IngameConsole = new IngameConsole(); IngameConsole.Init(); IngameConsole.AddCommand("dupa", "soundOddawajPiec"); IngameConsole.AddCommand("tp", "ZejscieDoPiwnicy"); IngameConsole.AddCommand("exit", "Exit", "Wychodzi z gry. Ale odkrywcze. Super. Musze sprawdzic jak sie zachowa konsola przy duzej dlugosci linii xD llllllllllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmiiiiiiiiiiiiiiii"); IngameConsole.AddCommand("play", "playSound", "Odtwarza dzwiek. Skladnia: play <sciezka do pliku>. Np. play other/haa.mp3"); IngameConsole.AddCommand("map", "ChangeMap"); IngameConsole.AddCommand("save", "SaveGame"); IngameConsole.AddCommand("load", "LoadGame"); IngameConsole.AddCommand("help", "ConsoleHelp"); IngameConsole.AddCommand("h", "CommandHelp"); }
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("../plugins.cfg", "../ogre.cfg", "../flexrender.log"); _root.RenderSystem = _root.GetRenderSystemByName("Direct3D9Ex Rendering Subsystem"); // 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); } } _root.RenderSystem.SetConfigOption("Full Screen", "No"); _root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour"); _root.Initialise(false); var misc = new NameValuePairList(); misc["externalWindowHandle"] = hWnd.ToString(); misc["vsync"] = "False"; misc["FSAA"] = "2"; misc["Multithreaded"] = "False"; _renderWindow = _root.CreateRenderWindow("OgreImageSource Windows", 0, 0, false, misc); _renderWindow.IsAutoUpdated = false; //InitResourceLoad(); ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); Dispatcher.Invoke( (MethodInvoker) delegate { IsFrontBufferAvailableChanged += _isFrontBufferAvailableChanged; _sceneManager = _root.CreateSceneManager(SceneType.ST_GENERIC); if (Initialised != null) { Initialised(this, new RoutedEventArgs()); } ReInitRenderTarget(); AttachRenderTarget(true); OnFrameRateChanged(this.FrameRate); _currentThread = null; }); return(true); } }
public bool initOgre(String wndTitle) { LogManager logMgr = new LogManager(); m_pLog = LogManager.Singleton.CreateLog("OgreLogfile.log", true, true, false); m_pLog.SetDebugOutputEnabled(true); m_pRoot = new Root(); if (!m_pRoot.ShowConfigDialog()) { return(false); } m_pRenderWnd = m_pRoot.Initialise(true, wndTitle); m_pViewport = m_pRenderWnd.AddViewport(null); ColourValue cv = new ColourValue(0.5f, 0.5f, 0.5f); m_pViewport.BackgroundColour = cv; m_pViewport.Camera = null; int hWnd = 0; //ParamList paramList; m_pRenderWnd.GetCustomAttribute("WINDOW", out hWnd); m_pInputMgr = InputManager.CreateInputSystem((uint)hWnd); m_pKeyboard = (MOIS.Keyboard)m_pInputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true); m_pMouse = (MOIS.Mouse)m_pInputMgr.CreateInputObject(MOIS.Type.OISMouse, true); m_pMouse.MouseMoved += new MouseListener.MouseMovedHandler(mouseMoved); m_pMouse.MousePressed += new MouseListener.MousePressedHandler(mousePressed); m_pMouse.MouseReleased += new MouseListener.MouseReleasedHandler(mouseReleased); m_pKeyboard.KeyPressed += new KeyListener.KeyPressedHandler(keyPressed); m_pKeyboard.KeyReleased += new KeyListener.KeyReleasedHandler(keyReleased); MOIS.MouseState_NativePtr mouseState = m_pMouse.MouseState; mouseState.width = m_pViewport.ActualWidth; mouseState.height = m_pViewport.ActualHeight; //m_pMouse.MouseState = tempMouseState; String secName, typeName, archName; ConfigFile cf = new ConfigFile(); cf.Load("resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); 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); } } TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); m_pTrayMgr = new SdkTrayManager("AOFTrayMgr", m_pRenderWnd, m_pMouse, null); m_pTimer = new Timer(); m_pTimer.Reset(); m_pRenderWnd.IsActive = true; return(true); }