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

namespace DirectXEksempel05
{
    class Brick : ModelComponent
    {
        private Mesh mesh;
        private Color color;

        public Brick(Device device, Vector3 aPosition, Color aColor)
            : base(aPosition)
        {
            mesh = Mesh.Box(device, 1f, 1f, 1f);
            color = aColor;
        }

        public void Render(Device device)
        {
            Material meshMaterial = new Material();
            meshMaterial.AmbientColor = new ColorValue(color.R, color.G, color.B);
            meshMaterial.DiffuseColor = new ColorValue(color.R, color.G, color.B);
            device.Transform.World = Matrix.RotationYawPitchRoll(Yaw, Pitch, Roll) *
                Matrix.Translation(Position);
            device.Material = meshMaterial;
            device.SetTexture(0, null);
            mesh.DrawSubset(0);
        }
    }
}
