using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HaloPlugins.H2.Xbox;

namespace HaloPlugins.Xbox
{
    public class mode : TagDefinition
    {
       public mode() : base("mode", "render_model", 132, new ModelDefinition())
       {
           Fields.AddRange(new IMetaNode[] {
           new StringId("Model Name"),
           new Flags("Flags", new string[] { "Force_Third_Person", "Force_Carmack_Reverse", "Force_Node_Maps" }, 32),
           new Value("Unknown", typeof(int)),
           new Padding(8),
           new TagBlock("Compression Info", 56, 1, new IMetaNode[] { 
               new Value("X (min)", typeof(float)),
               new Value("X (max)", typeof(float)),
               new Value("Y (min)", typeof(float)),
               new Value("Y (max)", typeof(float)),
               new Value("Z (min)", typeof(float)),
               new Value("Z (max)", typeof(float)),
               new Value("U (min)", typeof(float)),
               new Value("U (max)", typeof(float)),
               new Value("V (min)", typeof(float)),
               new Value("V (max)", typeof(float)),
               new Value("Secondary U (Min)", typeof(float)),
               new Value("Secondary U (max)", typeof(float)),
               new Value("Secondary V (min)", typeof(float)),
               new Value("Secondary V (max)", typeof(float)),
           }),
           new TagBlock("Regions", 16, 16, new IMetaNode[] { 
               new StringId("Part Name"),
               new Value("Node Map Offset", typeof(short)),
               new Value("Node Map Size", typeof(short)),
               new TagBlock("Permutation", 16, 32, new IMetaNode[] { 
                   new StringId("Permutation Name"),
                   new Value("Lowest Piece (Index)", typeof(short)),
                   new Value("Low Piece (Index)", typeof(short)),
                   new Value("Medium-Low Piece (Index)", typeof(short)),
                   new Value("Medium-High Piece (Index)", typeof(short)),
                   new Value("High Piece (Index)", typeof(short)),
                   new Value("Highest Piece (Index)", typeof(short)),
               }),
           }),
           new TagBlock("Sections", 92, 255, new IMetaNode[] { 
               new HaloPlugins.Enum("Global Geometry Classification", new string[] { "Rigid", "Rigid_Boned", "Skinned" }, 32),
               new Value("Vertex Count", typeof(short)),
               new Value("Triangle Count", typeof(short)),
               new Value("Part Count", typeof(short)),
               new Value("Shadow Casting Triangle Cour", typeof(short)),
               new Value("Shadow Casting Part Count", typeof(short)),
               new Value("Opaque Point Count", typeof(short)),
               new Value("Opaque Vertex Count", typeof(short)),
               new Value("Opaque Part Count", typeof(short)),
               new Value("Opaque Max Nodes/Verte", typeof(byte)),
               new Value("Transparent Max Nodes/Verte", typeof(byte)),
               new Value("Shadow Casting Rigid Triangle Count", typeof(short)),
               new HaloPlugins.Enum("Geometry Classification", new string[] { "Rigid", "Rigid_Boned", "Skinned" }, 16),
               new Flags("Unknown", new string[] { "Compressed_Position", "Compressed_Texcoord", "Compressed_Secondary_Texcoord" }, 32),
               new Value("Hardware Node Count", typeof(byte)),
               new Value("Node Map Size", typeof(byte)),
               new Value("Software Plane Count", typeof(byte)),
               new Padding(3),
               new Value("Unknown", typeof(short)),
               new Padding(2),
               new Value("Total SubPart Count", typeof(int)),
               new Flags("Section Lighting FLags", new string[] { "Has_Im_Texcoords", "Has_Im_inc._rad.", "Has_Im_Colors", "Has_Im_prt" }, 8),
               new Value("Rigid Node Index", typeof(byte)),
               new Value("", typeof(byte)),
               new Flags("Flags", new string[] { "Geometry_Postprocessed" }, 8),
               new TagBlock("Section Data", 88, 1, new IMetaNode[] { 
                   new Padding(88),
               }),
               new Value("Raw Offset", typeof(int)),
               new Value("Raw Size", typeof(int)),
               new Value("Raw Header Size", typeof(int)),
               new Value("Raw Data Size", typeof(int)),
               new TagBlock("Resource", 16, -1, new IMetaNode[] { 
                   new Value("Unknown", typeof(int)),
                   new Value("Primary Locator", typeof(short)),
                   new Value("Secondary Locator", typeof(short)),
                   new Value("Size", typeof(int)),
                   new Value("Offset", typeof(int)),
               }),
               new TagIndex("Owner_Tag_Section_Offset", "mode"),
               new Value("Unknown", typeof(int)),
               new Value("Unused", typeof(int)),
           }),
           new TagBlock("Invalid Section Pair Bits", 4, 1013, new IMetaNode[] { 
               new Value("Bits", typeof(int)),
           }),
           new TagBlock("Section Groups", 12, 6, new IMetaNode[] { 
               new Flags("Detail Levels", new string[] { "L1_(super_Low)", "L2_(low", "L3_(medium)", "L4_(high)", "L5_(super_high)", "L6_(hollywood)" }, 32),
               new TagBlock("Compount Nodes", 16, 255, new IMetaNode[] { 
                   new Value("Node Index", typeof(byte)),
                   new Value("Node Index", typeof(byte)),
                   new Value("Node Index", typeof(byte)),
                   new Value("Node Index", typeof(byte)),
                   new Value("Node Weight", typeof(float)),
                   new Value("Node Weight", typeof(float)),
                   new Value("Node Weight", typeof(float)),
               }),
           }),
           new Value("L1 Section Group Index", typeof(short)),
           new Value("L2 Section Group Index", typeof(short)),
           new Value("L3 Section Group Index", typeof(short)),
           new Value("L4 Section Group Index", typeof(short)),
           new Value("L5 Section Group Index", typeof(short)),
           new Value("L6 Section Group Index", typeof(short)),
           new TagBlock("Nodes", 96, 255, new IMetaNode[] { 
               new StringId("Name"),
               new Value("Parent Node Index", typeof(short)),
               new Value("First Child Node Index", typeof(short)),
               new Value("Next Sibling Node Index", typeof(short)),
               new Value("Import Node Index", typeof(short)),
               new Value("Default Translation X", typeof(float)),
               new Value("Default Translation Y", typeof(float)),
               new Value("Default Translation Z", typeof(float)),
               new Value("Default Rotation i", typeof(float)),
               new Value("Default Rotation j", typeof(float)),
               new Value("Default Rotation k", typeof(float)),
               new Value("Default Rotation w", typeof(float)),
               new Value("Inverse Foward i", typeof(float)),
               new Value("Inverse Foward j", typeof(float)),
               new Value("Inverse Foward k", typeof(float)),
               new Value("Inverse Left i", typeof(float)),
               new Value("Inverse Left j", typeof(float)),
               new Value("Inverse Left k", typeof(float)),
               new Value("Inverse Up i", typeof(float)),
               new Value("Inverse Up j", typeof(float)),
               new Value("Inverse Up k", typeof(float)),
               new Value("Inverse Position i", typeof(float)),
               new Value("Inverse Position j", typeof(float)),
               new Value("Inverse Position k", typeof(float)),
               new Value("Inverse Scale", typeof(float)),
               new Value("Distance from Parent", typeof(float)),
           }),
           new Padding(8),
           new TagBlock("Marker Groups", 12, 4096, new IMetaNode[] { 
               new StringId("Name"),
               new TagBlock("Markers", 36, 256, new IMetaNode[] { 
                   new Value("Region index", typeof(byte)),
                   new Value("Permutation Index", typeof(byte)),
                   new Value("Node Index", typeof(short)),
                   new Value("Translation X", typeof(float)),
                   new Value("Translation Y", typeof(float)),
                   new Value("Tranlsation Z", typeof(float)),
                   new Value("Rotation i", typeof(float)),
                   new Value("Rotation j", typeof(float)),
                   new Value("Rotation k", typeof(float)),
                   new Value("Rotation w", typeof(float)),
                   new Value("Scale", typeof(float)),
               }),
           }),
           new TagBlock("Materials", 32, 1024, new IMetaNode[] { 
               new TagReference("Old_Shader", "shad"),
               new TagReference("Shader", "shad"),
               new TagBlock("Propeties", 8, 16, new IMetaNode[] { 
                   new Value("Int Value", typeof(int)),
                   new Value("Real Value", typeof(float)),
               }),
               new Value("Brakable Surface Index", typeof(int)),
               new Padding(4),
           }),
           new Padding(8),
           new Value("Unknown", typeof(float)),
           new TagBlock("Prt Info", 88, 1, new IMetaNode[] { 
               new Value("SH Order", typeof(short)),
               new Value("Clustor Number", typeof(short)),
               new Value("PCA Vectors Per Clustor", typeof(short)),
               new Value("Number of Rays", typeof(short)),
               new Value("Number of Bounces", typeof(short)),
               new Value("Mat Index for sbsfc Scattering", typeof(short)),
               new Value("Length Scale", typeof(float)),
               new Value("Number of LODs", typeof(int)),
               new TagBlock("Lod Info", 12, 6, new IMetaNode[] { 
                   new Value("Clustor Offset", typeof(int)),
                   new TagBlock("Section Info", 8, 255, new IMetaNode[] { 
                       new Value("Section Index", typeof(int)),
                       new Value("PCA Data Offset", typeof(int)),
                   }),
               }),
               new TagBlock("Clustor Basis", 4, 34560, new IMetaNode[] { 
                   new Value("Basis Data", typeof(int)),
               }),
               new Padding(16),
               new Value("Raw Offset", typeof(int)),
               new Value("Raw Size", typeof(int)),
               new Value("Raw Header Size", typeof(int)),
               new Value("Raw Data Size", typeof(int)),
               new TagBlock("Resource", 16, -1, new IMetaNode[] { 
                   new Value("Unknown", typeof(int)),
                   new Value("Unknown", typeof(int)),
                   new Value("Size", typeof(uint)),
                   new Value("Offset", typeof(uint)),
               }),
               new TagIndex("Owner_Section_Data_Offset", "mode"),
               new Value("Unknown", typeof(int)),
               new Value("Unused", typeof(int)),
           }),
           new TagBlock("Section Render Leaves", 8, 255, new IMetaNode[] { 
               new TagBlock("Node Render Leaves", 16, 64, new IMetaNode[] { 
                   new TagBlock("Collision Leaves", 8, 65536, new IMetaNode[] { 
                       new Value("Clustor", typeof(short)),
                       new Value("Surface Reference Count", typeof(short)),
                       new Value("First Surface Reference Index", typeof(int)),
                   }),
                   new TagBlock("Serface References", 8, 262144, new IMetaNode[] { 
                       new Value("Strip Index", typeof(short)),
                       new Value("Lightmap Triangle Index", typeof(short)),
                       new Value("BSP Node Index", typeof(int)),
                   }),
               }),
           }),
           });
       }
    }
}
