using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX;
using System.Drawing;

namespace DirectXEksempel07
{
    class Building : ModelComponent
    {
        private Mesh mesh;
        private Color theColor;
        private Device theDevice;
        private Vector3 lowerLeft;
        private Vector3 upperRight;

        public Vector3 LowerLeft
        {
            get { return lowerLeft; }
        }

        public Vector3 UpperRight
        {
            get { return upperRight; }
        }

        public Building(Device aDevice, Vector3 aPosition, Color aColor, 
            float aWidth, float aHeight, float aDepth) : base(aPosition)
        {
            theDevice = aDevice;
            mesh = Mesh.Box(theDevice, aWidth, aHeight, aDepth);
            theColor = aColor;
            lowerLeft.X = Position.X - aWidth / 2;
            upperRight.X = Position.X + aWidth / 2;
            lowerLeft.Y = Position.Y - aHeight / 2;
            upperRight.Y = Position.Y + aHeight / 2;
            lowerLeft.Z = Position.Z - aDepth / 2;
            upperRight.Z = Position.Z + aDepth / 2;
        }

        public void Render()
        {
            Material meshMaterial = new Material();
            meshMaterial.AmbientColor = new ColorValue(theColor.R, theColor.G, theColor.B);
            meshMaterial.DiffuseColor = new ColorValue(theColor.R, theColor.G, theColor.B);
            theDevice.Transform.World = Matrix.Translation(Position);
            theDevice.Material = meshMaterial;
            theDevice.SetTexture(0, null);
            mesh.DrawSubset(0);
        }

    }
}
