using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PG_Sim.Support
{

    #region OBJ handling class and structs

    /// <summary>
    /// Encapsuled params of each body from obj files
    /// </summary>
    class bodyObj
    {
        // quads and triangles in list
        public List<trianglVect> triangles = new List<trianglVect>();
        public List<quadsVect> quads = new List<quadsVect>();

        // surface parameters
        public string texture;
        public color faceColor;
        public string matName; // material name

        public bodyObj (string name)
        {
            matName = name;
        }
        public void setColor(string param)
        {
            faceColor = new color(param);
        }
        public void setTexture(string tex)
        {
            texture = tex.Replace(',','.');
        }
        public void addSquare(quadsVect square)
        {
            quads.Add(square);
        }
        public void addTriangle(trianglVect triangl)
        {
            triangles.Add(triangl);
        }
    }

    /// <summary>
    /// Contains red, green, blue part of color definition
    /// </summary>
    struct color
    {
        public float red;
        public float green;
        public float blue;
        public color(string param)
        {
            // exchange . into ,
            param = param.Replace('.', ',');

            // divide param into components
            string[] parts = param.Trim().Split(' ');
            red = float.Parse(parts[1]);
            green = float.Parse(parts[2]);
            blue = float.Parse(parts[3]);
        }
    }    
    
    /// <summary>
    /// Triangle structure (three vertices)
    /// </summary>
    struct trianglVect 
    {
        // each point represents a coordinates and texture mapping
        public vertices A;
        public vertices B;
        public vertices C;

        public trianglVect(vertices a, vertices b, vertices c)
        {
            A = a;
            B = b;
            C = c;
        }
    }

    /// <summary>
    /// Square structure - to define quads
    /// </summary>
    struct quadsVect 
    {
        // each point represents a coordinates and texture mapping
        public vertices A;
        public vertices B;
        public vertices C;
        public vertices D;

        public quadsVect(vertices a, vertices b, vertices c, vertices d)
        {
            A = a;
            B = b;
            C = c;
            D = d;
        }
    }

    /// <summary>
    /// One vertex - defined by cartesian coordinates and texture mapping coords
    /// </summary>
    class vertices 
    {
        public float coordX;
        public float coordY;
        public float coordZ;

        public float texX;
        public float texY;

        public vertices(float x, float y, float z)
        {
            coordX = x;
            coordY = y;
            coordZ = z;
        }

        public void addTexture(float x, float y)
        {
            texX = x;
            texY = y;
        }
    }

    #endregion;

    static class settings
    {
        public static string basePath = "";//"C:/Cs_source/";
        public static int numForces = 54;
    }

    static public class Logger
    {
        public static void Add(string message)
        {
            Console.WriteLine(message);
        }
    }
}
