Esempio n. 1
0
        private void BuildShapeGeometryBuffers() {
            
            _boxModel = new BasicModel();
            _boxModel.CreateBox(Device, 1, 1, 1);
            _boxModel.Materials[0] = new Material {
                Ambient = new Color4(1f, 1f, 1f),
                Diffuse = new Color4(1f, 1f, 1f),
                Specular = new Color4(16.0f, 0.8f, 0.8f, 0.8f),
                Reflect = Color.Black
            };
            _boxModel.DiffuseMapSRV[0] = _texMgr.CreateTexture("Textures/bricks.dds");
            _boxModel.NormalMapSRV[0] = _texMgr.CreateTexture("Textures/bricks_nmap.dds");

            

            _sphereModel = new BasicModel();
            _sphereModel.CreateSphere(Device, 0.5f, 20, 20);
            _sphereModel.Materials[0] = new Material {
                Ambient = new Color4(0.2f, 0.3f, 0.4f),
                Diffuse = new Color4(0.2f, 0.3f, 0.4f),
                Specular = new Color4(16.0f, 0.9f, 0.9f, 0.9f),
                Reflect = new Color4(0.4f, 0.4f, 0.4f)
            };
            _cylinderModel = new BasicModel();
            _cylinderModel.CreateCylinder(Device, 0.5f, 0.3f, 3.0f, 15, 15);
            _cylinderModel.Materials[0] = new Material {
                Ambient = new Color4(1f, 1f, 1f),
                Diffuse = new Color4(1f, 1f, 1f),
                Specular = new Color4(32.0f, 1f, 1f, 1f),
                Reflect = Color.Black
            };
            _cylinderModel.DiffuseMapSRV[0] = _texMgr.CreateTexture("Textures/bricks.dds");
            _cylinderModel.NormalMapSRV[0] = _texMgr.CreateTexture("Textures/bricks_nmap.dds");

            for (var i = 0; i < 5; i++) {
                _cylinders[i * 2] = new BasicModelInstance(_cylinderModel) {
                    World = Matrix.Translation(-5.0f, 1.5f, -10.0f + i * 5.0f),
                    TexTransform = Matrix.Scaling(1, 2, 1)
                };
                _cylinders[i * 2 + 1] = new BasicModelInstance(_cylinderModel) {
                    World = Matrix.Translation(5.0f, 1.5f, -10.0f + i * 5.0f),
                    TexTransform = Matrix.Scaling(1, 2, 1)
                };

                _spheres[i * 2] = new BasicModelInstance(_sphereModel) {
                    World = Matrix.Translation(-5.0f, 3.45f, -10.0f + i * 5.0f)
                };
                _spheres[i * 2 + 1] = new BasicModelInstance(_sphereModel) {
                    World = Matrix.Translation(5.0f, 3.45f, -10.0f + i * 5.0f)
                };
            }

            _box = new BasicModelInstance(_boxModel) {
                TexTransform = Matrix.Scaling(2, 1, 1),
                World = Matrix.Scaling(3.0f, 1.0f, 3.0f) * Matrix.Translation(0, 0.5f, 0)
            };
            


        }
Esempio n. 2
0
        public override bool Init()
        {
            if (!base.Init())
                return false;
            Effects.InitAll(Device);
            InputLayouts.InitAll(Device);
            RenderStates.InitAll(Device);

            _texMgr = new TextureManager();
            _texMgr.Init(Device);

            _gridModel = new BasicModel();
            _gridModel.CreateGrid(Device, 20, 20, 40, 40);
            _gridModel.Materials[0] = new Material() { Diffuse = Color.SaddleBrown, Specular = new Color4(16, .9f, .9f, .9f) };
            _gridModel.DiffuseMapSRV[0] = _texMgr.CreateTexture("Textures/floor.dds");
            _gridModel.NormalMapSRV[0] = _texMgr.CreateTexture("textures/floor_nmap.dds");

            _sphereModel = new BasicModel();
            _sphereModel.CreateSphere(Device, 0.3f, 5, 4);
            _sphereModel.Materials[0] = new Material() { Ambient = Color.Blue, Diffuse = Color.Blue, Specular = new Color4(64.0f, 1.0f, 1.0f, 1.0f) };
            _sphereModel.NormalMapSRV[0] = _texMgr.CreateTexture("Textures/stones_nmap.dds");

            _cylinderModel = new BasicModel();
            _cylinderModel.CreateCylinder(Device, 1, 1, 3, 20, 20);
            _cylinderModel.Materials[0] = new Material() { Ambient = Color.Green, Diffuse = Color.Green, Specular = new Color4(64.0f, 1.0f, 1.0f, 1.0f) };
            _cylinderModel.NormalMapSRV[0] = _texMgr.CreateTexture("Textures/stones_nmap.dds");

            _grid = new BasicModelInstance(_gridModel) {
                TexTransform = Matrix.Scaling(10, 10, 1),
                World = Matrix.Scaling(10, 1, 10)*Matrix.Translation(0, 0, 90)
            };

            _sphere = new BasicModelInstance(_sphereModel);

            _cylinder = new BasicModelInstance(_cylinderModel) {
                World = Matrix.Translation(0, 1.5f, 0)
            };

            return true;
        }
