Esempio n. 1
0
        // Called when the game should load its content
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            camera = new FreeCamera(new Vector3(100, 65, 100),
                                    MathHelper.ToRadians(45),
                                    MathHelper.ToRadians(-30),
                                    GraphicsDevice);

            Effect lit    = Content.Load <Effect>("Content/LightingEffect");
            Effect normal = Content.Load <Effect>("Content/NormalMapEffect");

            LightingMaterial marble = new LightingMaterial();

            marble.SpecularColor = Color.White.ToVector3();

            LightingMaterial steel = new LightingMaterial();

            steel.SpecularColor = Color.Gray.ToVector3();

            NormalMapMaterial brick = new NormalMapMaterial(
                Content.Load <Texture2D>("Content/brick_normal_map"));

            NormalMapMaterial wood = new NormalMapMaterial(
                Content.Load <Texture2D>("Content/wood_normal"));

            CModel model = new CModel(Content.Load <Model>("Content/multimesh__cv1"),
                                      Vector3.Zero, Vector3.Zero, Vector3.One, GraphicsDevice);

            model.SetMeshEffect("Box01", normal, true);
            model.SetMeshMaterial("Box01", wood);

            model.SetMeshEffect("Pyramid01", normal, true);
            model.SetMeshMaterial("Pyramid01", brick);

            model.SetMeshEffect("Sphere01", lit, true);
            model.SetMeshMaterial("Sphere01", marble);

            model.SetMeshEffect("Plane01", lit, true);
            model.SetMeshMaterial("Plane01", steel);

            models.Add(model);

            lastMouseState = Mouse.GetState();
        }
Esempio n. 2
0
        // Called when the game should load its content
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            models.Add(new CModel(Content.Load <Model>("ground"),
                                  Vector3.Zero, Vector3.Zero, Vector3.One, GraphicsDevice));

            models.Add(new CModel(Content.Load <Model>("brick_wall"),
                                  Vector3.Zero, new Vector3(0, 0, 0), Vector3.One, GraphicsDevice));

            Effect           lightingEffect = Content.Load <Effect>("LightingEffect");
            LightingMaterial lightingMat    = new LightingMaterial();

            Effect            normalMapEffect = Content.Load <Effect>("NormalMapEffect");
            NormalMapMaterial normalMat       = new NormalMapMaterial(
                Content.Load <Texture2D>("brick_normal_map"));

            lightingMat.LightDirection = new Vector3(.5f, .5f, 1);
            lightingMat.LightColor     = Vector3.One;

            normalMat.LightDirection = new Vector3(.5f, .5f, 1);
            normalMat.LightColor     = Vector3.One;

            models[0].SetModelEffect(lightingEffect, true);
            models[1].SetModelEffect(normalMapEffect, true);

            models[0].Material = lightingMat;
            models[1].Material = normalMat;

            camera = new FreeCamera(new Vector3(0, 400, 1400),
                                    MathHelper.ToRadians(0),
                                    MathHelper.ToRadians(0),
                                    GraphicsDevice);

            sky = new SkySphere(Content, GraphicsDevice,
                                Content.Load <TextureCube>("clouds"));

            lastMouseState = Mouse.GetState();
        }