コード例 #1
0
ファイル: GEOS.cs プロジェクト: The-Alpha-Project/MDX-Parser
        public List <byte[]> GetIndicies()
        {
            uint[] matrixindexes = MatrixIndexes.ToArray();

            //Parse the bone indices by slicing the matrix groups
            uint[][] slices = new uint[NrOfMatrixGroups][];
            for (int i = 0; i < NrOfMatrixGroups; i++)
            {
                int offset = (i == 0 ? 0 : (int)MatrixGroups[i - 1]);

                slices[i] = new uint[MatrixGroups[i]];
                Array.Copy(matrixindexes, offset, slices[i], 0, slices[i].Length);
            }

            //Construct the final bone arrays
            List <byte[]> boneIndices = new List <byte[]>();

            for (int i = 0; i < NrOfVertices; i++)
            {
                uint[] slice    = slices[VertexGroupIndices[i]];
                byte[] indicies = new byte[4];

                //TODO some slices have more than 4 bone indicies what do??
                for (int j = 0; j < Math.Min(slice.Length, 4); j++)
                {
                    indicies[j] = (byte)(slice[j]);
                }

                boneIndices.Add(indicies);
            }

            return(boneIndices);
        }