Esempio n. 3
0
        public override bool Init() {
            if (!base.Init()) return false;
            Effects.InitAll(Device);
            InputLayouts.InitAll(Device);
            RenderStates.InitAll(Device);

            _texMgr = new TextureManager();
            _texMgr.Init(Device);


            _geosphereModel = new BasicModel();
            _geosphereModel.CreateGeosphere(Device, 5, _subdivisions);
            _geosphereModel.Materials[0] = _material;

            _sphereModel = new BasicModel();
            _sphereModel.CreateSphere(Device, 5, 20,20);
            _sphereModel.Materials[0] = new Material() {
                Ambient = Color.Blue,
                Diffuse = Color.Red,
                Specular = new Color4(16.0f, 0.75f, 0.75f, 0.75f)
            };

            _geosphere = new BasicModelInstance(_geosphereModel) {
                World = Matrix.Identity
            };
            _sphere = new BasicModelInstance(_sphereModel);


            return true;
        }
Esempio n. 4
0
        public override bool Init() {
            if (!base.Init()) return false;

            Effects.InitAll(Device);
            InputLayouts.InitAll(Device);
            RenderStates.InitAll(Device);
            Patch.InitPatchData(Terrain.CellsPerPatch, Device);

            _sky = new Sky(Device, "Textures/grasscube1024.dds", 5000.0f);

            var tii = new InitInfo {
                HeightMapFilename = null,
                LayerMapFilename0 = "textures/grass.png",
                LayerMapFilename1 = "textures/hills.png",
                LayerMapFilename2 = "textures/stone.png",
                LayerMapFilename3 = "Textures/lightdirt.dds",
                LayerMapFilename4 = "textures/snow.png",
                Material = new Material() {
                    Ambient = Color.LightGray,
                    Diffuse = Color.LightGray,
                    Specular = new Color4(64, 0, 0, 0)
                },
                BlendMapFilename = null,
                HeightScale = 50.0f,
                HeightMapWidth = 2049,
                HeightMapHeight = 2049,
                CellSpacing = 0.5f,

                Seed = MathF.Rand(),
                NoiseSize1 = 3.0f,
                Persistence1 = 0.7f,
                Octaves1 = 7,
                NoiseSize2 = 2.5f,
                Persistence2 = 0.8f,
                Octaves2 = 3,


            };
            _terrain = new Terrain();
            //_terrain.DebugQuadTree = true;
            _terrain.Init(Device, ImmediateContext, tii);

            _camera.Height = _terrain.Height;


            _camera.SetLens(0.25f * MathF.PI, AspectRatio, 1.0f, 1000.0f);
            _ssao = new Ssao(Device, ImmediateContext, ClientWidth, ClientHeight, _camera.FovY, _camera.FarZ);

            _whiteTex = ShaderResourceView.FromFile(Device, "Textures/white.dds");

            _sMap = new ShadowMap(Device, SMapSize, SMapSize);

            _sceneBounds = new BoundingSphere(new Vector3(), MathF.Sqrt(_terrain.Width * _terrain.Width + _terrain.Depth * _terrain.Depth) / 2);

            _minimap = new Minimap(Device, ImmediateContext, MinimapSize, MinimapSize, _terrain, _camera);

            _sphereModel = new BasicModel();
            _sphereModel.CreateSphere(Device, 0.25f, 10, 10);
            _sphereModel.Materials[0] = new Material {
                Ambient = new Color4(63, 0, 0),
                Diffuse = Color.Red,
                Specular = new Color4(32, 1.0f, 1.0f, 1.0f)
            };
            _sphereModel.DiffuseMapSRV[0] = _whiteTex;

            _sphere = new BasicModelInstance(_sphereModel);

            _unit = new Unit(_sphere, _terrain.GetTile(511, 511), _terrain);

            FontCache.RegisterFont("bold", 16, "Courier New", FontWeight.Bold);


            return true;
        }
Esempio n. 5
0
 private BasicModel CreateFireworkModel(Color diffuse) {
     var m1 = new BasicModel();
     m1.CreateSphere(Device, .2f, 5, 5);
     m1.Materials[0] = new Material { Ambient = Color.White, Diffuse = diffuse, Specular = new Color4(128.0f, 1.0f, 1.0f, 1.0f) };
     
     return m1;
 }