public Face[][] ToGroupFaceArray(MeshInformationData[] meshdata)
        {
            Face[][] GroupFaceArray = new Face[meshdata.Length][];

            for (int SubMesh = 0; SubMesh < meshdata.Length; SubMesh++)
            {
                List<Face> FaceArray = new List<Face>(meshdata[0].IndiceLength);

                int Start = meshdata[SubMesh].IndiceStart;
                int End = meshdata[SubMesh].IndiceStart + meshdata[SubMesh].IndiceLength - 2;
                bool Winding = true;

                int Index = 0;
                for (int x = Start; x < End; x++)
                {
                    Face Temp = new Face(IndiceArray[x], IndiceArray[x + 1], IndiceArray[x + 2]);
                    if (!Temp.IsDegenerate)
                    {
                        FaceArray.Add(Temp);
                        if (Winding == false)
                        {
                            short y = Temp.VertexIndices[1];
                            short z = Temp.VertexIndices[2];
                            Temp.VertexIndices[1] = z;
                            Temp.VertexIndices[2] = y;
                            Winding = true;
                        }
                        else
                        {
                            Winding = false;
                        }

                    }
                    else
                    {
                        if (Winding == false) { Winding = true; }
                        else { Winding = false; }
                    }
                    Index++;
                }
                FaceArray.TrimExcess();
                GroupFaceArray[SubMesh] = FaceArray.ToArray();
            }
            return GroupFaceArray;
        }
        public ModelRawData(Stream stream, H2Model.Resource[] resources, H2Model.Section section)
        {
            //SectionData = section;

            int StartOffset = (int)stream.Position;
            Header = new RawHeaderData(stream);
            foreach (H2Model.Resource r in resources)
            {
                stream.Position = StartOffset + RawOffsetStart + r.RawDataOffset;
                
                switch (r.MainRawDataType)
                {
                    case H2Model.ResourceType.BoneMap:
                        BoneData = new BoneData(stream, (uint)r.RawDataSize);
                        break;
                    case H2Model.ResourceType.MeshInformation:
                        MeshInformation = new MeshInformationData[r.RawDataSize / MeshInformationData.Size];
                        for (int x = 0; x < MeshInformation.Length; x++)
                        {
                            MeshInformation[x] = new MeshInformationData(stream);
                        }
                        break;
                    case H2Model.ResourceType.UnknownStruct8:
                        Struct8 = new UnknownStruct8Data[r.RawDataSize / UnknownStruct8Data.Size];
                        for (int x = 0; x < Struct8.Length; x++)
                        {
                            Struct8[x] = new UnknownStruct8Data(stream);
                        }
                        break;
                    case H2Model.ResourceType.Unknown:
                        Struct32 = new UnknownStruct32Data[3];
                        for (int x = 0; x < 3; x++)
                        {
                            Struct32[x] = new UnknownStruct32Data(stream);
                        }
                        break;
                    case H2Model.ResourceType.Vertex:
                        switch (r.SubRawDataType)
                        {
                            case H2Model.ResourceSubType.VertexData:
                                PositionData = new VertexData(stream, (uint)r.RawDataSize);
                                break;
                            case H2Model.ResourceSubType.UVData:
                                TexcoordData = new TexcoordData(stream, (uint)r.RawDataSize);
                                break;
                            case H2Model.ResourceSubType.VectorData:
                                VectorData = new VectorData(stream, (uint)r.RawDataSize);
                                break;
                        }
                        break;
                    case H2Model.ResourceType.TriangleStrip:
                        IndiceData = new TriangleIndiceData(stream, (uint)r.RawDataSize);
                        break;
                }
            }
        }
        public Face[] ToFaceArray(MeshInformationData[] meshdata)
        {
            List<Face> FaceArray = new List<Face>(IndiceArray.Length);

            for (int SubMesh = 0; SubMesh < meshdata.Length; SubMesh++)
            {
                int Start = meshdata[SubMesh].IndiceStart;
                int End = meshdata[SubMesh].IndiceStart + meshdata[SubMesh].IndiceLength - 2;
                bool Winding = true;

                for (int x = Start; x < End; x++)
                {
                    Face Temp = new Face(IndiceArray[x], IndiceArray[x + 1], IndiceArray[x + 2], IndiceArray[x], IndiceArray[x + 1], IndiceArray[x + 2], IndiceArray[x], IndiceArray[x + 1], IndiceArray[x + 2]);
                    Temp.MaterialID = meshdata[SubMesh].ShaderIndex;
                    Temp.GroupID = SubMesh;
                    if (!Temp.IsDegenerate)
                    {
                        FaceArray.Add(Temp);
                        if (Winding == false)
                        {
                            short y = Temp.VertexIndices[1];
                            short z = Temp.VertexIndices[2];
                            Temp.VertexIndices[1] = z;
                            Temp.VertexIndices[2] = y;
                            y = Temp.TexcoordIndices[1];
                            z = Temp.TexcoordIndices[2];
                            Temp.TexcoordIndices[1] = z;
                            Temp.TexcoordIndices[2] = y;
                            y = Temp.NormalIndices[1];
                            z = Temp.NormalIndices[2];
                            Temp.NormalIndices[1] = z;
                            Temp.NormalIndices[2] = y;
                            Winding = true;
                        }
                        else
                        {
                            Winding = false;
                        }

                    }
                    else
                    {
                        if (Winding == false) { Winding = true; }
                        else { Winding = false; }
                    }
                }
            }
            FaceArray.TrimExcess();
            return FaceArray.ToArray();
        }