Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        /// <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);
        }
        private void InitResourceLoad()
        {
            GroupEventListener rgl = new GroupEventListener();

            rgl.ResourceGroupLoadStarted      += Singleton_ResourceGroupLoadStarted;
            rgl.ResourceGroupScriptingStarted += Singleton_ResourceGroupScriptingStarted;
            rgl.ScriptParseStarted            += Singleton_ScriptParseStarted;
            rgl.ResourceLoadStarted           += Singleton_ResourceLoadStarted;
            rgl.WorldGeometryStageStarted     += Singleton_WorldGeometryStageStarted;

            ResourceGroupManager.getSingleton().addResourceGroupListener(rgl);

            _currentProcess = 0;
        }
Exemple #5
0
 /// <summary>
 /// Called in Setup when Resources should be added to ResourceGroupManager
 /// Method which will define the source of resources (other than current folder)
 /// </summary>
 protected virtual void SetupResources(string sFileName)
 {
     //Initialiser.SetupResources(sFileName);
     using (StreamReader sr = new StreamReader(sFileName))
     {
         string secName = "", sLocType, sarchName;
         string line;
         while ((line = sr.ReadLine()) != null)
         {
             int x = line.IndexOf("#");
             if (x > -1)
             {
                 line = line.Substring(0, x);
             }
             line = line.Trim();
             if (line.Length > 0)
             {
                 if (line[0] == '[')
                 {
                     secName = line.Substring(1, line.Length - 2);
                 }
                 else if (secName.Length > 0)
                 {
                     x = line.IndexOf("=");
                     if (x <= 0)
                     {
                         throw new Exception("Invalid line in resource file " + sFileName);
                     }
                     sLocType  = line.Substring(0, x);
                     sarchName = line.Substring(x + 1);
                     ResourceGroupManager.getSingleton().addResourceLocation(sarchName, sLocType, secName);
                 }
             }
         }
     }
 }
Exemple #6
0
 ///  <summary>
 /// Optional override method where you can perform resource group loading
 /// Must at least do ResourceGroupManager.getSingleton().initialiseAllResourceGroups();
 /// </summary>
 protected virtual void LoadResources()
 {
     ResourceGroupManager.getSingleton().initialiseAllResourceGroups();
 }