<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".cs" #>
// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version: 17.0.0.0
//  
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;


<#

void WriteAllVertexTypePermutations(string baseTemplate)
{
    WriteLine("switch(numJoints)");

    PushIndent("            ");

    WriteLine("{"); PushIndent("    ");

    for (int __jnt = 0; __jnt <= 8; __jnt += 4)
    {
        WriteLine("case " + __jnt + ":");
        WriteLine("switch(numCols)");
        WriteLine("{"); PushIndent("    ");

        for(int __col = 0; __col <= 2; ++__col)
        {
            WriteLine("case " + __col + ":");
            WriteLine("switch(numUV)");
            WriteLine("{"); PushIndent("    ");

            for(int __tex = 0; __tex <= 4; ++__tex)
            {
                WriteLine("case " + __tex + ":");

                var matType = "VertexEmpty";
                var jntType = "VertexEmpty";

                if (__col == 0 && __tex != 0) matType = $"VertexTexture{__tex}";
                if (__col != 0 && __tex == 0) matType = $"VertexColor{__col}";
                if (__col != 0 && __tex != 0) matType = $"VertexColor{__col}Texture{__tex}";

                if (__jnt == 4) jntType = "VertexJoints4";
                if (__jnt == 8) jntType = "VertexJoints8";

                var a = $"{baseTemplate}<VertexPosition,{matType},{jntType}>";
                var b = $"{baseTemplate}<VertexPositionNormal,{matType},{jntType}>";
                var c = $"{baseTemplate}<VertexPositionNormalTangent,{matType},{jntType}>";

                PushIndent("    ");
                WriteLine($"if (!hasNormals) return (typeof({a}), ()=> new {a}() );");
                WriteLine($"if (!hasTangents) return (typeof({b}), ()=> new {b}() );");
                WriteLine($"return (typeof({c}), ()=> new {c}() );");                       
                PopIndent();
            }

            WriteLine("default: throw new ArgumentOutOfRangeException(nameof(numUV));");
            PopIndent(); WriteLine("}");                        
        }

        WriteLine("default: throw new ArgumentOutOfRangeException(nameof(numCols));");
        PopIndent(); WriteLine("}");                    
    }
                
    WriteLine("default: throw new ArgumentOutOfRangeException(nameof(numJoints));");
    PopIndent(); WriteLine("}");

    WriteLine("throw new NotImplementedException();");

    PopIndent();    
}

#>


namespace SharpGLTF.Geometry.VertexTypes
{
    partial class VertexUtils
    {            
        public static (Type BuilderType, Func<IVertexBuilder> BuilderFactory) GetVertexBuilderType(bool hasNormals, bool hasTangents, int numCols, int numUV, int numJoints)
        {
            <# WriteAllVertexTypePermutations("VertexBuilder"); #>
        }
    }    
}