public Skybox(string dir, D3D11.Device device) { TextureViews = new D3D11.ShaderResourceView[6]; ResourceUtil.LoadFromFile(device, dir + "/NegativeX.png", out TextureViews[0]); ResourceUtil.LoadFromFile(device, dir + "/PositiveX.png", out TextureViews[1]); ResourceUtil.LoadFromFile(device, dir + "/NegativeY.png", out TextureViews[2]); ResourceUtil.LoadFromFile(device, dir + "/PositiveY.png", out TextureViews[3]); ResourceUtil.LoadFromFile(device, dir + "/NegativeZ.png", out TextureViews[4]); ResourceUtil.LoadFromFile(device, dir + "/PositiveZ.png", out TextureViews[5]); sides = new Matrix[6] { Matrix.RotationY(-MathUtil.PiOverTwo) * Matrix.Translation(-1, 0, 0), Matrix.RotationY(MathUtil.PiOverTwo) * Matrix.Translation(1, 0, 0), Matrix.RotationX(MathUtil.PiOverTwo) * Matrix.Translation(0, -1, 0), Matrix.RotationX(MathUtil.PiOverTwo) * Matrix.Translation(0, 1, 0), Matrix.RotationY(0) * Matrix.Translation(0, 0, -1), Matrix.RotationY(MathUtil.Pi) * Matrix.Translation(0, 0, 1) }; Matrix m = Matrix.Identity; constBuffer = D3D11.Buffer.Create(device, D3D11.BindFlags.ConstantBuffer, ref m); }
public void SetNormalTexture(D3D11.Device device, string filePath) { NormalTextureView?.Dispose(); ResourceUtil.LoadFromFile(device, filePath, out NormalTextureView); }
public static void Load(D3D11.Device device) { QuadVertexBuffer = D3D11.Buffer.Create(device, D3D11.BindFlags.VertexBuffer, new float[] { // POSITION0, TEXCOORD0 -1, -1, 0, 0, 0, 1, -1, 0, 1, 0, -1, 1, 0, 0, 1, 1, 1, 0, 1, 1, }); QuadIndexBuffer = D3D11.Buffer.Create(device, D3D11.BindFlags.IndexBuffer, new short[] { 0, 1, 2, 1, 3, 2, }); BoundingBoxVertexBuffer = D3D11.Buffer.Create(device, D3D11.BindFlags.VertexBuffer, new VertexColor[] { new VertexColor(new Vector3(-1, -1, -1), Color.White), new VertexColor(new Vector3(1, -1, -1), Color.White), new VertexColor(new Vector3(-1, -1, 1), Color.White), new VertexColor(new Vector3(1, -1, 1), Color.White), new VertexColor(new Vector3(-1, -1, 1), Color.White), new VertexColor(new Vector3(-1, -1, -1), Color.White), new VertexColor(new Vector3(1, -1, 1), Color.White), new VertexColor(new Vector3(1, -1, -1), Color.White), new VertexColor(new Vector3(-1, -1, -1), Color.White), new VertexColor(new Vector3(-1, 1, -1), Color.White), new VertexColor(new Vector3(1, -1, -1), Color.White), new VertexColor(new Vector3(1, 1, -1), Color.White), new VertexColor(new Vector3(-1, -1, 1), Color.White), new VertexColor(new Vector3(-1, 1, 1), Color.White), new VertexColor(new Vector3(1, -1, 1), Color.White), new VertexColor(new Vector3(1, 1, 1), Color.White), new VertexColor(new Vector3(-1, 1, -1), Color.White), new VertexColor(new Vector3(1, 1, -1), Color.White), new VertexColor(new Vector3(-1, 1, 1), Color.White), new VertexColor(new Vector3(1, 1, 1), Color.White), new VertexColor(new Vector3(-1, 1, 1), Color.White), new VertexColor(new Vector3(-1, 1, -1), Color.White), new VertexColor(new Vector3(1, 1, 1), Color.White), new VertexColor(new Vector3(1, 1, -1), Color.White), }); ShipModel = new Model(modelFolder + "cruiser/ship.fbx", device, Matrix.Scaling(.05f) * Matrix.RotationY(MathUtil.Pi)); ShipModel.Meshes[0].SetNormalTexture(device, modelFolder + "cruiser/normal.png"); ShipModel.Meshes[0].SetEmissiveTexture(device, modelFolder + "cruiser/emissive.png"); ShipModel.Meshes[0].SetSpecularTexture(device, modelFolder + "cruiser/specular.png"); ShipModel.SpecularColor = Color.White; ShipModel.Shininess = 200; ShipModel.SpecularIntensity = 1; GunModel = new Model(modelFolder + "gun/gun.fbx", device, Matrix.Scaling(.02f)); GunModel.Meshes[0].SetNormalTexture(device, modelFolder + "gun/normal.png"); GunModel.Meshes[0].SetSpecularTexture(device, modelFolder + "gun/specular.png"); GunModel.SpecularColor = Color.White; GunModel.SpecularIntensity = .1f; CylinderModel = new Model(modelFolder + "cylinder.fbx", device); CylinderModel.SpecularColor = Color.White; CylinderModel.Shininess = 200; CylinderModel.SpecularIntensity = 0; TreeModel = new Model(modelFolder + "tree/tree.fbx", device); TreeModel.Meshes[0].SetNormalTexture(device, modelFolder + "tree/leaf_normal.png"); TreeModel.Meshes[0].SetSpecularTexture(device, modelFolder + "tree/leaf_specular.png"); TreeModel.SpecularColor = Color.White; TreeModel.Shininess = 0; TreeModel.SpecularIntensity = 0; ResourceUtil.LoadFromFile(device, modelFolder + "tree/imposter_diffuse.png", out TreeModelImposterDiffuse); ResourceUtil.LoadFromFile(device, modelFolder + "tree/imposter_normal.png", out TreeModelImposterNormals); ResourceUtil.LoadFromFile(device, "data/textures/grass.dds", out GrassTexture); }