示例#1
0
        /// <summary>
        /// Load content here.
        /// </summary>
        protected override void LoadContent()
        {
            // Load our teapot and ground models.
            Model teapotModel = Game.Content.Load<Model>("Model\\teapot");
            Model groundModel = Game.Content.Load<Model>("Model\\ground");
            Texture2D bricks = Game.Content.Load<Texture2D>("Texture\\brick");
            Texture2D checkers = Game.Content.Load<Texture2D>("Texture\\checker");

            mEffect = Game.Content.Load<Effect>("Effect\\Model");
            mEffect.Parameters["t_Basic"].SetValue(bricks);
            mEffect.Parameters["TextureEnabled"].SetValue(true);

            mCamera = new FreeCamera("Main", MathHelper.PiOver4,
                                     this.GraphicsDevice.Viewport.AspectRatio,
                                     new Vector3(1000f, 650f, 1000f),
                                     MathHelper.ToRadians(-50f), MathHelper.ToRadians(-5f));

            ModelInstance teapot = new ModelInstance(teapotModel, Vector3.Zero, Vector3.Zero, new Vector3(60f));
            teapot.SetModelMaterial(new Material());
            teapot.SetModelEffect(mEffect, true);
            teapot.SetSingleParameter("t_Basic", bricks);
            teapot.SetSingleParameter("TextureEnabled", true);

            ModelInstance ground = new ModelInstance(groundModel, Vector3.Zero, Vector3.Zero, Vector3.One);
            ground.SetModelMaterial(new Material());
            ground.SetModelEffect(mEffect, true);

            // Create a single teapot and just one instance of the ground model.
            mModels.Add(teapot);
            mModels.Add(ground);

            foreach (ModelInstance modelInstance in mModels) { modelInstance.SetModelEffect(mEffect, true); }

            mRenderer = new PrePassRenderer(this.Game, this.GraphicsDevice, this.Game.Content);

            mLights.Add(new PrePointLight(new Vector3(-1000, 1000, 0), Color.Red, 1500));
            mLights.Add(new PrePointLight(new Vector3(1000, 1000, 0), Color.Orange, 1500));
            mLights.Add(new PrePointLight(new Vector3(0, 1000, 1000), Color.Yellow, 1500));
            mLights.Add(new PrePointLight(new Vector3(0, 1000, -1000), Color.Green, 1500));
            mLights.Add(new PrePointLight(new Vector3(1000, 1000, 1000), Color.Blue, 1500));
            mLights.Add(new PrePointLight(new Vector3(-1000, 1000, 1000), Color.Indigo, 1500));
            mLights.Add(new PrePointLight(new Vector3(1000, 1000, -1000), Color.Violet, 1500));
            mLights.Add(new PrePointLight(new Vector3(-1000, 1000, -1000), Color.White, 1500));

            // Input.
            mCamera.Update();

            mX = -MathHelper.Pi / 10f;
            mY = MathHelper.PiOver2;

            Mouse.SetPosition(this.GraphicsDevice.Viewport.Width / 2,
                              this.GraphicsDevice.Viewport.Height / 2);
            mPrevMouse = Mouse.GetState();

            base.LoadContent();
        }