using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Primitives3D
{
    public class PlanePrimitive : GeometricPrimitive
    {
        #region Variables

        // Nothing here yet.

        #endregion

        #region Constructors
        
        /// <summary>
        /// Constructs a new plane primitive, with the specified size.
        /// </summary>
        public PlanePrimitive(GraphicsDevice graphicsDevice, Vector3 minPoint, Vector3 maxPoint, float texCoordScale)
        {
            // Variables.
            Vector3 pointOne;
            Vector3 pointTwo;
            Vector3 pointThree;
            Vector3 pointFour;

            // Front face (clockwise).
            pointOne = new Vector3(minPoint.X, minPoint.Y, maxPoint.Z);// 0
            pointTwo = new Vector3(minPoint.X, maxPoint.Y, maxPoint.Z); // 1
            pointThree = new Vector3(maxPoint.X, maxPoint.Y, maxPoint.Z); // 2
            pointFour = new Vector3(maxPoint.X, minPoint.Y, maxPoint.Z); // 3

            // First triangle.
            AddIndex(0);
            AddIndex(1);
            AddIndex(2);

            // Second triangle.
            AddIndex(0);
            AddIndex(2);
            AddIndex(3);

            // Four vertices per face.
            AddVertex(pointOne, new Vector3(0, 1, 0), new Vector2(0, 1) * texCoordScale); // Perfekt
            AddVertex(pointTwo, new Vector3(0, 1, 0), new Vector2(0, 0) * texCoordScale); // Perfekt
            AddVertex(pointThree, new Vector3(0, 1, 0), new Vector2(1, 0) * texCoordScale); // Perfekt
            AddVertex(pointFour, new Vector3(0, 1, 0), new Vector2(1, 1) * texCoordScale); // Perfekt

            // Initialize the plane for fast rendering.
            InitializeTexturePrimitive(graphicsDevice);
        }

        #endregion

    } // End of class

} // End of namespace
