protected virtual void ChooseSceneManager() { sceneMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC); camera = sceneMgr.CreateCamera("Camera"); camera.Position = new Vector3(0, 0, 150); camera.LookAt(Vector3.ZERO); mViewport = mRenderWindow.AddViewport(camera); }
private void InitializeViewports() { // Create viewports array m_viewport = new Viewport[2]; // Left viewport m_viewport[0] = m_renderWindow.AddViewport(m_camera[0], 0.0f, 0, 0.5f, 1.0f, 0); //m_viewport[0].BackgroundColor = ColorEx.Red; // Right viewport m_viewport[1] = m_renderWindow.AddViewport(m_camera[1], 0.45f, 0, 0.5f, 1.0f, 1); //m_viewport[1].BackgroundColor = ColorEx.CornflowerBlue; }
public void OnLoad() { ResourceGroupManager.Instance.AddResourceLocation("media", "Folder", true); //_scene = _engine.CreateSceneManager("DefaultSceneManager", "DefaultSM"); //_scene.ClearScene(); _scene = Root.Instance.CreateSceneManager(SceneType.ExteriorClose); _scene.LoadWorldGeometry("SampleOFS.xml"); _camera = _scene.CreateCamera("MainCamera"); // _camera.Position = new Vector3(0, 170, 300); // x=right/left from screen,y=bottom/up from screen,z=in/out from scren _camera.LookAt(Vector3.Zero); //The clipping distance of a Camera specifies how close or far something can be before you no longer see it. _camera.Near = 5; _camera.AutoAspectRatio = true; var vp = _window.AddViewport(_camera, 0, 0, 1.0f, 1.0f, 100); vp.BackgroundColor = ColorEx.CornflowerBlue; ResourceGroupManager.Instance.InitializeAllResourceGroups(); }
protected void CreateViewports() { Viewport viewport = mRenderWindow.AddViewport(mCamera); viewport.BackgroundColour = ColourValue.Blue; mCamera.AspectRatio = (float)viewport.ActualWidth / viewport.ActualHeight; }
/// <summary> /// Creates dummy scene to allow rendering GUI in viewport. /// </summary> protected virtual void CreateDummyScene() { RenderWindow.RemoveAllViewports(); SceneManager sm = Root.CreateSceneManager(SceneType.Generic, "DummyScene"); Camera cam = sm.CreateCamera("DummyCamera"); Viewport vp = RenderWindow.AddViewport(cam); }
public void OnLoad() { var dir = Directory.GetCurrentDirectory(); ResourceGroupManager.Instance.AddResourceLocation(dir, "Folder"); //MaterialManager.Instance.Initialize(); _scene = _root.CreateSceneManager("DefaultSceneManager", "SLSharpInstance"); _scene.ClearScene(); Bindings.Axiom.SLSharp.Init(); Shader.DebugMode = true; //Shader.DebugMode = true; _clipmap = new Clipmap(_scene); RecalcHeight(); _camera = _scene.CreateCamera("MainCamera"); _camera.Position = new Vector3(0, 0, 5); _camera.LookAt(Vector3.Zero); _camera.Near = 0.001f; _camera.Far = 20.0f; _camera.AutoAspectRatio = true; var vp = _window.AddViewport(_camera); vp.BackgroundColor = ColorEx.CornflowerBlue; }
public App() { mRoot = new Root(String.Format("plugins-{0}.cfg", GetOS())); Initialiser.SetupResources("resources.cfg"); mRoot.ShowConfigDialog(); mRenderWindow = mRoot.Initialise(true); mSceneManager = mRoot.CreateSceneManager((UInt16)SceneType.Generic, "ExampleSMInstance"); mCamera = mSceneManager.CreateCamera("MainCamera"); mCamera.Position = new Math3D.Vector3(150, 150, 150); mCamera.LookAt(new Math3D.Vector3(0, 0, 0)); mCamera.NearClipDistance = 5; mViewport = mRenderWindow.AddViewport(mCamera); mViewport.BackgroundColor = Color.Blue; mCamera.AspectRatio = (float)mViewport.ActualWidth / (float)mViewport.ActualHeight; TextureManager.Instance.SetDefaultNumMipmaps(5); ResourceGroupManager.getSingleton().initialiseAllResourceGroups(); mSceneManager.AmbientLightColor = Color.FromArgb(125, 125, 125, 125); mSceneManager.SetSkyBox(true, "Examples/SpaceSkyBox", 50); mLight = mSceneManager.CreateLight("MainLight"); mLight.Position = new Math3D.Vector3(20, 80, 50); mEntity = mSceneManager.CreateEntity("razor", "razor.mesh"); mSceneManager.RootSceneNode.AttachObject(mEntity); // TODO: enabling this causes a crash: // mSceneManager.RootSceneNode.CreateChildSceneNode(new Math3D.Vector3(0.0f, 6.5f, -67.0f)).AttachObject(mParticleSystem); }
protected virtual void CreateViewports() { Debug.Assert(window != null, "Attempting to use a null RenderWindow."); // create a new viewport and set it's background color viewport = window.AddViewport(camera, 0, 0, 1.0f, 1.0f, 100); viewport.BackgroundColor = ColorEx.Black; }
public bool Initiliase(IntPtr windowHandle) { if (windowHandle == IntPtr.Zero) { // auto create the window if (!Initiliase(true)) { return(false); } } else { // we'll create the window if (!Initiliase(false)) { return(false); } // manual creation of render window this.renderWindow = this.CreateRenderWindow(windowHandle, "DefaultRenderWindow"); } // camera this.camera = sceneManager.CreateCamera("DefaultCamera"); this.camera.NearClipDistance = 0.1f; // viewport this.viewport = renderWindow.AddViewport(camera); this.viewport.BackgroundColour = ColourValue.Black; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); return(true); }
public void OnLoad() { var dir = Directory.GetCurrentDirectory(); ResourceGroupManager.Singleton.AddResourceLocation(dir, "FileSystem"); MaterialManager.Singleton.Initialise(); _scene = _root.CreateSceneManager("DefaultSceneManager", "SLSharpInstance"); _scene.ClearScene(); Bindings.MOGRE.SLSharp.Init(); Shader.DebugMode = true; //Shader.DebugMode = true; _clipmap = new Clipmap(_scene); RecalcHeight(); _camera = _scene.CreateCamera("MainCamera"); _camera.Position = new Vector3(0, 0, 5); _camera.LookAt(Vector3.ZERO); _camera.NearClipDistance = 0.001f; _camera.FarClipDistance = 20.0f; _camera.AutoAspectRatio = true; var vp = _window.AddViewport(_camera); vp.BackgroundColour = ColourValue.Blue; }
private void CreateViewports() { // Create one viewport, entire window viewport = window.AddViewport(camera); viewport.BackgroundColour = new ColourValue(0, 0, 0); // Alter the camera aspect ratio to match the viewport camera.AspectRatio = ((float)viewport.ActualWidth) / ((float)viewport.ActualHeight); }
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); }
/// <summary> /// Creates a viewport using mCamera /// </summary> protected virtual void CreateViewports() { // Create one viewport, entire window Viewport vp = m_renderWindow.AddViewport(m_camera); vp.BackgroundColor = ColorEx.Black; // Alter the camera aspect ratio to match the viewport m_camera.AspectRatio = vp.ActualWidth / vp.ActualHeight; }
protected virtual void CreateViewports() { // Create one viewport, entire window var vp = mWindow.AddViewport(mCamera); vp.BackgroundColour = ColourValue.Black; // Alter the camera aspect ratio to match the viewport mCamera.AspectRatio = (vp.ActualWidth / vp.ActualHeight); }
/************************************************************************/ /* start up ogre manager */ /************************************************************************/ internal bool Startup() { // check if already initialized if (mRoot != null) { return(false); } // create ogre root mRoot = new Root("plugins.cfg", "settings.cfg", "mogre.log"); // set directx render system RenderSystem renderSys = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem"); mRoot.RenderSystem = renderSys; // register event to get notified when application lost or regained focus mRoot.RenderSystem.EventOccurred += OnRenderSystemEventOccurred; // initialize engine mRoot.Initialise(false); // optional parameters NameValuePairList parm = new NameValuePairList(); parm["vsync"] = "true"; // create window mWindow = mRoot.CreateRenderWindow("Mogre Quickstart 2010", 800, 600, false, parm); // create scene manager mSceneMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC, "DefaultSceneManager"); // create default camera mCamera = mSceneMgr.CreateCamera("DefaultCamera"); mCamera.AutoAspectRatio = true; mCamera.NearClipDistance = 1.0f; mCamera.FarClipDistance = 1000.0f; // create default viewport mViewport = mWindow.AddViewport(mCamera); // create resource manager and initialize it mResourceMgr = new ResourceManager(); if (!mResourceMgr.Startup("resources.cfg")) { return(false); } // set rendering active flag mRenderingActive = true; // OK return(true); }
public void OnLoad() { var dir = Directory.GetCurrentDirectory(); ResourceGroupManager.Singleton.AddResourceLocation(dir, "FileSystem"); MaterialManager.Singleton.Initialise(); _scene = _root.CreateSceneManager("DefaultSceneManager", "SLSharpInstance"); _scene.ClearScene(); Bindings.MOGRE.SLSharp.Init(); Shader.DebugMode = true; //Shader.DebugMode = true; _shader = Shader.CreateSharedShader <SimpleShader>(); _patchEntity = _scene.CreateEntity("Box", "box.mesh"); _scene.RootSceneNode.AttachObject(_patchEntity); var mat = _shader.ToMaterial(); var pass = mat.GetTechnique(0).GetPass(0); pass.SetAlphaRejectSettings(CompareFunction.CMPF_GREATER_EQUAL, 128); pass.CullingMode = CullingMode.CULL_NONE; // SL# on OGRE: bind auto semantic to a uniform! // (we might automate this via semantic attributes within the SL# shaders in future!) _shader.SetAuto(() => _shader.ModelviewProjection, GpuProgramParameters.AutoConstantType.ACT_WORLDVIEWPROJ_MATRIX); _shader.Begin(); // Set a texture /* * var smp = _shader.Sampler(() => _shader.Texture); * smp.SetTextureName(TextureManager.Singleton.Load("test.png", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).Name); * smp.SetTextureName(_wang.AsTexture.Name); * smp.SetTextureFiltering(FilterOptions.FO_POINT, FilterOptions.FO_POINT, FilterOptions.FO_POINT); */ _patchEntity.SetMaterial(mat); _camera = _scene.CreateCamera("MainCamera"); _camera.Position = new Vector3(0, 0, 5); _camera.LookAt(Vector3.ZERO); _camera.NearClipDistance = 0.0001f; _camera.FarClipDistance = 4.0f; _camera.AutoAspectRatio = true; var vp = _window.AddViewport(_camera); vp.BackgroundColour = ColourValue.Blue; }
public App(Control control) { mRoot = new Root(String.Format("plugins-{0}.cfg", GetOS())); Initialiser.SetupResources("resources.cfg"); mRoot.ShowConfigDialog(); mRenderWindow = mRoot.Initialise(control); mSceneManager = mRoot.CreateSceneManager((UInt16)SceneType.Generic, "ExampleSMInstance"); mCamera = mSceneManager.CreateCamera("MainCamera"); mCamera.Position = new Math3D.Vector3(150, 150, 150); mCamera.LookAt(new Math3D.Vector3(0, 0, 0)); mCamera.NearClipDistance = 5; mViewport = mRenderWindow.AddViewport(mCamera); mViewport.BackgroundColor = Color.Blue; mCamera.AspectRatio = (float)mViewport.ActualWidth / (float)mViewport.ActualHeight; TextureManager.Instance.SetDefaultNumMipmaps(5); ResourceGroupManager.getSingleton().initialiseAllResourceGroups(); mSceneManager.AmbientLightColor = Color.FromArgb(125, 125, 125, 125); mSceneManager.SetSkyBox(true, "Examples/SpaceSkyBox", 50); mLight = mSceneManager.CreateLight("MainLight"); mLight.Position = new Math3D.Vector3(20, 80, 50); mEntity = mSceneManager.CreateEntity("razor", "razor.mesh"); mSceneManager.RootSceneNode.AttachObject(mEntity); mParticleSystem = mSceneManager.CreateParticleSystem("ParticleSys1", 200); mParticleSystem.MaterialName = "Examples/Flare"; mParticleSystem.SetDefaultDimensions(25, 25); mParticleEmitter1 = mParticleSystem.AddEmitter("Point"); mParticleEmitter1.TimeToLive = 0.2f; mParticleEmitter1.EmissionRate = 70.0f; mParticleEmitter1.ParticleVelocity = 100.0f; mParticleEmitter1.Direction = new Math3D.Vector3(0.0f, 0.0f, -1.0f); mParticleEmitter1.SetColors(Color.White, Color.Red); mParticleEmitter1.Position = new Math3D.Vector3(5.7f, 0.0f, 0.0f); mParticleEmitter2 = mParticleSystem.AddEmitter("Point"); mParticleEmitter2.TimeToLive = 0.2f; mParticleEmitter2.EmissionRate = 70.0f; mParticleEmitter2.ParticleVelocity = 100.0f; mParticleEmitter2.Direction = new Math3D.Vector3(0.0f, 0.0f, -1.0f); mParticleEmitter2.SetColors(Color.White, Color.Red); mParticleEmitter2.Position = new Math3D.Vector3(-18.0f, 0.0f, 0.0f); mSceneManager.RootSceneNode.CreateChildSceneNode(new Math3D.Vector3(0.0f, 6.5f, -67.0f)).AttachObject(mParticleSystem); }
/************************************************************************/ /* start up ogre manager */ /************************************************************************/ internal bool Startup() { // check if already initialized if (mRoot != null) { return(false); } // create ogre root mRoot = new Root("plugins.cfg", "settings.cfg", "mogre.log"); // create resource manager and initialize it mResourceMgr = new ResourceManager(); if (!mResourceMgr.Startup("../resources.cfg")) { return(false); } if (!Configure()) { return(false); } // register event to get notified when application lost or regained focus mRoot.RenderSystem.EventOccurred += OnRenderSystemEventOccurred; // create window and get the native window handle (needed for MOIS) mWindow = mRoot.CreateRenderWindow("Project Sustain", Program.WINDOW_WIDTH, Program.WINDOW_HEIGHT, true); mWindow.GetCustomAttribute("WINDOW", out mWindowHandle); mResourceMgr.InitGroup("PostLoad"); // create scene manager mSceneMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC, "DefaultSceneManager"); // create default camera mCamera = mSceneMgr.CreateCamera("DefaultCamera"); mCamera.AutoAspectRatio = true; mCamera.NearClipDistance = 1.0f; mCamera.FarClipDistance = 1000.0f; // create default viewport mViewport = mWindow.AddViewport(mCamera); mResourceMgr.Load(); mResourceMgr.LoadGroup("PostLoad"); // set rendering active flag mRenderingActive = true; // OK return(true); }
/// <summary> /// Initialises Ogre objects and event handling, loads resources, and calls ExampleApplication.CreateScene(). /// </summary> /// <returns>Returns true if successfull, false if unsuccessfull</returns> /// <remarks>This method should only be called by the user if ExampleApplication.Start() is not called.</remarks> /// <seealso>ExampleApplication.Start</seealso> protected bool Setup() { mRoot = new Root(); Initialiser.SetupResources("resources.cfg"); if (!mRoot.ShowConfigDialog()) { return(false); } mRenderWindow = mRoot.Initialise(true, "Ogre Render Window"); mSceneManager = this.mRoot.GetSceneManager(SceneType.Generic); mCamera = this.mSceneManager.CreateCamera("MainCamera"); mCamera.SetPosition(0, 0, -200); mCamera.LookAt = new Vector3(0, 0, 0); mCamera.NearClipDistance = 5; mViewport = mRenderWindow.AddViewport(mCamera); mViewport.BackgroundColor = Color.Blue; mCamera.AspectRatio = (float)mViewport.ActualWidth / (float)mViewport.ActualHeight; TextureManager.Instance.SetDefaultNumMipmaps(5); ResourceGroupManager.getSingleton().initialiseAllResourceGroups(); mEventHandler = new OgreDotNet.EventHandler(mRoot, mRenderWindow); mEventHandler.SubscribeEvents(); mEventHandler.FrameStarted += new FrameEventDelegate(FrameStarted); mEventHandler.FrameEnded += new FrameEventDelegate(FrameEnded); mEventHandler.KeyClicked += new KeyEventDelegate(KeyClicked); mEventHandler.KeyPressed += new KeyEventDelegate(KeyPressed); mEventHandler.KeyReleased += new KeyEventDelegate(KeyReleased); mEventHandler.MouseMoved += new MouseMotionEventDelegate(MouseMotion); mEventHandler.MouseClicked += new MouseEventDelegate(MouseClick); mEventHandler.MousePressed += new MouseEventDelegate(MousePressed); mEventHandler.MouseReleased += new MouseEventDelegate(MouseReleased); mEventHandler.MouseDragged += new MouseMotionEventDelegate(MouseDragged); InputReader inputreader = mEventHandler.GetInputReader(); mDebugOverlay = OverlayManager.getSingleton().getByName("Core/DebugOverlay"); mAverageFPS = OverlayManager.getSingleton().getOverlayElement("Core/AverageFps"); mCurrentFPS = OverlayManager.getSingleton().getOverlayElement("Core/CurrFps"); mBestFPS = OverlayManager.getSingleton().getOverlayElement("Core/BestFps"); mWorstFPS = OverlayManager.getSingleton().getOverlayElement("Core/WorstFps"); mTriangleCount = OverlayManager.getSingleton().getOverlayElement("Core/NumTris"); DebugOverlayVisible = true; MaterialManager.Instance.SetDefaultTextureFiltering(mFilter); MaterialManager.Instance.SetDefaultAnisotropy(mAnisotropy); CreateScene(); return(true); }
protected static void CreateScene() { m_SceneManager = mRoot.CreateSceneManager(SceneType.ST_GENERIC); m_Camera = m_SceneManager.CreateCamera("myCamera1"); m_Camera.ProjectionType = ProjectionType.PT_ORTHOGRAPHIC; m_Camera.SetPosition(-1, 2000, 0); m_Camera.NearClipDistance = 5; m_Camera.FarClipDistance = 2501; m_Camera.LookAt(Vector3.ZERO); Viewport viewport = mRenderWindow.AddViewport(m_Camera); viewport.BackgroundColour = ColourValue.Black; m_Camera.AspectRatio = viewport.ActualWidth / viewport.ActualHeight; var context = ZmqContext.Create(); var receiver = new MessageReceiver(context); receiver.Listen(); m_Bus = new MessageBus(new MessageSender(context), receiver); var creator = new ShapeCreator(m_SceneManager); creator.CreateUnitTrianlge(); creator.CreateStar(); //m_Object = new GameObject(m_SceneManager); //m_Path = new Path(4, new CircularMotion(0, 50, new Angle(0), new Angle(Math.PI / 10), 20, Vector.Zero), m_Bus); //m_Circle = path.CreatePathTo(new Vector2(100, -100), new Vector2(0, 10), Vector2.ZERO); //m_Circle = new CircularMotion(0, 50, new Angle(0), new Angle(Math.PI/2),2); m_Linear = new LinearMotion(0, new Vector(10, 0), Vector.Zero); m_SceneManager.AmbientLight = new ColourValue(1, 1, 1); mNinjaEntity = m_SceneManager.CreateEntity("Ninja", "triangle"); mNinjaNode = m_SceneManager.RootSceneNode.CreateChildSceneNode("NinjaNode"); mNinjaNode.AttachObject(mNinjaEntity); mNinjaNode.SetPosition(500, 0, -500); m_ClickStar = m_SceneManager.CreateEntity("Star", "star"); m_ClickNode = m_SceneManager.RootSceneNode.CreateChildSceneNode("ClickNode"); m_ClickNode.AttachObject(m_ClickStar); mLight = m_SceneManager.CreateLight("pointLight"); mLight.Type = Light.LightTypes.LT_POINT; mLight.Position = new Vector3(250, 150, 250); mLight.DiffuseColour = ColourValue.White; mLight.SpecularColour = ColourValue.White; }
public void CreateRenderWindow(string handle) { // var form = new Form1(); CreateCamera(); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = handle; m_RenderWindow = m_Root.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); Viewport viewport = m_RenderWindow.AddViewport(m_Camera); viewport.BackgroundColour = ColourValue.Black; m_Camera.AspectRatio = (double)viewport.ActualWidth / (double)viewport.ActualHeight; }
public void ToggleViewport() { if (Viewport2 == null) { Viewport2 = RenderWindow.AddViewport(Camera2, 1); Viewport2.SetDimensions(0, 0, 0.25F, 0.25F * Viewport.ActualWidth / Viewport.ActualHeight); Viewport2.OverlaysEnabled = false; Camera2.AspectRatio = (float)Viewport2.ActualWidth / Viewport2.ActualHeight; } else { RenderWindow.RemoveViewport(1); Viewport2 = null; } }
public void CreateMainViewport(int zOrder, float left, float top, float width, float height) { if (viewport != null) { viewport.Dispose(); viewport = null; } viewport = window.AddViewport(camera, zOrder, left, top, width, height); viewport.BackgroundColour = new ColourValue(0, 0, 0); // Alter the camera aspect ratio to match the viewport camera.AspectRatio = (viewport.ActualWidth) / ((float)viewport.ActualHeight); viewport.OverlaysEnabled = false; }
/// <summary> /// set up ogre /// </summary> public Program() { root = new Root("plugins.cfg", "", "Ogre.log"); renderSystem = root.GetRenderSystemByName("Direct3D9 Rendering Subsystem"); renderSystem.SetConfigOption("Full Screen", "No"); renderSystem.SetConfigOption("Video Mode", "1920 x 1200 @ 32-bit colour"); root.RenderSystem = renderSystem; SetupResources(); window = root.Initialise(true, "shadow test"); sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "sceneMgr"); sceneMgr.AmbientLight = new ColourValue(0.8f, 0.8f, 0.8f); camera = sceneMgr.CreateCamera("cam"); camera.Position = new Vector3(0.8f, 0.8f, 0.8f); camera.LookAt(new Vector3(-1, 1, -1)); camera.SetAutoTracking(true, sceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(0, 0.4f, 0))); camera.NearClipDistance = 0.1f; camera.FarClipDistance = 2000; viewport = window.AddViewport(camera); viewport.BackgroundColour = ColourValue.Black; camera.AspectRatio = (float) viewport.ActualWidth / (float) viewport.ActualHeight; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); TextureManager.Singleton.DefaultNumMipmaps = 1; CreateThings(); //SetupParticles(); //SetupShadows(); SetupInput(); root.FrameStarted += FrameStarted; Console.WriteLine( @" Press 1, 2, 3, 4 to enable/disable lights, or Esc to quit. The red and blue textures have PSSM and self-shadowing enabled. The yellow one does not. You can also use WASDQE to move the camera around." ); }
private void CreateCamera(State state) { Camera = state.SceneManager.CreateCamera("MainCamera"); Camera.NearClipDistance = 0.1F; Viewport = RenderWindow.AddViewport(Camera, 0); Camera.AspectRatio = (float)Viewport.ActualWidth / Viewport.ActualHeight; //Viewport.SetDimensions(window.Left, window.Top, window.Width, window.Height); Camera2 = state.SceneManager.CreateCamera("MainCamera2"); Camera2.NearClipDistance = 0.1F; //Camera2.Yaw(Math.HALF_PI); ResetCamera(state); }
static void Main() { IConfigurationManager ConfigurationManager = ConfigurationManagerFactory.CreateDefault(); using (var root = new Root("Game1.log")) { if (ConfigurationManager.ShowConfigDialog(root)) { RenderWindow window = root.Initialize(true); ResourceGroupManager.Instance.AddResourceLocation("media", "Folder", true); SceneManager scene = root.CreateSceneManager(SceneType.Generic); Camera camera = scene.CreateCamera("cam1"); Viewport viewport = window.AddViewport(camera); TextureManager.Instance.DefaultMipmapCount = 5; ResourceGroupManager.Instance.InitializeAllResourceGroups(); Light pointLight = scene.CreateLight("pointLight"); //pointLight.Type = LightType.Point; //pointLight.Position = new Vector3(0, 150, 250); //pointLight.DiffuseColor = ColorEx.Red; //pointLight.SpecularColor = ColorEx.Red; //pointLight.Diffuse = ColorEx.Red; scene.AmbientLight = new ColorEx(1, 1, 1); //Entity penguin = scene.CreateEntity( "bob", "penguin.mesh" ); //SceneNode penguinNode = scene.RootSceneNode.CreateChildSceneNode(); //penguinNode.AttachObject( penguin ); camera.Move(new Vector3(0, 0, 300)); //camera.LookAt( penguin.BoundingBox.Center ); Plane plane = new Plane(Vector3.UnitY, 0); MeshManager.Instance.CreatePlane("ground", ResourceGroupManager.DefaultResourceGroupName, plane, 1500, 1500, 20, 20, true, 1, 5, 5, Vector3.UnitZ); Entity groundEnt = scene.CreateEntity("GroundEntity", "ground"); scene.RootSceneNode.CreateChildSceneNode().AttachObject(groundEnt); groundEnt.SetMaterialName("Examples/Rockwall"); groundEnt.CastShadows = false; camera.LookAt(groundEnt.BoundingBox.Center); root.RenderOneFrame(); } Console.Write("Press [Enter] to exit."); Console.ReadLine(); } }
bool CreateRenderTarget() { DestroyRenderTarget(); if (EngineApp.Instance == null) { return(false); } Vector2I size = new Vector2I(ClientRectangle.Size.Width, ClientRectangle.Size.Height); if (size.X < 1 || size.Y < 1) { return(false); } renderWindow = RenderingSystem.CreateRenderWindow(Handle, size); if (renderWindow == null) { return(false); } viewport = renderWindow.AddViewport(true, true); viewport.MousePositionSetImpl = MousePositionSet; viewport.MouseRelativeModeSetImpl = MouseRelativeModeSet; ViewportCreated?.Invoke(this); //apply DpiScaleFactor to canvas default font size var defaultSize = 0.017; try { defaultSize *= DpiHelper.Default.DpiScaleFactor; } catch { } viewport.CanvasRenderer.DefaultFontSize = defaultSize; //viewport.CanvasRenderer.DefaultFontSize = 0.02 * DpiHelper.Default.DpiScaleFactor; //var fontHeight = viewport.CanvasRenderer.DefaultFontSize * DpiHelper.Default.DpiScaleFactor; //viewport.CanvasRenderer.DefaultFont = EngineFontManager.Instance.LoadFont( "Default", fontHeight ); //if( viewport.CanvasRenderer.DefaultFont == null ) // viewport.CanvasRenderer.DefaultFont = EngineFontManager.Instance.LoadFont( "Default", "English", fontHeight ); return(true); }
protected override HandleRef BuildWindowCore(HandleRef hwndParent) { NameValuePairList misc = new NameValuePairList(); misc["parentWindowHandle"] = hwndParent.Handle.ToString(); m_RenderWindow = m_Root.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); CreateCamera(); Viewport viewport = m_RenderWindow.AddViewport(m_Camera); viewport.BackgroundColour = ColourValue.Black; m_Camera.AspectRatio = (double)viewport.ActualWidth / (double)viewport.ActualHeight; int windowHandle; m_RenderWindow.GetCustomAttribute("WINDOW", out windowHandle); return(new HandleRef(this, new IntPtr(windowHandle))); }
public void ReinitRenderWindow(String handle, uint width, uint height) { if (_root == null) { return; } 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; _renderWindow.AddViewport(_viewCamera); }
public void OnLoad() { //ResourceGroupManager.Instance.AddResourceLocation("media", "Folder", true); _root.SceneManager = _sceneManager = _root.CreateSceneManager(SceneType.ExteriorClose); _sceneManager.ClearScene(); _camera = _sceneManager.CreateCamera("MainCamera"); _camera.Position = new Vector3(0, 0, 500); _camera.LookAt(new Vector3(0, 0, -300)); _camera.Near = 5; _camera.AutoAspectRatio = true; _camera.FieldOfView = 0.70f; _viewport = _renderWindow.AddViewport(_camera, 0, 0, 1.0f, 1.0f, 100); _viewport.BackgroundColor = ColorEx.Black;; _light = _sceneManager.CreateLight("light1"); _light.Type = LightType.Directional; _light.Position = new Vector3(0, 150, 300); _light.Diffuse = ColorEx.Blue; _light.Specular = ColorEx.Blue; //_light.Direction = new Vector3(0, 0, -300); _sceneManager.AmbientLight = ColorEx.White; // new ColorEx(0.2f, 0.2f, 0.2f); ResourceGroupManager.Instance.InitializeAllResourceGroups(); _inputReader = PlatformManager.Instance.CreateInputReader(); _inputReader.Initialize(_renderWindow, true, true, false, false); _inputReader.UseKeyboardEvents = true; _inputReader.UseMouseEvents = false; //_renderItems.Add(new BasicCube()); _renderItems.Add(new CubeBrowser()); foreach (var i in _renderItems) { i.Initialise(_root); } }
public void InitializeScene() { // Start the Stopwatch. stopwatch = new Stopwatch(); stopwatch.Start(); physicsDelayTicks = Stopwatch.Frequency / 35.0; // 30 physics steps per second ticksToMilliFactor = 1.0 / (Stopwatch.Frequency / 1000.0); ticksToPhysicsStepPercentFactor = 1.0 / physicsDelayTicks; lastPhysicsStepTicks = 0.0; // Create the World. World.Instance = new World(sceneManager); World.Instance.Initialize(); World.Instance.Arena = new Arena(sceneManager, 500, 4); // Create a AI Ships. for (var i = 0; i < 36; i++) { World.Instance.AddShip(new Ship(sceneManager, new RandomController())); } // Camera. camera = new SmoothCamera("Camera", sceneManager, World.Instance.PlayerShip, 6); // Lighting. sunlight = sceneManager.CreateLight("Sunlight"); sunlight.Type = LightType.Spotlight; sunlight.Specular = ColorEx.White; sunlight.Diffuse = new ColorEx(0.85f, 0.77f, 0.60f); sunlight.Position = new Vector3(0, 0, 0); sunlight.Direction = Vector3.NegativeUnitZ; sunlight.SetSpotlightRange(15, 60); sceneManager.AmbientLight = ColorEx.Black; camera.Node.AttachObject(sunlight); // Viewport. viewport = window.AddViewport(camera, 0, 0, 1.0f, 1.0f, 100); viewport.BackgroundColor = ColorEx.Black; }
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 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); }
public void CreateRenderWindow(string handle) { // var form = new Form1(); CreateCamera(); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = handle; m_RenderWindow = m_Root.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); Viewport viewport = m_RenderWindow.AddViewport(m_Camera); viewport.BackgroundColour = ColourValue.Black; m_Camera.AspectRatio = (double)viewport.ActualWidth / (double)viewport.ActualHeight; }
protected override HandleRef BuildWindowCore(HandleRef hwndParent) { NameValuePairList misc = new NameValuePairList(); misc["parentWindowHandle"] = hwndParent.Handle.ToString(); m_RenderWindow = m_Root.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); CreateCamera(); Viewport viewport = m_RenderWindow.AddViewport(m_Camera); viewport.BackgroundColour = ColourValue.Black; m_Camera.AspectRatio = (double)viewport.ActualWidth / (double)viewport.ActualHeight; int windowHandle; m_RenderWindow.GetCustomAttribute("WINDOW", out windowHandle); return new HandleRef(this, new IntPtr(windowHandle)); }
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); }
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"); }
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 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 Initialise() { m_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 (!m_Root.RestoreConfig()) if (!m_Root.ShowConfigDialog()) return; m_RenderWindow = m_Root.Initialise(true); ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); m_SceneManager = m_Root.CreateSceneManager(SceneType.ST_GENERIC); m_Camera = m_SceneManager.CreateCamera("MainCamera"); m_Viewport = m_RenderWindow.AddViewport(m_Camera); m_Camera.NearClipDistance = 0.1f; m_Camera.FarClipDistance = 1000.0f; MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; m_RenderWindow.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); m_InputManager = MOIS.InputManager.CreateInputSystem(pl); m_Keyboard = (MOIS.Keyboard)m_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false); m_Mouse = (MOIS.Mouse)m_InputManager.CreateInputObject(MOIS.Type.OISMouse, false); m_NewtonWorld = new World(); m_NewtonDebugger = new Debugger(m_NewtonWorld); m_NewtonDebugger.Init(m_SceneManager); m_GameCamera = new GameCamera(); m_ObjectManager = new ObjectManager(); }
private bool CreateRenderTarget() { DestroyRenderTarget(); if (RendererWorld.Instance == null) return false; Vec2I size = new Vec2I(ClientRectangle.Size.Width, ClientRectangle.Size.Height); if (size.X < 1 || size.Y < 1) return false; renderWindow = RendererWorld.Instance.CreateRenderWindow(Handle, size); if (renderWindow == null) return false; renderWindow.AutoUpdate = false; renderWindow.AllowAdditionalMRTs = true; camera = SceneManager.Instance.CreateCamera( SceneManager.Instance.GetUniqueCameraName("UserControl")); camera.Purpose = Camera.Purposes.MainCamera; //update camera settings camera.NearClipDistance = cameraNearFarClipDistance.Minimum; camera.FarClipDistance = cameraNearFarClipDistance.Maximum; camera.AspectRatio = (float)renderWindow.Size.X / (float)renderWindow.Size.Y; camera.FixedUp = cameraFixedUp; camera.Position = cameraPosition; camera.Direction = cameraDirection; camera.Fov = cameraFov; camera.ProjectionType = cameraProjectionType; camera.OrthoWindowHeight = cameraOrthoWindowHeight; viewport = renderWindow.AddViewport(camera); //Initialize HDR compositor for HDR render technique if (EngineApp.RenderTechnique == "HDR") { viewport.AddCompositor("HDR", 0); viewport.SetCompositorEnabled("HDR", true); } //Initialize Fast Approximate Antialiasing (FXAA) { bool useMRT = RendererWorld.InitializationOptions.AllowSceneMRTRendering; string fsaa = RendererWorld.InitializationOptions.FullSceneAntialiasing; if ((useMRT && (fsaa == "" || fsaa == "RecommendedSetting") && IsActivateFXAAByDefault()) || fsaa == "FXAA") { if (RenderSystem.Instance.HasShaderModel3()) InitializeFXAACompositor(); } } //add listener renderTargetListener = new ViewRenderTargetListener(this); renderWindow.AddListener(renderTargetListener); if (guiRenderer == null) guiRenderer = new GuiRenderer(viewport); else guiRenderer.ChangeViewport(viewport); if (controlManager == null) controlManager = new ScreenControlManager(guiRenderer); return true; }
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); } }
bool CreateRenderTarget() { DestroyRenderTarget(); if( RendererWorld.Instance == null ) return false; Vec2i size = new Vec2i( ClientRectangle.Size.Width, ClientRectangle.Size.Height ); if( size.X < 1 || size.Y < 1 ) return false; renderWindow = RendererWorld.Instance.CreateRenderWindow( Handle, size ); if( renderWindow == null ) return false; renderWindow.AutoUpdate = false; camera = SceneManager.Instance.CreateCamera(); //update camera settings camera.NearClipDistance = cameraNearFarClipDistance.Minimum; camera.FarClipDistance = cameraNearFarClipDistance.Maximum; camera.AspectRatio = (float)renderWindow.Size.X / (float)renderWindow.Size.Y; camera.FixedUp = cameraFixedUp; camera.Position = cameraPosition; camera.Direction = cameraDirection; camera.Fov = cameraFov; viewport = renderWindow.AddViewport( camera ); SceneManager.Instance.Render += SceneManager_Render; guiRenderer = new GuiRenderer( true, viewport ); return true; }
/// <summary> /// Creates the viewport /// </summary> private static Viewport InitViewport(RenderWindow window) { Launch.Log("[Loading] Creating Viewport..."); // just make a temporary camera now for this return window.AddViewport(GetG<SceneManager>().CreateCamera("tempCam")); }
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; }