using System;
using System.Collections.Generic;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using System.IO;

namespace D3DObjekter
{
    public class Building
    {
        Device device;
        Mesh mesh;
        List<Material> materials = new List<Material>();
        public Matrix Matrix;
        float angle = 0;

        public Building(Device device, int bygningsNr)
        {
            this.device = device;

            ExtendedMaterial[] extendedMaterials;
            mesh = Mesh.FromFile(@"..\..\Buildings\1.x", MeshFlags.Managed, device, out extendedMaterials);
            foreach (ExtendedMaterial extendedMaterial in extendedMaterials)
            {
                materials.Add(extendedMaterial.Material3D);
            }
            Matrix = Matrix.Scaling(2.5f, 2.5f, 2.5f);
        }
        public void Render()
        {
            angle += 0.01f;
            device.Transform.World = Matrix * Matrix.RotationY(angle);

            for (int i = 0; i < materials.Count; i++)
            {
                device.Material = materials[i];
                mesh.DrawSubset(i);
            }
        }
    }
}
