Exemple #1
0
        protected override void LoadContent()
        {
            var width           = 640;
            var height          = 480;
            var scale           = 1f;
            var rayStep         = 1;
            var sceneComplexity = 3;

            var config = new ConfigParser("config.ini");

            config.GetBool("showUI", ref m_ShowUI);
            config.GetBool("Realtime", ref m_Realtime);
            config.GetInteger("Width", ref width);
            config.GetInteger("Height", ref height);
            config.GetFloat("Scale", ref scale);
            config.GetInteger("Step", ref rayStep);
            config.GetInteger("SceneComplexity", ref sceneComplexity);

            m_GraphicsDeviceManager.PreferredBackBufferWidth  = width;
            m_GraphicsDeviceManager.PreferredBackBufferHeight = height;
            m_GraphicsDeviceManager.GraphicsProfile           = GraphicsProfile.HiDef;
            m_GraphicsDeviceManager.ApplyChanges();

            m_SpriteBatch = new SpriteBatch(GraphicsDevice);
            m_SpriteFont  = Content.Load <SpriteFont>("Default");

            // Final setup.
            var aspect = (float)m_GraphicsDeviceManager.PreferredBackBufferWidth / (float)m_GraphicsDeviceManager.PreferredBackBufferHeight;

            var scene  = SceneFactory.MakeSphereScene(Content, sceneComplexity);
            var scene2 = new DataStructure.BVHNode(scene);

            //var scene = SceneFactory.MakeCornellBoxScene();

            m_Camera = new Camera(new Vector3(0, 0.5f, 5), new Vector3(-0.22f, 0.15f, 0.0f), Vector3.Up, 75.0f, aspect);
            m_World  = new HitableList(scene);

            m_Raytracer      = new RayTracer(this, scale);
            m_Raytracer.Step = rayStep;

            if (!m_Realtime)
            {
                m_Raytracer.Render(m_Camera, m_World);
            }
            else
            {
                m_Raytracer.Start(m_Camera, m_World);
            }
        }